Exemplo n.º 1
0
 protected BaseOutNetRTPUDPStream(RtspProtocol pProtocol, StreamsManager pStreamsManager, string name) : base(pProtocol, pStreamsManager, name)
 {
     AudioSSRC    = (uint)(0x80000000 | (Utils.Random.Next() & 0x00ffffff));
     VideoSSRC    = AudioSSRC + 1;
     VideoCounter = (ushort)Utils.Random.Next();
     AudioCounter = (ushort)Utils.Random.Next();
 }
        public static BaseOutNetRTMPStream GetInstance(BaseRTMPProtocol pProtocol, StreamsManager pStreamsManager,
                                                       string name, uint rtmpStreamId, uint chunkSize, ulong inStreamType)
        {
            BaseOutNetRTMPStream result = null;

            if (inStreamType.TagKindOf(StreamTypes.ST_IN_NET_RTMP) ||
                inStreamType.TagKindOf(StreamTypes.ST_IN_NET_RTMFP) ||
                inStreamType.TagKindOf(StreamTypes.ST_IN_NET_LIVEFLV) ||
                inStreamType.TagKindOf(StreamTypes.ST_IN_FILE_RTMP) ||
                inStreamType.TagKindOf(StreamTypes.ST_IN_NET_MP3)
                )
            {
                result = new OutNetRTMP4RTMPStream(pProtocol, pStreamsManager, name, rtmpStreamId, chunkSize);
            }
            else if (inStreamType.TagKindOf(StreamTypes.ST_IN_NET_TS) ||
                     inStreamType.TagKindOf(StreamTypes.ST_IN_NET_RTP) ||
                     inStreamType.TagKindOf(StreamTypes.ST_IN_NET_AAC))
            {
                result = new OutNetRTMP4TSStream(pProtocol, pStreamsManager, name, rtmpStreamId, chunkSize);
            }
            if (result._pChannelAudio != null && result._pChannelVideo != null && result._pChannelCommands != null)
            {
                return(result);
            }
            Logger.FATAL("No more channels left");
            return(null);
        }
        public BaseClientApplication(Variant configuration)
        {
            _configuration = configuration;

            Name = _configuration[Defines.CONF_APPLICATION_NAME];
            var index = Name.IndexOf('/');

            InstanceName = index == -1 ? "_default_" : Name.Substring(index + 1);
            DirPath      = _configuration[Defines.CONF_APPLICATION_DIRECTORY] + InstanceName + "/";
            Aliases      = _configuration[Defines.CONF_APPLICATION_ALIASES] != null ? (_configuration[Defines.CONF_APPLICATION_ALIASES].Children).Select(x => (string)x.Value).ToArray() : new string[0];
            IsDefault    = _configuration[Defines.CONF_APPLICATION_DEFAULT];
            AllowDuplicateInboundNetworkStreams = _configuration[Defines.CONF_APPLICATION_ALLOW_DUPLICATE_INBOUND_NETWORK_STREAMS];

            StreamsManager = new StreamsManager(this);
            SOManager      = new SOManager(this);

            CustomFunctions = GetType()
                              .GetMethods().Where(x => Attribute.IsDefined(x, typeof(CustomFunctionAttribute)))
                              .ToDictionary(
                x =>
                x.GetCustomAttributes(typeof(CustomFunctionAttribute), true)
                .OfType <CustomFunctionAttribute>()
                .Single()
                .Name, y => Delegate.CreateDelegate(typeof(CustomFunction), this, y) as CustomFunction);
        }
Exemplo n.º 4
0
 public InNetRTMPStream(BaseRTMPProtocol pProtocol, StreamsManager pStreamsManager, string name, uint rtmpStreamId, uint chunkSize, uint channelId)
     : base(pProtocol, pStreamsManager, name)
 {
     RtmpStreamId   = rtmpStreamId;
     base.ChunkSize = chunkSize;
     _channelId     = channelId;
     _clientId      = $"{Protocol.Id}_{RtmpStreamId}_{DateTime.Now.Ticks.ToString("X")}";
 }
Exemplo n.º 5
0
 public InNetRTPStream(RtspProtocol _rtsp, StreamsManager streamsManager, string _streamName, StreamCapabilities _streamCapabilities, TimeSpan _rtcpDetectionInterval) : base(_rtsp, streamsManager, _streamName)
 {
     bandwidth = _streamCapabilities.BandwidthHint;
     this._rtcpDetectionInterval = _rtcpDetectionInterval;
     Capabilities  = _streamCapabilities;
     _currentNalu  = Utils.Rms.GetStream();
     _hasAudio     = _streamCapabilities.AudioCodecId != AudioCodec.Unknown;
     _hasVideo     = _streamCapabilities.VideoCodecId != VideoCodec.Unknown;
     _rtcpPresence = RtcpPresence.Unknown;
 }
 public OutNetRTMP4TSStream(BaseRTMPProtocol pProtocol, StreamsManager pStreamsManager, string name, uint rtmpStreamId, uint chunkSize) : base(pProtocol, pStreamsManager, name, rtmpStreamId, chunkSize)
 {
     _pSPSPPS[0]  = 0x17; //0x10 - key frame; 0x07 - H264_CODEC_ID
     _pSPSPPS[1]  = 0;    //0: AVC sequence header; 1: AVC NALU; 2: AVC end of sequence
     _pSPSPPS[2]  = 0;    //CompositionTime
     _pSPSPPS[3]  = 0;    //CompositionTime
     _pSPSPPS[4]  = 0;    //CompositionTime
     _pSPSPPS[5]  = 1;    //version
     _pSPSPPS[9]  = 0xff; //6 bits reserved (111111) + 2 bits nal size length - 1 (11)
     _pSPSPPS[10] = 0xe1; //3 bits reserved (111) + 5 bits number of sps (00001)
 }
 protected BaseOutNetRTMPStream(BaseRTMPProtocol pProtocol, StreamsManager pStreamsManager, string name,
                                uint rtmpStreamId, uint chunkSize)
     : base(pProtocol, pStreamsManager, name)
 {
     RTMPStreamId      = rtmpStreamId;
     ChunkSize         = chunkSize;
     _pChannelAudio    = pProtocol.ReserveChannel();
     _pChannelVideo    = pProtocol.ReserveChannel();
     _pChannelCommands = pProtocol.ReserveChannel();
     _clientId         = $"{Protocol.Id}_{RTMPStreamId}_{Utils.Random.Next(10000000, 99999999)}";
     InternalReset();
 }
Exemplo n.º 8
0
 public OutNetRTPUDPH264Stream(RtspProtocol pProtocol, StreamsManager pStreamsManager, string name, bool forceTcp) : base(pProtocol, pStreamsManager, name)
 {
     _forceTcp         = forceTcp;
     _maxRTPPacketSize = _forceTcp ? 1500 : MAX_RTP_PACKET_SIZE;
     _videoData        = new MsgHdr {
         Buffers = new[] { new byte[14], new byte[0], }
     };
     _videoData.Buffers[0][0] = 0x80;
     _videoData.Buffers[0].Write(8, VideoSSRC);
     _audioData = new MsgHdr {
         Buffers = new[] { new byte[14], new byte[16], null }
     };
     _audioData.Buffers[0][0] = 0x80;
     _audioData.Buffers[0][1] = 0xe0;
     _audioData.Buffers[0].Write(8, AudioSSRC);
 }
Exemplo n.º 9
0
        public static InFileRTMPStream GetInstance(BaseProtocol pRTMPProtocol, StreamsManager pStreamsManager,
                                                   Variant metadata)
        {
            metadata[META_RTMP_META, HTTP_HEADERS_SERVER] = HTTP_HEADERS_SERVER_US;
            if (!File.Exists(metadata[META_SERVER_FULL_PATH]))
            {
                WARN("File not found. fullPath: `{0}`", metadata[META_SERVER_FULL_PATH]);
                return(null);
            }
            InFileRTMPStream pResult = null;

            switch ((string)metadata[META_MEDIA_TYPE])
            {
            case MEDIA_TYPE_FLV:
            case MEDIA_TYPE_LIVE_OR_FLV:
            case MEDIA_TYPE_MP3:
            case MEDIA_TYPE_MP4:
            case MEDIA_TYPE_M4A:
            case MEDIA_TYPE_M4V:
            case MEDIA_TYPE_MOV:
                pResult = new InFileRTMPStream(pRTMPProtocol,
                                               pStreamsManager, metadata[META_SERVER_FULL_PATH]);
                break;

            default:
                FATAL("File type not supported yet. Metadata:\n{0}",
                      metadata);
                break;
            }

            if (pResult != null)
            {
                pResult.CompleteMetadata = metadata;
            }

            return(pResult);
        }
Exemplo n.º 10
0
 public OutFileRTMPFLVStream(BaseProtocol pProtocol, StreamsManager pStreamsManager, string filePath, string name) : base(pProtocol, pStreamsManager, filePath, name)
 {
 }
Exemplo n.º 11
0
 public InFileRTMPStream(BaseProtocol pProtocol, StreamsManager pStreamsManager, string name) : base(pProtocol, pStreamsManager, name)
 {
     base.ChunkSize = 4 * 1024 * 1024;
 }
Exemplo n.º 12
0
 public OutClusterStream(BaseClusterProtocol pProtocol, StreamsManager pStreamsManager, string name, uint streamId)
     : base(pProtocol, pStreamsManager, name)
 {
     StreamId = streamId;
 }
Exemplo n.º 13
0
 public OutNetRtmfpStream(Session pProtocol, StreamsManager pStreamsManager, uint id, string name)
     : base(pProtocol, pStreamsManager, name)
 {
     Id = id;
 }
Exemplo n.º 14
0
        public OutNetMP4RTMPStream(Mp4Protocol pProtocol, StreamsManager pStreamsManager, string name) : base(pProtocol, pStreamsManager, name)
        {
            var inStream = pStreamsManager.FindByTypeByName(StreamTypes.ST_IN_NET_RTMP, name, true, false).Values.FirstOrDefault() as IInStream;

            inStream?.Link(this);
        }
Exemplo n.º 15
0
 public OutNetRTMP4RTMPStream(BaseRTMPProtocol pProtocol, StreamsManager pStreamsManager, string name, uint rtmpStreamId, uint chunkSize)
     : base(pProtocol, pStreamsManager, name, rtmpStreamId, chunkSize)
 {
 }
Exemplo n.º 16
0
 public InNetRtmfpStream(Session pProtocol, StreamsManager pStreamsManager, string name)
     : base(pProtocol, pStreamsManager, name)
 {
 }