actionscript-3flashrtmpnetstreamnetconnection

Is there a way to write a |RtmpSampleAccess command to a NetStream in data generation mode?


I'm streaming data from a server and passing it into a net stream in data generation mode. I'm successfully wrapping H264 and PCMU to be played back through NetStream, however I need to be able to capture this output from the video display it's on and store it in an image. When using an RTMP server, I'd configure it to send an RtmpSampleAccess command, with true,true for audio and video access allowed. When using RTMFP I'd do the same, send() a RtmpSampleAccess true,true from the peer to allow access.

I believe I need to send in an FLV tag for a script data object to represent the RtmpSampleAccess command, however I can't find any information on what the format of that tag needs to be. I've tried using the OSMF FLVTagScriptDataObject with the objects set to the following combinations:

["|RtmpSampleAccess", true, true];
["|RtmpSampleAccess", [true, true]];

And various attempts at guessing the naming for object parameters (though looking at the protocol docs, I'm not sure there is one).

Could someone out there help me here, would be much appreciated.


Solution

  • Where you put your Netstream into Data Generation mode you add a second Play command. The second one simply plays "a blank" and for some reason this overrides the security error.

    ns.play(null);
    ns.play(""); //works to avoid all security errors
    ns.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
    

    Then to draw just setup a button to run the draw_VideoFrame function when clicked, or try real-time drawing with something like below (using enterFrame):

    vid_Obj.addEventListener(Event.ENTER_FRAME, draw_VideoFrame);
    

    and then create a function like this example.

    function draw_VideoFrame (e:Event) : void
    {
        vid_BMD.draw( vid_Obj ); //draw into a BitMapData variable
    }