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
Developer
Posts: 41
Registered: ‎04-10-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

hi,

My apllication is workink with diffrent aproach , so the dta is valid ans having AMR header as well, My problem is that i am not able to find  the perfect way to write the data on NoCopyByteArrayOutputStream ,

New Developer
Posts: 24
Registered: ‎07-20-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

Well, in my case I was simply using baos.write()
Developer
Posts: 41
Registered: ‎04-10-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

hi,

Sorry i think u doesn't understatd my problem, i mean to say , i am passing the reference of NoCopyByteArrayOutputStream to diffrent thread, and that thread is writing the data on it ,  and how to block the stream here.

if (bytesToReturn < 1) {
// TODO: Need to block here on the stream until some bytes are available
return 0;
}

 

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

You could always use the standard Java synchronization primitives for that. You create a monitor that is referenced by both the reader and the writer. The writer, every time it wants to write something to the stream, acquires the monitor, writes to the stream, notifies all threads waiting on monitor and then releases the monitor. The reader, every time it wants to read something from the stream, acquires the monitor, goes into loop where it checks if there's anything to read. If there is something to read, it reads as much as it can/wants without blocking, releases the monitor and returns the read data. If there isn't anything to read, it waits for a notification on the monitor (this blocks the reader). Once a notification arrives, the reader goes into the next iteration of the above loop.

 

In the above design, the reader will read data without blocking when there's data available, and, if there's no data available, will block until some data is available. In your case the reader will be the thread the code that provides AMR frames to the system's audio player.

Developer
Posts: 41
Registered: ‎04-10-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

Hi i am geting this wahle debbugging the application .

 

SMPSmiley Frustratedtreaming session aquired id=2056
MN: init0(0)=0
MN: load 0
Starting net_rim_bb_simphonebook
Started net_rim_bb_simphonebook(158)
JVM: bklt @7917: timer
JVM: bklt[1] @7917: idle 0
JVM: bklt @7917: setTimer 22
MN: getPlayableStreams0(0)=1
MN: getLength0(0)=-1
MN: getPlayableStreams0(0)=1
MN: isSeekable0(0)=0
AR: add source 11
AR: setAudioMode 32
MN: play0(0) is audio, NO check for active pause
MN: play0(0)=0
running
EF: 20 SIZE: -1
MN: unload0(0)=2 pauseHandle=7fffffff
AR: remove source 11
AR: setAudioMode 32
MN: MEDIA_STOPPED received
MN: handle=0 staticsHandle=7fffffff
Streaming done reason=1 prev-state=300

 

 

thanks

New Developer
Posts: 24
Registered: ‎07-20-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

Try to debug your code - add a listener to the player for the player status changes, log how many data is the player getting in the read method(better, log everything), try to start the player after caching some amount of data (without streaming) in order to check whether the incoming voice data/player implementation is valid, etc..
New Developer
Posts: 7
Registered: ‎09-08-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

hi marek,

 

in the code u've posted how do tell the stream to only read X bytes and play it back ? And how do modify/add bytes to your baos ? i wanted to have a simple player that woul play a stream ( a stream that i want to update in real time)

 

tkz

New Developer
Posts: 24
Registered: ‎07-20-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

Hi Smuorfy,

as you can see from my code, the baos object is my underlying buffer which is growing (in another thread I'm feeding this buffer with new data, calling baos.write(..). The native Player is basically reading this buffer using the read(PlayerSourceStream.read) method (actually copying it into its own round buffer) and playing the audio.
New Developer
Posts: 21
Registered: ‎09-18-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

Hi Marek_,

 

I am trying to do the same .. realtime streaming using datasource.

But here is the traces that reports failed to start player.

 

 

Source stream READ request :  CuurentPosition0 len: 58000  offset: 0
Source stream READ request :  CuurentPosition6156 len: 51844  offset: 6156
RTPSourceStream getContentLength
RTPSourceStream getSeekType
Source stream READ request :  CuurentPosition6156 len: 51844  offset: 6156
RTPSourceStream getContentLength
SMPSmiley Frustratedtreaming session aquired id=2313
MN: init0(0)=0
MN: load 0
After start play
PLAYERCallback :: Player eventsss : com.rim.loading : EventData null
Source stream READ request :  CuurentPosition6156 len: 51844  offset: 6156
Source stream READ request :  CuurentPosition12306 len: 45694  offset: 12306
MN: getPlayableStreams0(0)=1
MN: getLength0(0)=-1
MN: getPlayableStreams0(0)=1
MN: isSeekable0(0)=0
Source stream READ request :  CuurentPosition12306 len: 45694  offset: 12306
PLAYERCallback :: Player eventsss : com.rim.mediaLoaded : EventData null
PLAYERCallback :: Player eventsss : com.rim.seekableUpdate : EventData false
AR: add source 9
AR: setAudioMode 32
PLAYERCallback :: Player eventsss : com.rim.playableStreams : EventData 1
MN: play0(0) is audio, NO check for active pause
MN: play0(0)=0
MN: MEDIA_STOPPED received
MN: handle=0 staticsHandle=7fffffff
PLAYERCallback :: Player eventsss : started : EventData 0
PLAYERCallback :: Player eventsss : bufferingStopped : EventData 0
PLAYERCallback :: Player eventsss : error : EventData 5
AUDIOMANAGER: IOException
MN: unload0(0)=2 pauseHandle=7fffffff
AR: remove source 9
AR: setAudioMode 32
PLAYERCallback :: Player eventsss : stopped : EventData 0
Streaming done reason=1 prev-state=300

 

 

When no data is available it will go into sleep mode by calling Thread.sleep() , so other thread can get a chance to write into bios.

Can you please tell me what goes wrong ???

 

 

 

 

 

New Developer
Posts: 24
Registered: ‎07-20-2009
My Device: Not Specified

Re: Player custom DataSource streaming without RTSP possible?

Hi jparmar,

please see the klyubin advice for synchronization - please note that you have to create a wait/notify scenario, not Thread.sleep.
if you don't have data available you have to wait and once the other thread receives new data it's duty is feed the buffer and and to call notify.