Beispiel #1
0
        /// <summary>
        /// Creates the RTP source.
        /// </summary>
        /// <param name="fileSink">The file sink.</param>
        /// <param name="serverAddress">The server address.</param>
        /// <param name="serverRtpPort">The server RTP port.</param>
        /// <param name="serverRtcpPort">The server RTCP port.</param>
        /// <param name="clientRtpPort">The client RTP port.</param>
        /// <param name="clientRtcpPort">The client RTCP port.</param>
        /// <returns>Succeeded or failed.</returns>
        public bool CreateRtpSource(FileSink fileSink, string serverAddress,
                                    int serverRtpPort, int serverRtcpPort,
                                    int clientRtpPort, int clientRtcpPort)
        {
            // Creates rtp socket and rtcp socket:
            ClientSocketBase clientRtpSocket  = null;
            ClientSocketBase clientRtcpSocket = null;
            Socket           socket           = null;

            socket = Utils.CreateUdpSocket(clientRtpPort);
            if (socket == null)
            {
                return(false);
            }

            IPEndPoint iep = new IPEndPoint(IPAddress.Parse(serverAddress), serverRtpPort);

            clientRtpSocket = new ClientSocketUdp(socket, (EndPoint)iep);

            socket = Utils.CreateUdpSocket(clientRtcpPort);
            if (socket != null)
            {
                iep = new IPEndPoint(IPAddress.Parse(serverAddress), serverRtcpPort);
                clientRtcpSocket = new ClientSocketUdp(socket, (EndPoint)iep);
            }

            Source = new RtpSource(fileSink, clientRtpSocket);
            if (Source == null)
            {
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the stream parameters.
        /// </summary>
        /// <param name="clientSessionId">The client session id(unused at present).</param>
        /// <param name="clientAddr">The client address.</param>
        /// <param name="clientRtpPort">The client RTP port.</param>
        /// <param name="clientRtcpPort">The client RTCP port.</param>
        /// <param name="serverRtpPort">The server RTP port.</param>
        /// <param name="serverRtcpPort">The server RTCP port.</param>
        /// <param name="streamToken">The stream token.</param>
        /// <returns>Succeeded or failed.</returns>
        public bool GetStreamParameters(int clientSessionId, string clientAddr,
                                        int clientRtpPort, int clientRtcpPort, int serverRtpPort, int serverRtcpPort,
                                        ref StreamState streamToken)
        {
            // Creates a new media source:
            MediaSource inputSource = CreateStreamSource();

            if (inputSource == null)
            {
                return(false);
            }

            // Creates rtp socket and rtcp socket for the client:
            ClientSocketBase clientRtpSocket  = null;
            ClientSocketBase clientRtcpSocket = null;
            Socket           socket           = null;

            socket = Utils.CreateUdpSocket(serverRtpPort);
            if (socket == null)
            {
                return(false);
            }

            IPEndPoint iep = new IPEndPoint(IPAddress.Parse(clientAddr), clientRtpPort);

            clientRtpSocket = new ClientSocketUdp(socket, (EndPoint)iep);

            socket = Utils.CreateUdpSocket(serverRtcpPort);
            if (socket != null)
            {
                iep = new IPEndPoint(IPAddress.Parse(clientAddr), clientRtcpPort);
                clientRtcpSocket = new ClientSocketUdp(socket, (EndPoint)iep);
            }

            // Creates a sink for this stream:
            RtpSink rtpSink = CreateRtpSink(inputSource, clientRtpSocket);

            if (rtpSink == null)
            {
                return(false);
            }

            // Setups the state of the stream. The stream will get started later:
            streamToken = new StreamState(rtpSink, inputSource, clientRtcpSocket);
            if (streamToken == null)
            {
                return(false);
            }

            return(true);
        }