ossrs / srs

@@ -577,11 +577,13 @@
Loading
577 577
SrsGoApiRtcWhip::SrsGoApiRtcWhip(SrsRtcServer* server)
578 578
{
579 579
    publish_ = new SrsGoApiRtcPublish(server);
580 +
    play_ = new SrsGoApiRtcPlay(server);
580 581
}
581 582
582 583
SrsGoApiRtcWhip::~SrsGoApiRtcWhip()
583 584
{
584 585
    srs_freep(publish_);
586 +
    srs_freep(play_);
585 587
}
586 588
587 589
srs_error_t SrsGoApiRtcWhip::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
@@ -614,6 +616,13 @@
Loading
614 616
    string codec = r->query_get("codec");
615 617
    string app = r->query_get("app");
616 618
    string stream = r->query_get("stream");
619 +
    string action = r->query_get("action");
620 +
    if (action.empty()) {
621 +
        action = "publish";
622 +
    }
623 +
    if (srs_string_ends_with(r->path(), "/whip-play/")) {
624 +
        action = "play";
625 +
    }
617 626
618 627
    // The RTC user config object.
619 628
    SrsRtcUserConfig ruc;
@@ -629,14 +638,14 @@
Loading
629 638
        ruc.req_->vhost = parsed_vhost->arg0();
630 639
    }
631 640
632 -
    srs_trace("RTC whip %s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s",
633 -
        ruc.req_->get_stream_url().c_str(), clientip.c_str(), ruc.req_->app.c_str(), ruc.req_->stream.c_str(),
641 +
    srs_trace("RTC whip %s %s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s",
642 +
        action.c_str(), ruc.req_->get_stream_url().c_str(), clientip.c_str(), ruc.req_->app.c_str(), ruc.req_->stream.c_str(),
634 643
        remote_sdp_str.length(), eip.c_str(), codec.c_str()
635 644
    );
636 645
637 646
    ruc.eip_ = eip;
638 647
    ruc.codec_ = codec;
639 -
    ruc.publish_ = true;
648 +
    ruc.publish_ = (action == "publish");
640 649
    ruc.dtls_ = ruc.srtp_ = true;
641 650
642 651
    // TODO: FIXME: It seems remote_sdp doesn't represents the full SDP information.
@@ -645,7 +654,8 @@
Loading
645 654
        return srs_error_wrap(err, "parse sdp failed: %s", remote_sdp_str.c_str());
646 655
    }
647 656
648 -
    if ((err = publish_->serve_http(w, r, &ruc)) != srs_success) {
657 +
    err = action == "publish" ? publish_->serve_http(w, r, &ruc) : play_->serve_http(w, r, &ruc);
658 +
    if (err != srs_success) {
649 659
        return srs_error_wrap(err, "serve");
650 660
    }
651 661

@@ -357,13 +357,7 @@
Loading
357 357
class SrsVideoPayload : public SrsCodecPayload
358 358
{
359 359
public:
360 -
    struct H264SpecificParameter
361 -
    {
362 -
        std::string profile_level_id;
363 -
        std::string packetization_mode;
364 -
        std::string level_asymmerty_allow;
365 -
    };
366 -
    H264SpecificParameter h264_param_;
360 +
    H264SpecificParam h264_param_;
367 361
368 362
public:
369 363
    SrsVideoPayload();

@@ -505,10 +505,16 @@
Loading
505 505
        return srs_error_wrap(err, "handle publish");
506 506
    }
507 507
508 +
    // Generally, WHIP is a publishing protocol, but it can be also used as playing.
508 509
    if ((err = http_api_mux->handle("/rtc/v1/whip/", new SrsGoApiRtcWhip(this))) != srs_success) {
509 510
        return srs_error_wrap(err, "handle whip");
510 511
    }
511 512
513 +
    // We create another mount, to support play with the same query string as publish.
514 +
    if ((err = http_api_mux->handle("/rtc/v1/whip-play/", new SrsGoApiRtcWhip(this))) != srs_success) {
515 +
        return srs_error_wrap(err, "handle whip play");
516 +
    }
517 +
512 518
#ifdef SRS_SIMULATOR
513 519
    if ((err = http_api_mux->handle("/rtc/v1/nack/", new SrsGoApiRtcNACK(this))) != srs_success) {
514 520
        return srs_error_wrap(err, "handle nack");

@@ -2977,6 +2977,9 @@
Loading
2977 2977
                    SrsVideoPayload* video_payload = new SrsVideoPayload(payload.payload_type_, payload.encoding_name_, payload.clock_rate_);
2978 2978
                    video_payload->set_h264_param_desc(payload.format_specific_param_);
2979 2979
2980 +
                    // Set the codec parameter for H.264, to make Unity happy.
2981 +
                    video_payload->h264_param_ = h264_param;
2982 +
2980 2983
                    // TODO: FIXME: Only support some transport algorithms.
2981 2984
                    for (int k = 0; k < (int)payload.rtcp_fb_.size(); ++k) {
2982 2985
                        const string& rtcp_fb = payload.rtcp_fb_.at(k);
@@ -3061,6 +3064,8 @@
Loading
3061 3064
                    stream_desc->audio_track_desc_ = track_desc_copy;
3062 3065
                } else if (remote_media_desc.is_video()) {
3063 3066
                    stream_desc->video_track_descs_.push_back(track_desc_copy);
3067 +
                } else {
3068 +
                    srs_freep(track_desc_copy);
3064 3069
                }
3065 3070
            }
3066 3071
            track_id = ssrc_info.msid_tracker_;
Files Coverage
trunk 58.50%
Project Totals (133 files) 58.50%
Untitled

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading