Ejemplo n.º 1
0
        public void rtmptConnect(string[] c_params)
        {

            PersistantHTTPConnection connection = new PersistantHTTPConnection(sParams.ServerURL,
                sParams.Port);

      
            
            req = (HttpWebRequest)WebRequest.Create(
                "http://" + sParams.ServerURL + ":" + sParams.Port + "/send/" + clientIndex + "/" + pollCount
            );
            req.ContentType = "application/x-fcs";
            req.Method = "POST";
            req.KeepAlive = true;

            //using the client index connect to the application
            AMFHeader header = new AMFHeader(AMFHeader.HEADER_12, 0x3);
            header.EndPoint = 0;
            header.TimeStamp = 1;
            header.RTMPType = AMFHeader.RTMP_TYPE_FUNCTION;
            header.BodySize = 0;

            requestStream = req.GetRequestStream();
           

            //write the method name (connect);
            AMFString aString = new AMFString("connect");
            aString.write(buffer);
            buffer.Write(reserved1, 0, reserved1.Length);

            AMFObject aConnParams = new AMFObject();
            aConnParams.addParameter("app", new AMFString(sParams.ApplicationName));
            aConnParams.addParameter("flashVer", new AMFString("WIN 8,0,24,0"));
            aConnParams.addParameter("swfUrl", new AMFString("xfile://c:\\swfurl.swf"));
            aConnParams.addParameter("tcUrl", new AMFString("rtmp://" + sParams.ServerURL + "/" + sParams.ApplicationName));
            aConnParams.addParameter("fpad", new AMFBoolean(false));
            aConnParams.addParameter("name", new AMFString("ePresence"));

            aConnParams.write(buffer);

            foreach (string s in c_params)
            {
                new AMFString(s).write(buffer);
            }

            header.BodySize = (int)buffer.Position;
            Console.Write(header.BodySize);
            header.writeHeader(requestStream);
            requestStream.Write(buffer.GetBuffer(), 0, (int)buffer.Position);

 
            resp = (HttpWebResponse)req.GetResponse();
            responseReader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
            Console.WriteLine(responseReader.ReadToEnd());


        }
Ejemplo n.º 2
0
        public LinkedList<AMFDataType> getParameters(byte[] data, int length)
        {
            AMFHeader headerResponse = AMFHeader.readHeader(0, data);
            MemoryStream inStream = new MemoryStream(data);
            inStream.Position = headerResponse.getHeaderSize();

            //since we are only dealing with function calls...
            //the first information is going to be A Function name. (AMF String)

            AMFString function = new AMFString("");
            function.read(inStream);

            inStream.Close();


            return null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Publish a stream on the server.
        /// </summary>
        private void rtmpPublish()
        {
            outputBuff.Position = 0;

            AMFHeader header = new AMFHeader(AMFHeader.HEADER_12, 0x8);
            header.EndPoint = 0x1;
            header.TimeStamp = 0x25;
            header.RTMPType = AMFHeader.RTMP_TYPE_FUNCTION;
            header.BodySize = 0;


            AMFString func = new AMFString("publish");
            func.write(outputBuff);
            byte[] n_reserved = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            outputBuff.Write(n_reserved, 0, n_reserved.Length);
            new AMFNull().write(outputBuff);
            new AMFString(sParams.PublishName).write(outputBuff);
            AMFString live = new AMFString(sParams.Record ? "record" : "live");
            live.write(outputBuff);
            header.BodySize = (int)outputBuff.Position;

            //send the information
            chunkBufferAndSend(header);

            int l = connectionSocket.Receive(dataBuffer);


        }
Ejemplo n.º 4
0
        public override void call(string methodName, fMethodCallback callbackFunc, params object[] pobject)
        {
            outputBuff.Position = 0;
            AMFHeader header = new AMFHeader(AMFHeader.HEADER_12, 0x3);
            header.EndPoint = 0;
            header.TimeStamp = 1;
            header.RTMPType = AMFHeader.RTMP_TYPE_FUNCTION;
            header.BodySize = 0;

            AMFString func = new AMFString(methodName);
            func.write(outputBuff);

            outputBuff.Write(c_reserved, 0, c_reserved.Length);

            new AMFNull().write(outputBuff);

            foreach (object o in pobject)
            {
               AMFDataType dObj = AMFDataType.findDataHandler(o);
               dObj.write(outputBuff);

            }
            header.BodySize = (int)outputBuff.Position;
            chunkBufferAndSend(header);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a Live Stream on the server
        /// </summary>
        private void rtmpCreateStream()
        {
            outputBuff.Position = 0;

            AMFHeader header = new AMFHeader(AMFHeader.HEADER_12, 0x3);
            header.EndPoint = 0;
            header.TimeStamp = 1;
            header.RTMPType = AMFHeader.RTMP_TYPE_FUNCTION;
            header.BodySize = 0;


            AMFString func = new AMFString("createStream");
            func.write(outputBuff);

            outputBuff.Write(c_reserved, 0, c_reserved.Length);

            new AMFNull().write(outputBuff);

            header.BodySize = (int)outputBuff.Position;

            //send the information
            chunkBufferAndSend(header);


            int l = connectionSocket.Receive(dataBuffer);


        }
Ejemplo n.º 6
0
        /// <summary>
        /// Performs the "connect" method on the server.
        /// </summary>
        private void rtmpConnect(string[] c_params)
        {
            //reset the output buffer position
            outputBuff.Position = 0;


            AMFHeader header = new AMFHeader(AMFHeader.HEADER_12, 0x3);
            header.EndPoint = 0;
            header.TimeStamp = 1;
            header.RTMPType = AMFHeader.RTMP_TYPE_FUNCTION;
            header.BodySize = 0;


            //write the method name (connect);
            AMFString aString = new AMFString("connect");
            aString.write(outputBuff);
            outputBuff.Write(reserved1, 0, reserved1.Length);

            AMFObject aConnParams = new AMFObject();
            aConnParams.addParameter("app", new AMFString(sParams.ApplicationName));
            aConnParams.addParameter("flashVer", new AMFString("WIN 8,0,24,0"));
            aConnParams.addParameter("swfUrl", new AMFString("xfile://c:\\swfurl.swf"));
            aConnParams.addParameter("tcUrl", new AMFString("rtmp://" + sParams.ServerURL +"/" + sParams.ApplicationName));
            aConnParams.addParameter("fpad", new AMFBoolean(false));
            aConnParams.addParameter("name", new AMFString("ePresence"));

            aConnParams.write(outputBuff);

            foreach (string s in c_params)
            {
                new AMFString(s).write(outputBuff);
            }

            //since we only wrote the body, the body size is the positiin
            //in the buffer
            header.BodySize = (int)outputBuff.Position;

            //send the information
            chunkBufferAndSend(header);

            //receive the connection information
            int l =connectionSocket.Receive(dataBuffer);


            //receive the connection information
            l = connectionSocket.Receive(dataBuffer);
            

        }
Ejemplo n.º 7
0
        public override bool disconnect()
        {
            isConnected = false;
            outputBuff.Position = 0;
            AMFHeader header = new AMFHeader(AMFHeader.HEADER_12, 0x8);
            header.EndPoint = 0x00000001;
            header.TimeStamp = 0;
            header.RTMPType = AMFHeader.RTMP_TYPE_FUNCTION;
            header.BodySize = 0;


            AMFString func = new AMFString("publish");
            func.write(outputBuff);
            byte[] n_reserved = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            outputBuff.Write(n_reserved, 0, n_reserved.Length);
            new AMFNull().write(outputBuff);
            new AMFString(sParams.PublishName).write(outputBuff);
            new AMFBoolean(false).write(outputBuff);
            header.BodySize = (int)outputBuff.Position;

            //send the information
            chunkBufferAndSend(header);

            connectionSocket.Disconnect(true);

            return true;
        }