How do I specify a crossdomain policy file to allow Flash to grab a bitmap from an RTMP (Wowza) video stream?

11,642

Solution 1

It's not a crossdomain.xml issue: Here's the relevant Adobe documentation. I think this post may also be of help.

Solution 2

I am using Wowza too, I had the same problem than you, here what I did:

  1. Changed Application.xml configuration, added * for client > Access > ...

  2. Load a crossDomain.xml file, here the piece of code I use to load http or streaming files:

                var url:String = this.vVideos.selectedItem.url;
                var protocol:String = URLUtil.getProtocol(url).toLowerCase();
                var crossDomainXmlUrl:String;
    
                if (protocol == 'rtmp' || protocol == 'rtmpt')
                {
                    crossDomainXmlUrl = 'http://' + URLUtil.getServerName(url) + ':1935/crossdomain.xml';
                }
                else
                {
                    crossDomainXmlUrl = 'http://' + URLUtil.getServerName(url) + '/crossdomain.xml';
                }
    
                Security.loadPolicyFile(crossDomainXmlUrl);
    
                this.videoMedia.source = url;
                this.videoMedia.visible = true;
    
                setTimeout(this.play,1000);
    

eBuildy, Adobe Flex specialists

Share:
11,642
Ken Smith
Author by

Ken Smith

CTO at Swyfft

Updated on June 05, 2022

Comments

  • Ken Smith
    Ken Smith almost 2 years

    I'm trying to get a bitmap/snapshot of a Wowza video stream playing on my client, like so:

    var bitmapData:BitmapData = new BitmapData(view.videoPlayerComponent.width, view.videoPlayerComponent.height);
    bitmapData.draw(view.videoPlayerComponent);
    

    When I do this, I get this error message:

    SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: http://localhost:51150/Resources/WRemoteWebCam.swf cannot access rtmp://localhost/videochat/smithkl42._default/. No policy files granted access.

    I presume the error comes from not being able to locate the appropriate crossdomain.xml file. I'm not quite sure where it's looking for it, and a wireshark sniff was inconclusive, so I've tried placing one in each of the following places:

    http://localhost/crossdomain.xml
    http://localhost:1935/crossdomain.xml
    http://localhost:51150/crossdomain.xml

    I can retrieve the file successfully from each of those three locations. (I'm pretty sure that the last one wouldn't have any effect, since it's just the location of the web site which hosts the page that hosts the .swf file, but on the off chance...)

    These are the contents of the file that it's grabbing in each instance:

    <cross-domain-policy> 
        <allow-access-from domain="*" to-ports="*" /> 
    </cross-domain-policy>
    

    And it's still throwing that same error message.

    I've also followed the instructions on the Wowza forums, to turn on StreamVideoSampleAccess in the [install]\conf[appname]\Application.xml, with no joy:

    <Client>
        <IdleFrequency>-1</IdleFrequency>
        <Access>
            <StreamReadAccess>*</StreamReadAccess>
            <StreamWriteAccess>*</StreamWriteAccess>
            <StreamAudioSampleAccess>*</StreamAudioSampleAccess>
            <StreamVideoSampleAccess>*</StreamVideoSampleAccess>
            <SharedObjectReadAccess>*</SharedObjectReadAccess>
            <SharedObjectWriteAccess>*</SharedObjectWriteAccess>
        </Access>
    </Client>
    

    Any thoughts?

  • Ken Smith
    Ken Smith over 14 years
    Thanks for the pointer. As it turns out, I'm using wowza rather than FMS, but supposedly Wowza has the same security bit. But I've followed the instructions in <a href="wowzamedia.com/forums/showthread.php?t=4750">this post</a>, to no avail. Editing question to include that bit of info.
  • Ken Smith
    Ken Smith over 14 years
    I figured it out. Your answer was part of the solution; the other bit triggering my problem was that I was trying to grab a bitmap on a non-existent stream. I threw in a slightly more intelligent try/catch, and we're good to go. Thanks.