Skip to main content
didoin
Participant
September 17, 2015
Question

Publish stream on RTMFP+H264 work with only one receiver?

  • September 17, 2015
  • 2 replies
  • 455 views

Hi, when I try to publish a video stream on rtmfp://p2p.rtmfp.net/ using codec H264 type DIRECT_CONNECTIONS, the first receiver that connect to the publisher correctly display the video stream, but when I try to connect a second receiver, it (the seconds) receives only a black frame.


Other tests I did were:

     1) Publish a video stream on rtmfp://p2p.rtmfp.net/ using codec H264 type DIRECT_CONNECTIONS;

     2) Start the receiver that connects to the publisher (the receiver correctly displays the video stream);

     3) Close the connection to the publisher by the receiver.

     4) Restart the receiver and reconnecting it to the publisher (I receive now only frame blacks).

I tried to publish using the Sorenson codec and works quietly without any problems, so I assume the problem is on H264

.

Someone else has encountered the same problem?

This topic has been closed for replies.

2 replies

didoin
didoinAuthor
Participant
September 23, 2015

No one has ever had the same problem?

didoin
didoinAuthor
Participant
September 18, 2015

This is the code of the publisher used:


public function publish():void

{

    _netConnection = new NetConnection();

    _netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

    _netConnection.connect("rtmfp://p2p.rtmfp.net/" + DEVELOPER_KEY + '/');

}

public function netStatusHandler(event:NetStatusEvent):void

{

    switch (event.info.code)

    {

        case "NetConnection.Connect.Success":

        {

            var groupSpecifier:GroupSpecifier = new GroupSpecifier(_groupName);

           

            groupSpecifier.serverChannelEnabled                 = true;

            groupSpecifier.ipMulticastMemberUpdatesEnabled         = true;   

            groupSpecifier.postingEnabled                         = true;               

            groupSpecifier.routingEnabled                        = false;

            groupSpecifier.peerToPeerDisabled                    = false;       

            groupSpecifier.multicastEnabled                     = false;

            groupSpecifier.objectReplicationEnabled             = false;

           

            _netGroup = new NetGroup(_netConnection, groupSpecifier.groupspecWithAuthorizations());

            _netGroup.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

            break;

        }

           

        case "NetGroup.Connect.Success":

        {

            publish(_camera, _microphone, _videoSettings);

           

            break;

        }

    }

}

public function publish(camera:Camera, microphone:Microphone, videoSettings:VideoStreamSettings = null):void

{

    _netStreamMetaData = new Object();

    // Inizializza i metadati

    if (videoSettings)

    {

        _netStreamMetaData.codec                 = videoSettings.codec;

        _netStreamMetaData.frameRate             = camera.fps;

        _netStreamMetaData.quality                = camera.quality;

        _netStreamMetaData.bandwith             = camera.bandwidth;

        _netStreamMetaData.width                 = camera.width;

        _netStreamMetaData.height                 = camera.height;

        _netStreamMetaData.keyFrameInterval     = camera.keyFrameInterval;

    }

    else

    {

        _netStreamMetaData.codec                 = null;

        _netStreamMetaData.frameRate             = 0;

        _netStreamMetaData.quality                = 0;

        _netStreamMetaData.bandwith             = 0;

        _netStreamMetaData.width                 = 0;

        _netStreamMetaData.height                 = 0;

        _netStreamMetaData.keyFrameInterval     = 0;

    }

       

    // Inizializza il NetStream

    _netStream = new NetStream(_netConnection, NetStream.DIRECT_CONNECTIONS);

    _netStream.client = {};

    _netStream.client.onPeerConnect = function(subscriber:NetStream):Boolean

    {

        return true;

    };

    _netStream.addEventListener(NetStatusEvent.NET_STATUS, netStreamPublisher_netStatusHandler);

    // Impostazioni NetStream

    _netStream.audioReliable     = false;   

    _netStream.dataReliable     = false;

    _netStream.videoReliable     = false;

    _netStream.bufferTime         = 0;

    //_netStream.useJitterBuffer     = true;

    _netStream.attachCamera(camera);

    _netStream.attachAudio(microphone);

    // FIX:

    // http://help.adobe.com/it_IT/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#videoStreamSettings

    if (videoSettings)

        _netStream.videoStreamSettings = videoSettings;

    _netStream.publish("livestream");

}

public function netStreamPublisher_netStatusHandler(event:NetStatusEvent):void

{

    switch (event.info.code)

    {

        case "NetStream.Play.Start":

        {

            // FIX:

            // http://forums.adobe.com/thread/16862

            // https://github.com/OpenRTMFP/Cumulus/issues/43#issuecomment-2758147

            // http://forums.adobe.com/thread/632355?decorator=print&displayFullThread=true

            // http://forums.adobe.com/message/3658836

            _netStream.send("|RtmpSampleAccess", true, true);

           

            _netStream.send("onMetaData", _netStreamMetaData);

           

            break;

        }

    }

}

and this is the code of the receiver:


public function publish():void

{

    _netConnection = new NetConnection();

    _netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

    _netConnection.connect("rtmfp://p2p.rtmfp.net/" + DEVELOPER_KEY + '/');

}

public function netStatusHandler(event:NetStatusEvent):void

{

    switch (event.info.code)

    {

        case "NetConnection.Connect.Success":

        {

            var groupSpecifier:GroupSpecifier = new GroupSpecifier(_groupName);

           

            groupSpecifier.serverChannelEnabled                 = true;

            groupSpecifier.ipMulticastMemberUpdatesEnabled         = true;   

            groupSpecifier.postingEnabled                         = true;               

            groupSpecifier.routingEnabled                        = false;

            groupSpecifier.peerToPeerDisabled                    = false;       

            groupSpecifier.multicastEnabled                     = false;

            groupSpecifier.objectReplicationEnabled             = false;

           

            _netGroup = new NetGroup(_netConnection, groupSpecifier.groupspecWithAuthorizations());

            _netGroup.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

            break;

        }

           

        case "NetGroup.Neighbor.Connect":

        {

            play(_peerID);

           

            break;

        }

    }

}

public function play(peerID:String):void

{   

    _netStream = new NetStream(_netConnection, peerID);

    _netStream.client = {};

               

    //_netStream.useHardwareDecoder = true;

           

    _netStream.play("livestream");

}