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: 25
Registered: ‎05-11-2010
My Device: bold 9700
My Carrier: developer

Video Streaming

I am trying to come up with a code that i can start my camera on the phone and stream the video on the server at the same time. the first step is to create a conncetion with server and then transfer my video into bytes and then send it to server. Now before even i could be able to sream video, i have tried to send bytes to server using socket connection and it works fine on simulator, it sends information with 30 sec delay. however when i try it on the device, i am not able to even get connected. if any one has any information in this regard please share it with me as well

BlackBerry Development Advisor
Posts: 15,813
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Video Streaming

Can you elaborate on what is not working?  This sample may help with potential networking issues.

 

Network Diagnostic Tool

http://supportforums.blackberry.com/t5/Java-Development/Network-Diagnostic-Tool/ta-p/445964

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 25
Registered: ‎05-11-2010
My Device: bold 9700
My Carrier: developer

Re: Video Streaming

I am trying one of blackberry's samples and did some changes to it. i have posted the code below. if you read through the code i try to open a connection and i made the display to show me it is opening connection, as soon as connection is maid, it sould display connection open and then i try to write something on the server and the close the conncetion and display done. now when i try this on the simulator it works with about 40sec delay but when i test the application on my bold 9700, it does not even opens connections.

 

package com.rim.samples.device.socketdemo;

import java.io.*;
import javax.microedition.io.*;

import net.rim.device.api.ui.*;

public class ConnectThread extends Thread
{       
    private SocketDemoScreen _screen;
    private OutputStream os;
    
    public ConnectThread()
    {
        _screen = ((SocketDemo)UiApplication.getUiApplication()).getScreen(); 
    }
    
    private void exchange(byte[] data) throws IOException
    {
        os.write(data);
    }

    public void run()
    {        
        StreamConnection sc = null;       
        
        try
        {
            _screen.updateDisplay("Opening Connection...");
            sc = (SocketConnection)Connector.open("socket://192.168.1.113:4530;interface=wifi");
// deviseside=true have been tested as well
 _screen.updateDisplay("Connection open"); os = sc.openOutputStream(); byte[] bt = "comming up".getBytes(); exchange(bt); _screen.updateDisplay("Done!"); } catch(IOException e) { System.err.println(e.toString()); } finally { _screen.setThreadRunning(false); try { os.close(); } catch(IOException ioe) { } try { sc.close(); } catch(IOException ioe) { } } } }

 

 

BlackBerry Development Advisor
Posts: 15,813
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Video Streaming

What line of code is it blocking on?  How long have you waited?  The default timeout for a connection on a BlackBerry Smartphone is 2 minutes.  You'll have to wait that long before you can see any sort of connection refused type of IOException.

 

Note that deviceside=true will fail in this case when run from a real BlackBerry Smartphone because you are trying to open a connection to a non routable (private) IP address.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 25
Registered: ‎05-11-2010
My Device: bold 9700
My Carrier: developer

Re: Video Streaming

it appear that this line of code never gets executed

 

sc = (SocketConnection)Connector.open("socket://192.168.1.113:4530;interface=wifi");

 

because i have update screen right after this line which will display connection open but that never appears on the screen. there are no exepctions and i also let the application to run for 5 min and still nothing is happening. I got to say that this works on the simulator and with a 40 sec delay, it send the information to the server. So i am wondering why this application is not working on the blackberry device and also why it has 40 sec delay to send information to the server from the simulator.

 

Developer
Posts: 114
Registered: ‎04-28-2010
My Device: Storm 9530
My Carrier: Telus

Re: Video Streaming

[ Edited ]

I'm assuming that you are behind a router with the IP address you've just given. The IP Address should be your main IP Address given by your ISP. Are your ports forwarded>?

BlackBerry Development Advisor
Posts: 15,813
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Video Streaming

Is your BlackBerry Smartphone connected to the debugger in Eclipse or the BlackBerry JDE when you are testing?

 

If not, you'll never be able to tell if an IOException was thrown because you are only printing out to the debug console after catching the exception.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 25
Registered: ‎05-11-2010
My Device: bold 9700
My Carrier: developer

Re: Video Streaming

yes my IP address is forwarded. and as i mentioned before, it works on the simulator, i can send bytes to the server but when i test it on the device, it appears that it stops on the line where it should connect to the server. now about the other post rgarding debugger i didnt understand what am i supose to do? Also since it works fine on the simulator, i assumed that there is no bug nad just to know that each step is completed, different msgs appears on the screen. is there something else i should do?

BlackBerry Development Advisor
Posts: 15,813
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Video Streaming

To debug on a real BlackBerry Smartphone connect it to your PC via USB and in Eclipse choose Debug As -> BlackBerry Smartphone.  This will allow you to see the System.err.println statement you have within you catch block.

 

Or you can modify the code so that it prints out the exception to the screen instead of to the debug window.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.