9 Replies Latest reply on Feb 11, 2010 10:32 AM by Avi Kessner

    How to get maxBytesPerSecond in OSMF?

    turbidity Level 1

      Does anyone know of a way to get the user's bandwidth through OSMF? I would like to get the maxBytesPerSecond off of the NetStreamInfo, but I can't seem to access anything at a lower level than VideoElement, which has its stream and its NetStreamInfo object inaccessible as private. Is there some other source I can get this information from?

        • 1. Re: How to get maxBytesPerSecond in OSMF?
          bringrags Level 4

          By default, the NetStream is private because we'd prefer that clients go through the MediaElement/MediaPlayer API for playback.  But for configuring NetStream or NetConnection, the recommended path is to subclass NetLoader (which gets passed into VideoElement) and override the createNetStream method.  This is where you can gain access to the NetStreamInfo.

          1 person found this helpful
          • 2. Re: How to get maxBytesPerSecond in OSMF?
            turbidity Level 1

            Thanks, Brian! Any chance the maxBytesPerSecond property or the entire NetStreamInfo (or MetricsProvider) object might get exposed on MediaPlayer where bufferTime and the like are? Hint, hint. ;-)

            • 3. Re: How to get maxBytesPerSecond in OSMF?
              bringrags Level 4

              That depends.  Can you explain what you'd like to do with it?  We've been thinking that NetStreamInfo data is more relevant to the "configurer" of the video than to the MediaPlayer client (who is primarily just trying to hook the class up to the UI controls).

              • 4. Re: How to get maxBytesPerSecond in OSMF?
                turbidity Level 1

                I was hoping to do some more involved buffer management than what is currently available in OSMF in the NetStreamSwitchManager. The averageMaxBandwidth and maxBandwidth properties on the RTMPMetricsProvider would be useful there. I could also see those properties and some of the other properties regarding dropped frames and frames per second being useful for diagnostic displays, though not for the average use case for the OSMF player. I'm looking at what it would take to create and use a custom NetStreamSwitchManager, and that makes me want a way to get those metrics directly without having to go that route.

                • 5. Re: How to get maxBytesPerSecond in OSMF?
                  bringrags Level 4

                  I assume that if you're looking at NetStreamSwitchManager it's in order to optimize MBR switches?  If so, the recommended path is to create your own subclass of SwitchingRuleBase (which can use the MetricsProviderBase to get singular and aggregate NetStream metrics) to define your specific rules for switching.

                   

                  If your focus is not on MBR switching but on leveraging the aggregate metrics on RTMPMetricsProvider, you could certainly use that class to influence your decisions about the buffer.  To do so, you could gain access to the NetStream (as we discussed before), pass it into a new RTMPMetricsProvider, and then use the metrics to decide when and how to set the bufferLength and bufferTime properties on the VideoElement's BufferTrait.  It might be nice to encapsulate all of this into a single class that extends MediaElement, so that you could have an AdvancedBufferingVideoElement.  We have a similar example here that implements dual-threshold buffering by extending ProxyElement: http://opensource.adobe.com/svn/opensource/osmf/trunk/apps/samples/framework/ExamplePlayer /org/osmf/examples/buffering/DualThresholdBufferingProxyElement.as.

                  • 6. Re: How to get maxBytesPerSecond in OSMF?
                    turbidity Level 1

                    Yeah, the second case is more of what I'm looking to do. I am looking at implementing a buffering system that sets the buffer time based on some calculations made from the user's bandwidth in order to optimize the buffer time according to the user's bandwidth. I think the class you provide would be the type of solution that would work well without getting too complicated. My only concern would be if buffer management done in the proxy class would conflict with buffer management done by the NetStreamSwitchManager, since that sets it directly on the NetStream rather than going through the BufferTrait. Do you think that would be a problem? If not, then I think what you suggest with extending the ProxyElement might be the solution. Thanks! This is helping quite a bit.

                    • 7. Re: How to get maxBytesPerSecond in OSMF?
                      bringrags Level 4

                      Yes, setting the bufferTime within NetStreamSwitchManager would be a problem.  And I think it's probably inappropriate for us to do that.  The switch manager should focus solely on switching, and we should leverage some other object (probably NetStreamBufferTrait) for setting the buffer, to ensure that you could override that behavior completely.  I've filed a bug on this (FM-436).

                       

                      As an aside, if you end up building the buffering system you're describing and are willing to share, I know there are other developers (myself included!) who'd be interested to see it.

                      • 8. Re: How to get maxBytesPerSecond in OSMF?
                        turbidity Level 1

                        Thanks, Brian! I'm working with David Hassoun on this and we ended up going the route of making our own NetStreamSwitcher class that gets passed in through custom loaders that override the createNetStreamSwitchManager method. We'd certainly love to see something like a NetStreamBufferTrait that allowed for more customization of buffer management. That makes sense, as it looks like the NetStreamSwitchManager only is working with DynamicStreamingResources and not single stream resources, which I believe are URLResources in the loader.

                         

                        In taking a quick look, it seems it would be easy enough to create a custom NetStreamBufferTrait type class, and do the logic in there. And since that has access to the netStream, we can get the NetStreamInfo off it. We'd just need to remove the buffer management logic from our custom NetStreamSwitchManager and move it all into the custom buffer trait. That way we could apply it to whatever video stream without having to make the stream switcher work with something that doesn't actually have multiple streams.

                         

                        Thanks for your help and thanks for filing the bug!

                        • 9. Re: How to get maxBytesPerSecond in OSMF?
                          Avi Kessner

                          Just as a comment.  Another use case that you might want to think about is the fact that there are a few new players out there that allow you to select the bandwidth you have to change the quality of the video.  This is handled as a UI button within the player controls.  It would be nice to be able to auto select the appropriate bandwidth/quality of video option based on the variables mentioned instead of requiring the user to make those settings, yet still allowing the user to change those settings if they wish to.