mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	Fix #2362: Allow WebRTC to play before publishing, for GB28181 as such. 4.0.117
This commit is contained in:
		
							parent
							
								
									ef617b5fc6
								
							
						
					
					
						commit
						d55af6be44
					
				
					 4 changed files with 68 additions and 41 deletions
				
			
		|  | @ -176,6 +176,7 @@ The ports used by SRS: | |||
| 
 | ||||
| ## V4 changes | ||||
| 
 | ||||
| * v4.0, 2021-05-19, Fix [#2362][bug #2362]: Allow WebRTC to play before publishing, for GB28181 as such. 4.0.117 | ||||
| * v4.0, 2021-05-18, Fix [#2355][bug #2355]: GB28181: Fix play by RTC bug. 4.0.116 | ||||
| * v4.0, 2021-05-15, SRT: Build SRT from source by SRS. 4.0.115 | ||||
| * v4.0, 2021-05-15, Rename SrsConsumer* to SrsLiveConsumer*. 4.0.114 | ||||
|  | @ -1926,6 +1927,7 @@ Winlin | |||
| [bug #2304]: https://github.com/ossrs/srs/issues/2304#issuecomment-826009290 | ||||
| [bug #2355]: https://github.com/ossrs/srs/issues/2355 | ||||
| [bug #307]: https://github.com/ossrs/srs/issues/307 | ||||
| [bug #2362]: https://github.com/ossrs/srs/issues/2362 | ||||
| [bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy | ||||
| 
 | ||||
| [bug #1631]: https://github.com/ossrs/srs/issues/1631 | ||||
|  |  | |||
|  | @ -367,7 +367,58 @@ srs_error_t SrsRtcSource::initialize(SrsRequest* r) | |||
| 
 | ||||
|     req = r->copy(); | ||||
| 
 | ||||
|     return err; | ||||
| 	// Create default relations to allow play before publishing.
 | ||||
| 	// @see https://github.com/ossrs/srs/issues/2362
 | ||||
| 	init_for_play_before_publishing(); | ||||
| 
 | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| void SrsRtcSource::init_for_play_before_publishing() | ||||
| { | ||||
|     // If the stream description has already been setup by RTC publisher,
 | ||||
|     // we should ignore and it's ok, because we only need to setup it for bridger.
 | ||||
|     if (stream_desc_) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     SrsRtcSourceDescription* stream_desc = new SrsRtcSourceDescription(); | ||||
|     SrsAutoFree(SrsRtcSourceDescription, stream_desc); | ||||
| 
 | ||||
|     // audio track description
 | ||||
|     if (true) { | ||||
|         SrsRtcTrackDescription* audio_track_desc = new SrsRtcTrackDescription(); | ||||
|         stream_desc->audio_track_desc_ = audio_track_desc; | ||||
| 
 | ||||
|         audio_track_desc->type_ = "audio"; | ||||
|         audio_track_desc->id_ = "audio-" + srs_random_str(8); | ||||
| 
 | ||||
|         uint32_t audio_ssrc = SrsRtcSSRCGenerator::instance()->generate_ssrc(); | ||||
|         audio_track_desc->ssrc_ = audio_ssrc; | ||||
|         audio_track_desc->direction_ = "recvonly"; | ||||
| 
 | ||||
|         audio_track_desc->media_ = new SrsAudioPayload(kAudioPayloadType, "opus", kAudioSamplerate, kAudioChannel); | ||||
|     } | ||||
| 
 | ||||
|     // video track description
 | ||||
|     if (true) { | ||||
|         SrsRtcTrackDescription* video_track_desc = new SrsRtcTrackDescription(); | ||||
|         stream_desc->video_track_descs_.push_back(video_track_desc); | ||||
| 
 | ||||
|         video_track_desc->type_ = "video"; | ||||
|         video_track_desc->id_ = "video-" + srs_random_str(8); | ||||
| 
 | ||||
|         uint32_t video_ssrc = SrsRtcSSRCGenerator::instance()->generate_ssrc(); | ||||
|         video_track_desc->ssrc_ = video_ssrc; | ||||
|         video_track_desc->direction_ = "recvonly"; | ||||
| 
 | ||||
|         SrsVideoPayload* video_payload = new SrsVideoPayload(kVideoPayloadType, "H264", kVideoSamplerate); | ||||
|         video_track_desc->media_ = video_payload; | ||||
| 
 | ||||
|         video_payload->set_h264_param_desc("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f"); | ||||
|     } | ||||
| 
 | ||||
|     set_stream_desc(stream_desc); | ||||
| } | ||||
| 
 | ||||
| void SrsRtcSource::update_auth(SrsRequest* r) | ||||
|  | @ -542,9 +593,6 @@ void SrsRtcSource::on_unpublish() | |||
|         srs_freep(bridger_); | ||||
|     } | ||||
| 
 | ||||
|     // release unpublish stream description.
 | ||||
|     set_stream_desc(NULL); | ||||
| 
 | ||||
|     // TODO: FIXME: Handle by statistic.
 | ||||
| } | ||||
| 
 | ||||
|  | @ -675,46 +723,20 @@ SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcSource* source) | |||
|     audio_sequence = 0; | ||||
|     video_sequence = 0; | ||||
| 
 | ||||
|     SrsRtcSourceDescription* stream_desc = new SrsRtcSourceDescription(); | ||||
|     SrsAutoFree(SrsRtcSourceDescription, stream_desc); | ||||
| 
 | ||||
|     // audio track description
 | ||||
|     // audio track ssrc
 | ||||
|     if (true) { | ||||
|         SrsRtcTrackDescription* audio_track_desc = new SrsRtcTrackDescription(); | ||||
|         stream_desc->audio_track_desc_ = audio_track_desc; | ||||
| 
 | ||||
|         audio_track_desc->type_ = "audio"; | ||||
|         audio_track_desc->id_ = "audio-"  + srs_random_str(8); | ||||
| 
 | ||||
|         audio_ssrc = SrsRtcSSRCGenerator::instance()->generate_ssrc(); | ||||
|         audio_track_desc->ssrc_ = audio_ssrc; | ||||
|         audio_track_desc->direction_ = "recvonly"; | ||||
| 
 | ||||
|         audio_track_desc->media_ = new SrsAudioPayload(kAudioPayloadType, "opus", kAudioSamplerate, kAudioChannel); | ||||
|         std::vector<SrsRtcTrackDescription*> descs = source->get_track_desc("audio", "opus"); | ||||
|         if (!descs.empty()) { | ||||
|             audio_ssrc = descs.at(0)->ssrc_; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // video track description
 | ||||
|     // video track ssrc
 | ||||
|     if (true) { | ||||
|         SrsRtcTrackDescription* video_track_desc = new SrsRtcTrackDescription(); | ||||
|         stream_desc->video_track_descs_.push_back(video_track_desc); | ||||
| 
 | ||||
|         video_track_desc->type_ = "video"; | ||||
|         video_track_desc->id_ = "video-"  + srs_random_str(8); | ||||
| 
 | ||||
|         video_ssrc = SrsRtcSSRCGenerator::instance()->generate_ssrc(); | ||||
|         video_track_desc->ssrc_ = video_ssrc; | ||||
|         video_track_desc->direction_ = "recvonly"; | ||||
| 
 | ||||
|         SrsVideoPayload* video_payload = new SrsVideoPayload(kVideoPayloadType, "H264", kVideoSamplerate); | ||||
|         video_track_desc->media_ = video_payload; | ||||
| 
 | ||||
|         video_payload->set_h264_param_desc("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f"); | ||||
|     } | ||||
| 
 | ||||
|     // If the stream description has already been setup by RTC publisher,
 | ||||
|     // we should ignore and it's ok, because we only need to setup it for bridger.
 | ||||
|     if (!source_->has_stream_desc()) { | ||||
|         source_->set_stream_desc(stream_desc); | ||||
|         std::vector<SrsRtcTrackDescription*> descs = source->get_track_desc("video", "H264"); | ||||
|         if (!descs.empty()) { | ||||
|             video_ssrc = descs.at(0)->ssrc_; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -209,6 +209,9 @@ public: | |||
|     virtual ~SrsRtcSource(); | ||||
| public: | ||||
|     virtual srs_error_t initialize(SrsRequest* r); | ||||
| private: | ||||
|     void init_for_play_before_publishing(); | ||||
| public: | ||||
|     // Update the authentication information in request.
 | ||||
|     virtual void update_auth(SrsRequest* r); | ||||
| private: | ||||
|  |  | |||
|  | @ -26,6 +26,6 @@ | |||
| 
 | ||||
| #define VERSION_MAJOR       4 | ||||
| #define VERSION_MINOR       0 | ||||
| #define VERSION_REVISION    116 | ||||
| #define VERSION_REVISION    117 | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue