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

Java Development

Reply
New Developer
Posts: 5
Registered: ‎10-28-2009
My Device: Not Specified

How to feed the SourceStream.read() method using the RAW H264 video data streaming from network?

Hello all,

I am writing a program that receiving the RAW H264 video streaming from network.

Video data is CORRECTLY received frame by frame, the READ function is also called by the framework repeatly,

however, it is seem that the player Misunderstanding the video data to audio data.

The following is my code fragment:

 

public final class H264Stream extends DataSource

...

public String getContentType() {  return "video/mp4"; }/* RIGHT? */

 

final class H264SourceStream implements SourceStream

...

public ContentDescriptor getContentDescriptor() { return new ContentDescriptor("video/mp4");  }/* CORRECT? */

...

private int leftBytes = 0;
public int read(byte[] b, int off, int len) throws IOException

   /* read the bytes left last time */
   if(0 != leftBytes)
   {
    int rLen = _dis.read(b, off, leftBytes);/* _dis is the DataInputStream object related with the socket input

stream */
    leftBytes = 0;
    return rLen;
   }


   int frameLe = /*current frame len, retrieved from network*/

   int minLen = frameLen;
   if(len < minLen)
   {
    minLen = len;
    leftBytes = frameLen - minLen;
   }

 

   return _dis.read(b, off, minLen);
}

 

The following debug information is printed by the simulator(Bold 9000):

connect()
getContentType()
start()
getStreams()
getContentLength()
getContentDescriptor()
getSeekType()
len: 58000 offset: 0/*** `len' and `offset' are the arguments passed to the SourceStream.read() function by the

framework ***/
current frame len: 11866/*** current frame length printed in the SourceStream.read() function ***/
getContentLength()
SMPSmiley Frustratedtreaming session aquired id=1799
MN: init0(0)=0
MN: load 0
Player Event: com.rim.loading evenData: null/***  the `Player Event...' line is printed in the PlayerListener ***/
len: 46134 offset: 11866
MN: getPlayableStreams0(0)=1
MN: getLength0(0)=-1
MN: getPlayableStreams0(0)=1
MN: isSeekable0(0)=0
Player Event: com.rim.mediaLoaded evenData: null
Player Event: com.rim.seekableUpdate evenData: false
AR: add source 9
AR: setAudioMode 32/*** WHY AUDIO ***/
MN: play0(0) is audio, NO check for active pause/*** WHY AUDIO ***/
MN: play0(0)=0
Player Event: com.rim.playableStreams evenData: 1
MN: setVideoVisible0(0, 1)=2
Player Event: started evenData: 0
Player Event: bufferingStopped evenData: 0
JVM: bklt @10164: timer
JVM: bklt[1] @10164: idle 0
JVM: bklt @10165: setTimer 22
Player Event: bufferingStarted evenData: 0
len2: 763
len: 45371 offset: 12629
Player Event: bufferingStopped evenData: 0
Player Event: bufferingStarted evenData: 0
current frame len: 50
len: 45321 offset: 12679
current frame len: 375
len: 44946 offset: 13054
current frame len: 585
len: 44361 offset: 13639
current frame len: 124

...

The H264 stream codec parameters:
JVT NAL sequence, baseline profile @ L20
320 x 240 @ 5fps, 32kbps

I hava encapsulated the RAW H264 data into MP4 file and play on the Blod 9000 real handheld using the Media
program, it is decoded and displayed. So I thing the Blackberry OS support the codec without question.

My development envrionment:
eclipse eJDE1.0.0.67_With_CP4.5.0.16
eJDE-4_6_0_19_Component

 

Does anyone faced with the similer problem? Tell me HOW and WHY, OK? Thanks!

New Developer
Posts: 5
Registered: ‎10-28-2009
My Device: Not Specified

Re: How to feed the SourceStream.read() method using the RAW H264 video data streaming from network?

Do I have to add some header for every frame received or

do some initializations to tell the framework something important so that 

the Player display as my expect?

 

Anybody could tell me the true? Thank you!

Developer
Posts: 190
Registered: ‎07-08-2009
My Device: Not Specified

Re: How to feed the SourceStream.read() method using the RAW H264 video data streaming from network?

I am also facing the same problem...but i am able to play small videos...but when i try to play large videos i can only hear the sound but no video is shown...

 

Any hint in this regard..??

Highlighted
New Developer
Posts: 5
Registered: ‎10-28-2009
My Device: Not Specified

Re: How to feed the SourceStream.read() method using the RAW H264 video data streaming from network?

Small videos? Is it also raw frame data without any header? Is it pure video data but changed to audio after feeded the Player?

Share your code fragment with us?

Developer
Posts: 190
Registered: ‎07-08-2009
My Device: Not Specified

Re: How to feed the SourceStream.read() method using the RAW H264 video data streaming from network?

I am using the BufferedPlayBack Demo shipped with JDE..it is pure video data but the media player  is treating it as audio..i can only hear the sound but no display....Smiley Sad

Developer
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: How to feed the SourceStream.read() method using the RAW H264 video data streaming from network?

Hi

I am facing the same issue. I have implemented the RTSP protocol.

My issue is i am able to run the audio and video separately but not togather (Separately means i just stops feeding the audio or video packets to the player). For Video i am adding a header at the start of stream. for audio i am adding an ADTS header with each aac frames.

Any guess what i am doing wrong. or is there anything i have to do play audio/video simultaneously.

 

Thanks

Ankit

 

Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.
New Developer
Posts: 6
Registered: ‎01-04-2010
My Device: Not Specified

Re: How to feed the SourceStream.read() method using the RAW H264 video data streaming from network?

you can use this implementation

http://devblog.blackberry.com/2010/05/streaming-player-api/

 

Thanks

Developer
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: How to feed the SourceStream.read() method using the RAW H264 video data streaming from network?

I have seen that code already , it uses HTTPConnection for streaming, in my case i am implementing the RTSP protocol stack i will receive the audio/ video data as Datagrams.

 

Thanks

Ankit

Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.