Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Harry_Dodgson
Posts: 151
Registered: ‎10-26-2010
My Device: Bold 9900
My Carrier: AT&T

Play video from RAM

Hi,

 

Is there anything like mmr_input_attach() where I can pass it a buffered video stream?

 

Harry

--------------
Accepted PlayBook Applications: Marmi-doos, BASIC, Run and Hide
Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device
My Carrier: Telenor

Re: Play video from RAM

I'm also looking for this, but I don't think that it is possible in the current API.

Please use plain text.
BlackBerry Development Advisor (Retired)
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold
My Carrier: Rogers

Re: Play video from RAM

Hi,

 

Are you asking if there is any way of passing a stream of bytes (encoded bytes; as opposed to be a container, in a URL) and do playback through mm-renderer?

If so, unfortunately, the multimedia platform currently doesn't support this feature. It is being planned and targetted for the future though; but we don't have any confirmed dates of delivery yet.

 

May we know what your use case is? There could be work around.....

 

Cheers,

Rashid

Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device
My Carrier: Telenor

Re: Play video from RAM

Hi,

In our games we have a pak file that contains all assets (png, ogg, videos. We memory map this file, then get a pointer to a file in memory as well as a size.

So it's basically supporting the standard FILE* way of opening files.
Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device
My Carrier: Telenor

Re: Play video from RAM

Only having support for opening files on disk is very inefficient. Android and iOS supports ptr + size as input for their media apis.
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Play video from RAM

We support that too, but only at the lower layers in the multimedia stack right now.

As mentioned, this is all on the roadmap and will be available when time permits.

 

Is your "pak" file compressed?  If not, then you might consider just shipping the assets as individual files.  You don't actually have the data in memory it seems, so there is no advantage over just using files.

 

Cheers,

Sean

Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device
My Carrier: Telenor

Re: Play video from RAM

Our pak file is not compressed. And yes I have the data in virtual memory, mapped and ready to be paged in for streaming.

Besides saving me half a day of work to split out assets for our game that need to be streamed, there are several benefits to memory mapped files. Including:
Avoiding system calls
Avoiding memcpys
More efficient I/O since data is streamed and paged in as needed

Of course, I so not know how efficient QNX's paging system is, but I assume it's quite good seeing as it is a RTOS.

And yes we are talking about milliseconds here, but milliseconds matter a lot when you need to efficiently load assets.

If I were you guys I would release docs for the lower layers, because for gamedevs they are very important.

Thanks a lot for the support guys, don't get me wrong, bb10 has been an extremely easy platform for us to port to.
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Play video from RAM

I think you're missing the fact that mmap() does not actually load the file into ram, but just provides a memory-like interface to the file.  Likewise, if you are using read(), you are already taking advantage of buffering by the filesystem, so chunks of the file will be in main memory already.  Performance is all the same at the bottom layer (blocksizes withstanding).  At the bottom layer in the OS, it's half a dozen of one or 6 of the other :smileyhappy:

 

As for documenting the low layer framework.. it is frightening stuff and is still churning regularly.  The headers alone are over 600,000 lines of code and the complete multimedia codebase is somewhere on the order of 3 million.  Aside from churning regularly, there are enough special use cases and gotchas that unless you sit next to the guys who wrote all of the plugins, filters, streamers, writers, readers, etc., it can sometimes be challenging to implement a graph and get it right on the first attempt.

 

We realize that there is a gap between the easy-to-use-but-less-flexible mm-renderer interface and the difficult-to-use-but-very-flexible low layer framework.  We do intend to provide something which alleviates the difficulty factor of the latter.  It just can't be promised for launch.

 

All that being said.. if you do want to stream files straight out of memory, I am told you may be able to use a pipe.  The caveat being that we have not tested this thoroughly and that if you ever let the pipe run out of data, playback will error out and terminate (eg. make sure to keep the pipe fed!).  At this point though, you may as well be using a file on the filesystem.

 

Cheers,

Sean

Please use plain text.
Contributor
yohan1234
Posts: 25
Registered: ‎11-21-2012
My Device: The alpha device
My Carrier: Telenor

Re: Play video from RAM

[ Edited ]

>I think you're missing the fact that mmap() does not actually load the file into ram, but just provides >a memory-like interface to the file.  Likewise, if you are using read(), you are already taking >advantage of buffering by the filesystem, so chunks of the file will be in main memory already. 

 

In our pak file we have thousands of files, it's several hundreds of megabytes.

 

Are you telling me that it is more efficient for me to load these files over and over again when the user is playing the game? You do understand that by mapping my pak file, I am insuring that my memory does not get fragmented, every time I load a file?

 

Yes, using fread/fopen in a hello world program that prints out text that is a file (given that the size is smaller than the page size) is more efficient than memory mapping it. But otherwise, probably not.

 

You have to count in that, whenever I tell the os or whatever os specific framework I'm using to play the same audio track again, it's highly likely that it is already paged in by the os. In these circumstances, there are some obvious advantages to using memory mapped files.

 

Not to mention doing 0 syscalls whenever I have to load small files. Which is very, very often.

 

Your code size seems very large, and I'm not saying that you should expose everything....just support for ptr as input and size.

 

Pipe is an idea, but seeing as I've inserted a special case for blackberry 10 already, there is no need to change anything :smileyhappy:. Game runs on much more limited hardware than the alpha device has, and runs great on bb10 so I'm happy :smileyhappy:.

 

Johan

Please use plain text.