4 Replies Latest reply on Jul 28, 2011 1:36 PM by Astor Digital

    HTTP Streaming

    liviez

      Hi all!!

       

      This is my first post in this forum. I've been struggling with this issue for a while but didn't get any solution.

       

      Let's go to the point. I'm developing a video player that would be responsible for playing dynamic streaming resources. I'm managing a content with differente qualities 480p, 720p and 1080p (at different bitrates). I've created an F4M file that looks like:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <manifest xmlns="http://ns.adobe.com/f4m/1.0">

      <id>

           aguila.roja.episode2.es.hd720

      </id>

      <streamType>

           recorded

      </streamType>

      <duration>

           5329.1670000000004

      </duration>

      <deliveryType>streaming</deliveryType>

      <baseURL>http://X.X.X.X/aguila.roja</baseURL>

      <bootstrapInfo

            profile="named"

            id="bootstrap7755"

          >

      ---- THERE IS RAW METADATA HERE -----

      </bootstrapInfo>

       

      <media

                 url="aguila.roja.episode2.es.hd480"

                 bootstrapInfoId="bootstrap7755"

                          bitrate="1500"

      >

      <metadata>

      AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgBAtNEqwIMSbwAFd2lkdGgAQJQAAAAAAAAABmhlaWdodABAhoAAAA AAAAAMdmlkZW9jb2RlY2lkAgAEYXZjMQAMYXVkaW9jb2RlY2lkAgAEbXA0YQAKYXZjcHJvZmlsZQBAWQAAAAAAAAAI YXZjbGV2ZWwAQD8AAAAAAAAABmFhY2FvdAAAAAAAAAAAAAAOdmlkZW9mcmFtZXJhdGUAQDgAAAAAAAAAD2F1ZGlvc2 FtcGxlcmF0ZQBA53AAAAAAAAANYXVkaW9jaGFubmVscwBAAAAAAAAAAAAJdHJhY2tpbmZvCgAAAAIDAAZsZW5ndGgA QP85wAAAAAAACXRpbWVzY2FsZQBAOAAAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAQa5+V8AAAAAACX RpbWVzY2FsZQBA53AAAAAAAAAIbGFuZ3VhZ2UCAANzcGEAAAkAB2N1c3RkZWYKAAAAAAAACQ==

      </metadata>

      </media>

      <media

                 url="aguila.roja.episode2.es.hd720"

                          bitrate="2000"

                 bootstrapInfoId="bootstrap7755"

      >

      <metadata>

      AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgBAtNEqwIMSbwAFd2lkdGgAQJQAAAAAAAAABmhlaWdodABAhoAAAA AAAAAMdmlkZW9jb2RlY2lkAgAEYXZjMQAMYXVkaW9jb2RlY2lkAgAEbXA0YQAKYXZjcHJvZmlsZQBAWQAAAAAAAAAI YXZjbGV2ZWwAQD8AAAAAAAAABmFhY2FvdAAAAAAAAAAAAAAOdmlkZW9mcmFtZXJhdGUAQDgAAAAAAAAAD2F1ZGlvc2 FtcGxlcmF0ZQBA53AAAAAAAAANYXVkaW9jaGFubmVscwBAAAAAAAAAAAAJdHJhY2tpbmZvCgAAAAIDAAZsZW5ndGgA QP85wAAAAAAACXRpbWVzY2FsZQBAOAAAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAQa5+V8AAAAAACX RpbWVzY2FsZQBA53AAAAAAAAAIbGFuZ3VhZ2UCAANzcGEAAAkAB2N1c3RkZWYKAAAAAAAACQ==

      </metadata>

      </media>

      <media

                 url="aguila.roja.episode2.es.hd1080"

                                 bitrate="2400"

                 bootstrapInfoId="bootstrap7755"

      >

      <metadata>

      AgAKb25NZXRhRGF0YQgAAAAAAAhkdXJhdGlvbgBAtNEqwIMSbwAFd2lkdGgAQJQAAAAAAAAABmhlaWdodABAhoAAAA AAAAAMdmlkZW9jb2RlY2lkAgAEYXZjMQAMYXVkaW9jb2RlY2lkAgAEbXA0YQAKYXZjcHJvZmlsZQBAWQAAAAAAAAAI YXZjbGV2ZWwAQD8AAAAAAAAABmFhY2FvdAAAAAAAAAAAAAAOdmlkZW9mcmFtZXJhdGUAQDgAAAAAAAAAD2F1ZGlvc2 FtcGxlcmF0ZQBA53AAAAAAAAANYXVkaW9jaGFubmVscwBAAAAAAAAAAAAJdHJhY2tpbmZvCgAAAAIDAAZsZW5ndGgA QP85wAAAAAAACXRpbWVzY2FsZQBAOAAAAAAAAAAIbGFuZ3VhZ2UCAANlbmcAAAkDAAZsZW5ndGgAQa5+V8AAAAAACX RpbWVzY2FsZQBA53AAAAAAAAAIbGFuZ3VhZ2UCAANzcGEAAAkAB2N1c3RkZWYKAAAAAAAACQ==

      </metadata>

      </media>

      </manifest>

       

      Then I have MyMediaFactory, which extends MediaFactory (from OSMF) and does the following in the constructor:

       

      public function MyMediaFactory()  {

      super();

       

           // Loader for f4m files that contain information about the pseudo-streaming files

           f4mLoader = new F4MLoader(this);

           addItem

      ( new MediaFactoryItem

      ( "org.osmf.elements.f4m"

      , f4mLoader.canHandleResource

      , function():MediaElement

      {

                      return new F4MElement(null, f4mLoader);

      }

      )

      );

       

      // Loader for pseudo-streaming files

      httpStreamingNetLoader = new HTTPStreamingNetLoader();

      addItem

      ( new MediaFactoryItem

      ( "org.osmf.elements.video.httpstreaming"

      , httpStreamingNetLoader.canHandleResource

      , function():MediaElement

      {

      var videoElement: VideoElement = new VideoElement(null,httpStreamingNetLoader);

      videoElement.smoothing = true;

      return videoElement; //new VideoElement(null, httpStreamingNetLoader);

       

      }

      )

      );

       

      loadPlugin(new PluginInfoResource(new CaptioningPluginInfo()));

      addEventListener(MediaFactoryEvent.PLUGIN_LOAD, onCaptionsPluginLoad);

      addEventListener(MediaFactoryEvent.PLUGIN_LOAD_ERROR, onCaptionsPluginLoadError);

       

      // No longer used but kept it, just in case

      //addEventListener(MediaFactoryEvent.MEDIA_ELEMENT_CREATE, onCreateElement);

      }

      }

       

      After the construction of this MediaFactory, I call the function "createMediaElement(videoResource: URLResource)" and it returns the MediaElement created.

       

      The content is correctly displayed but when I try to switch to different quality/birate (given in the F4M manifest file), it's not possible. I've been looking for some info on this and I found the DynamicStreamTrait, which has the capabilities to switch to different media (included in the f4m), etc. Having this implementation, I used the method getTraits to check the available Traits that the mediaElement has. However, it only has the "loadTrait" and I don't know why if, as far as I know, given the f4m and read it successfully, it's supposed to detect the "multi-bitrate/qualities/video files" capability.

       

      I've checked the f4m file following the specs. for the manifest files in OSMF and everything seems to be ok.

       

      Does anyone know how I could have that capability of switching between different video files?? Should I use DynamicStreamingNetLoader instead? What's the difference between HTTPStreamingNetLoader and DynamicStreamingNetLoader?

       

      Any help on this would be really appreciated as I'm really confused and stuck.

       

      Thank you very much

       

      Best Regards

        • 1. Re: HTTP Streaming
          Silviu Vergoti Adobe Employee

          Hi,

           

          OSMF has some helloworld apps and sample players that could help you find the recommended way to play dynamic streams - you do not need a special factory just to play a HDS.

          • 2. Re: HTTP Streaming
            csmaller Level 1

            thanks again!

            I am looking into the F4MLoader class since most of our clients are just sending us a ref to that instead of the classes themselves. can you point me in a direction for a tutorial?  thanks

             

            Corey

            • 3. Re: HTTP Streaming
              csmaller Level 1

              oh, and does that F4MLoader class handle dynamic stream switching?

              • 4. Re: HTTP Streaming
                Astor Digital

                What you are missing is the fact that you get the trait from the MediaElement you just created with your MediaFactory.

                 

                You should also be extending the DefaultMediaFactory since it has built in MediaFactoryItems.

                 

                ...

                var defaultMediaFactory:DefaultMediaFactory = new DefaultMediaFactory();

                var mediaElement:MediaElement = createMediaElement(videoResource: URLResource); //your resource

                var dynamicStreamTrait:DynamicStreamTrait = mediaElement.getTrait(MediaTraitType.DYNAMIC_STREAM) as DynamicStreamTrait;

                //work with the trait

                dynamicStreamTrait.autoSwitch = false;

                dynamicStreamTrait.switchTo(yourBitrateIndex);