ossrs / srs

@@ -290,6 +290,7 @@
Loading
290 290
    req_ = new SrsRequest();
291 291
    publish_ = false;
292 292
    dtls_ = srtp_ = true;
293 +
    audio_before_video_ = false;
293 294
}
294 295
295 296
SrsRtcUserConfig::~SrsRtcUserConfig()

@@ -1992,7 +1992,7 @@
Loading
1992 1992
        return srs_error_wrap(err, "publish negotiate");
1993 1993
    }
1994 1994
1995 -
    if ((err = generate_publish_local_sdp(req, local_sdp, stream_desc, ruc->remote_sdp_.is_unified())) != srs_success) {
1995 +
    if ((err = generate_publish_local_sdp(req, local_sdp, stream_desc, ruc->remote_sdp_.is_unified(), ruc->audio_before_video_)) != srs_success) {
1996 1996
        return srs_error_wrap(err, "generate local sdp");
1997 1997
    }
1998 1998
@@ -2058,7 +2058,7 @@
Loading
2058 2058
        ++it;
2059 2059
    }
2060 2060
2061 -
    if ((err = generate_play_local_sdp(req, local_sdp, stream_desc, ruc->remote_sdp_.is_unified())) != srs_success) {
2061 +
    if ((err = generate_play_local_sdp(req, local_sdp, stream_desc, ruc->remote_sdp_.is_unified(), ruc->audio_before_video_)) != srs_success) {
2062 2062
        return srs_error_wrap(err, "generate local sdp");
2063 2063
    }
2064 2064
@@ -2853,9 +2853,14 @@
Loading
2853 2853
    // TODO: FIME: Should check packetization-mode=1 also.
2854 2854
    bool has_42e01f = srs_sdp_has_h264_profile(remote_sdp, "42e01f");
2855 2855
2856 +
    // How many video descriptions we have parsed.
2857 +
    int nn_any_video_parsed = 0;
2858 +
2856 2859
    for (int i = 0; i < (int)remote_sdp.media_descs_.size(); ++i) {
2857 2860
        const SrsMediaDesc& remote_media_desc = remote_sdp.media_descs_.at(i);
2858 2861
2862 +
        if (remote_media_desc.is_video()) nn_any_video_parsed++;
2863 +
2859 2864
        SrsRtcTrackDescription* track_desc = new SrsRtcTrackDescription();
2860 2865
        SrsAutoFree(SrsRtcTrackDescription, track_desc);
2861 2866
@@ -2878,6 +2883,9 @@
Loading
2878 2883
        }
2879 2884
2880 2885
        if (remote_media_desc.is_audio()) {
2886 +
            // Update the ruc, which is about user specified configuration.
2887 +
            ruc->audio_before_video_ = !nn_any_video_parsed;
2888 +
2881 2889
            // TODO: check opus format specific param
2882 2890
            std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("opus");
2883 2891
            if (payloads.empty()) {
@@ -3091,7 +3099,7 @@
Loading
3091 3099
    return err;
3092 3100
}
3093 3101
3094 -
srs_error_t SrsRtcConnection::generate_publish_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan)
3102 +
srs_error_t SrsRtcConnection::generate_publish_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan, bool audio_before_video)
3095 3103
{
3096 3104
    srs_error_t err = srs_success;
3097 3105
@@ -3116,6 +3124,29 @@
Loading
3116 3124
3117 3125
    local_sdp.group_policy_ = "BUNDLE";
3118 3126
3127 +
    if (audio_before_video) {
3128 +
        if ((err = generate_publish_local_sdp_for_audio(local_sdp, stream_desc)) != srs_success) {
3129 +
            return srs_error_wrap(err, "audio");
3130 +
        }
3131 +
        if ((err = generate_publish_local_sdp_for_video(local_sdp, stream_desc, unified_plan)) != srs_success) {
3132 +
            return srs_error_wrap(err, "video");
3133 +
        }
3134 +
    } else {
3135 +
        if ((err = generate_publish_local_sdp_for_video(local_sdp, stream_desc, unified_plan)) != srs_success) {
3136 +
            return srs_error_wrap(err, "video");
3137 +
        }
3138 +
        if ((err = generate_publish_local_sdp_for_audio(local_sdp, stream_desc)) != srs_success) {
3139 +
            return srs_error_wrap(err, "audio");
3140 +
        }
3141 +
    }
3142 +
3143 +
    return err;
3144 +
}
3145 +
3146 +
srs_error_t SrsRtcConnection::generate_publish_local_sdp_for_audio(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc)
3147 +
{
3148 +
    srs_error_t err = srs_success;
3149 +
3119 3150
    // generate audio media desc
3120 3151
    if (stream_desc->audio_track_desc_) {
3121 3152
        SrsRtcTrackDescription* audio_track = stream_desc->audio_track_desc_;
@@ -3150,6 +3181,13 @@
Loading
3150 3181
        local_media_desc.payload_types_.push_back(payload->generate_media_payload_type());
3151 3182
    }
3152 3183
3184 +
    return err;
3185 +
}
3186 +
3187 +
srs_error_t SrsRtcConnection::generate_publish_local_sdp_for_video(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan)
3188 +
{
3189 +
    srs_error_t err = srs_success;
3190 +
3153 3191
    for (int i = 0;  i < (int)stream_desc->video_track_descs_.size(); ++i) {
3154 3192
        SrsRtcTrackDescription* video_track = stream_desc->video_track_descs_.at(i);
3155 3193
@@ -3213,9 +3251,14 @@
Loading
3213 3251
        return srs_error_wrap(err, "fetch rtc source");
3214 3252
    }
3215 3253
3254 +
    // How many video descriptions we have parsed.
3255 +
    int nn_any_video_parsed = 0;
3256 +
3216 3257
    for (int i = 0; i < (int)remote_sdp.media_descs_.size(); ++i) {
3217 3258
        const SrsMediaDesc& remote_media_desc = remote_sdp.media_descs_.at(i);
3218 3259
3260 +
        if (remote_media_desc.is_video()) nn_any_video_parsed++;
3261 +
3219 3262
        // Whether feature enabled in remote extmap.
3220 3263
        int remote_twcc_id = 0;
3221 3264
        if (true) {
@@ -3231,6 +3274,9 @@
Loading
3231 3274
        std::vector<SrsRtcTrackDescription*> track_descs;
3232 3275
        SrsMediaPayloadType remote_payload(0);
3233 3276
        if (remote_media_desc.is_audio()) {
3277 +
            // Update the ruc, which is about user specified configuration.
3278 +
            ruc->audio_before_video_ = !nn_any_video_parsed;
3279 +
3234 3280
            // TODO: check opus format specific param
3235 3281
            vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("opus");
3236 3282
            if (payloads.empty()) {
@@ -3390,7 +3436,7 @@
Loading
3390 3436
    }
3391 3437
}
3392 3438
3393 -
srs_error_t SrsRtcConnection::generate_play_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan)
3439 +
srs_error_t SrsRtcConnection::generate_play_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan, bool audio_before_video)
3394 3440
{
3395 3441
    srs_error_t err = srs_success;
3396 3442
@@ -3417,6 +3463,29 @@
Loading
3417 3463
3418 3464
    std::string cname = srs_random_str(16);
3419 3465
3466 +
    if (audio_before_video) {
3467 +
        if ((err = generate_play_local_sdp_for_audio(local_sdp, stream_desc, cname)) != srs_success) {
3468 +
            return srs_error_wrap(err, "audio");
3469 +
        }
3470 +
        if ((err = generate_play_local_sdp_for_video(local_sdp, stream_desc, unified_plan, cname)) != srs_success) {
3471 +
            return srs_error_wrap(err, "video");
3472 +
        }
3473 +
    } else {
3474 +
        if ((err = generate_play_local_sdp_for_video(local_sdp, stream_desc, unified_plan, cname)) != srs_success) {
3475 +
            return srs_error_wrap(err, "video");
3476 +
        }
3477 +
        if ((err = generate_play_local_sdp_for_audio(local_sdp, stream_desc, cname)) != srs_success) {
3478 +
            return srs_error_wrap(err, "audio");
3479 +
        }
3480 +
    }
3481 +
3482 +
    return err;
3483 +
}
3484 +
3485 +
srs_error_t SrsRtcConnection::generate_play_local_sdp_for_audio(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, std::string cname)
3486 +
{
3487 +
    srs_error_t err = srs_success;
3488 +
3420 3489
    // generate audio media desc
3421 3490
    if (stream_desc->audio_track_desc_) {
3422 3491
        SrsRtcTrackDescription* audio_track = stream_desc->audio_track_desc_;
@@ -3476,6 +3545,13 @@
Loading
3476 3545
        }
3477 3546
    }
3478 3547
3548 +
    return err;
3549 +
}
3550 +
3551 +
srs_error_t SrsRtcConnection::generate_play_local_sdp_for_video(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan, std::string cname)
3552 +
{
3553 +
    srs_error_t err = srs_success;
3554 +
3479 3555
    for (int i = 0;  i < (int)stream_desc->video_track_descs_.size(); ++i) {
3480 3556
        SrsRtcTrackDescription* track = stream_desc->video_track_descs_[i];
3481 3557
Files Coverage
trunk 58.46%
Project Totals (133 files) 58.46%
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