private InitVideoH264 ( byte pSPS, byte pPPS ) : bool | ||
pSPS | byte | |
pPPS | byte | |
Результат | bool |
public bool Initialize() { if (_rtsp.Application == null) { FATAL("RTSP protocol not yet assigned to an application"); return(false); } //2. Compute the bandwidthHint uint bandwidth = 0; if (_videoTrack != null) { bandwidth += _videoTrack["bandwidth"]; } if (_audioTrack != null) { bandwidth += _audioTrack["bandwidth"]; } if (bandwidth == 0) { bandwidth = _bandwidthHint; } if (_streamName == "") { _streamName = $"rtsp_{_rtsp.Id}"; } if (!_rtsp.Application.StreamNameAvailable(_streamName, _rtsp)) { FATAL("Stream name {0} already taken", _streamName); return(false); } var streamCapabilities = new StreamCapabilities { BandwidthHint = bandwidth }; if (_videoTrack != null) { streamCapabilities.VideoCodecId = VideoCodec.H264; streamCapabilities.InitVideoH264(Utils.DecodeFromBase64(_videoTrack["h264SPS"]), Utils.DecodeFromBase64(_videoTrack["h264PPS"])); } if (_audioTrack != null) { streamCapabilities.AudioCodecId = (AudioCodec)(byte)_audioTrack["codec"]; switch (streamCapabilities.AudioCodecId) { case AudioCodec.Aac: var aac = Utils.DecodeFromHex(_audioTrack["codecSetup"]); streamCapabilities.InitAudioAAC(new MemoryStream(aac), aac.Length); streamCapabilities.Samplerate = streamCapabilities.Aac._sampleRate; break; default: streamCapabilities.Samplerate = _audioTrack["rate"]; break; } } _inStream = new InNetRTPStream(_rtsp, _rtsp.Application.StreamsManager, _streamName, streamCapabilities, _rtcpDetectionInterval); var session = _rtsp.CustomParameters; if (session["customParameters", "externalStreamConfig", "width"] != null && session["customParameters", "externalStreamConfig", "height"] != null) { StreamCapabilities cap = _inStream.Capabilities; if (cap.VideoCodecId == VideoCodec.H264) { cap.Avc._widthOverride = session["customParameters", "externalStreamConfig", "width"]; cap.Avc._heightOverride = session["customParameters", "externalStreamConfig", "height"]; } } if (_rtpVideo != null) { _rtpVideo.SetStream(_inStream, false); _rtpVideo.InboundConnectivity = this; _rtcpVideo.SetInbboundConnectivity(this, false); } if (_rtpAudio != null) { _rtpAudio.SetStream(_inStream, true); _rtpAudio.InboundConnectivity = this; _rtcpAudio.SetInbboundConnectivity(this, true); } //7. Pickup all outbound waiting streams var subscribedOutStreams = _rtsp.Application.StreamsManager.GetWaitingSubscribers( _streamName, _inStream.Type); //FINEST("subscribedOutStreams count: %"PRIz"u", subscribedOutStreams.size()); //8. Bind the waiting subscribers foreach (var subscribedOutStream in subscribedOutStreams) { subscribedOutStream.Link(_inStream); } return(true); }
public bool Initialize() { if (_rtsp.Application == null) { FATAL("RTSP protocol not yet assigned to an application"); return false; } //2. Compute the bandwidthHint uint bandwidth = 0; if (_videoTrack != null) { bandwidth += _videoTrack["bandwidth"]; } if (_audioTrack != null) { bandwidth += _audioTrack["bandwidth"]; } if (bandwidth == 0) { bandwidth = _bandwidthHint; } if (_streamName == "") _streamName = $"rtsp_{_rtsp.Id}"; if (!_rtsp.Application.StreamNameAvailable(_streamName, _rtsp)) { FATAL("Stream name {0} already taken", _streamName); return false; } var streamCapabilities = new StreamCapabilities {BandwidthHint = bandwidth }; if (_videoTrack != null) { streamCapabilities.VideoCodecId = VideoCodec.H264; streamCapabilities.InitVideoH264(Utils.DecodeFromBase64(_videoTrack["h264SPS"]), Utils.DecodeFromBase64(_videoTrack["h264PPS"])); } if (_audioTrack != null) { streamCapabilities.AudioCodecId = (AudioCodec) (byte) _audioTrack["codec"]; switch (streamCapabilities.AudioCodecId) { case AudioCodec.Aac: var aac = Utils.DecodeFromHex(_audioTrack["codecSetup"]); streamCapabilities.InitAudioAAC(new MemoryStream(aac), aac.Length); streamCapabilities.Samplerate = streamCapabilities.Aac._sampleRate; break; default: streamCapabilities.Samplerate = _audioTrack["rate"]; break; } } _inStream = new InNetRTPStream(_rtsp, _rtsp.Application.StreamsManager,_streamName, streamCapabilities, _rtcpDetectionInterval); var session = _rtsp.CustomParameters; if (session["customParameters", "externalStreamConfig", "width"] != null && session["customParameters", "externalStreamConfig", "height"] != null) { StreamCapabilities cap = _inStream.Capabilities; if(cap.VideoCodecId == VideoCodec.H264) { cap.Avc._widthOverride = session["customParameters", "externalStreamConfig", "width"]; cap.Avc._heightOverride = session["customParameters", "externalStreamConfig", "height"]; } } if (_rtpVideo != null) { _rtpVideo.SetStream(_inStream, false); _rtpVideo.InboundConnectivity = this; _rtcpVideo.SetInbboundConnectivity(this,false); } if (_rtpAudio != null) { _rtpAudio.SetStream(_inStream,true); _rtpAudio.InboundConnectivity = this; _rtcpAudio.SetInbboundConnectivity(this,true); } //7. Pickup all outbound waiting streams var subscribedOutStreams = _rtsp.Application.StreamsManager.GetWaitingSubscribers( _streamName, _inStream.Type); //FINEST("subscribedOutStreams count: %"PRIz"u", subscribedOutStreams.size()); //8. Bind the waiting subscribers foreach (var subscribedOutStream in subscribedOutStreams) { subscribedOutStream.Link(_inStream); } return true; }