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
New Developer
sachinhambar
Posts: 14
Registered: ‎12-06-2012
My Device: BB10

H264 encoder callback not getting called

 

Hi 

 

I am accessing H264 encoder through camera service.

 

In my test example, following is the code flow

camera_open(...)

camera_set_videovf_property(...)

camera_set_video_property(....,CAMERA_IMGPROP_VIDEOCODEC, CAMERA_VIDEOCODEC_H264)

camera_start_video_viewfinder(....)

camera_start_encode(..,enc_video_callback)

 

But encoded callback i.e. enc_video_callback is not getting called. In what circumstances, enc_video_callback will not get called?

 

Thanks,

Sachin Hambar

 

New Developer
sachinhambar
Posts: 14
Registered: ‎12-06-2012
My Device: BB10

Re: H264 encoder callback not getting called

Addition Information:

 

To see the status of the functions, I added status_callback for 

camera_start_video_viewfinder and camera_start_encode. 

I am getting following status

1. CAMERA_STATUS_VIDEOVF  for camera_start_video_viewfinder

2. CAMERA_STATUS_VIDEO_RESUME for both camera_start_video_viewfinder and camera_start_encode.

 

I am configuring following parameters for H264 encoder.

CAMERA_IMGPROP_WIDTH : 480
CAMERA_IMGPROP_HEIGHT : 640
CAMERA_IMGPROP_FRAMERATE : 30 fps
CAMERA_IMGPROP_BITRATE : 400000 bits/sec

 

I dont have any clue to proceed further and stuck now. 

 

Does BB10 has system logging? How can I see the system logs for the issue mentioned above.

 

 

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: H264 encoder callback not getting called

did you set video viewfinder to the same resolution as the video output?  (480x640)

have you checked the error codes returned by all of the camera_() functions?

can you try with a higher bitrate?  I've been testing this stuff recently, so I know it works.

 

there is indeed system-level logging for most of this, but it is inaccessible to non-root users.

New Developer
sachinhambar
Posts: 14
Registered: ‎12-06-2012
My Device: BB10

Re: H264 encoder callback not getting called

1. Yes I set the video resolution same for camera_set_videovf_property and camera_set_video_property.

2. None of camera API calls return error. All APIs return success.

3. Yes I will try higher bitrate.

 

Can you please elaborate more on system logging?  What do mean by "inaccessible to non-root users".

Is there any way to view the log the IDE?

 

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: H264 encoder callback not getting called


sachinhambar wrote:

Can you please elaborate more on system logging?  What do mean by "inaccessible to non-root users".

Is there any way to view the log the IDE?


There is no way for you to view the internal system logs.

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: H264 encoder callback not getting called

Also, back to your problem... please try downloading the HelloVideoCamera sample from github:

https://github.com/blackberry/Cascades-Community-Samples/tree/master/HelloVideoCamera

 

Then just replace the call to camera_start_video() with camera_start_encode() instead.  Likewise: camera_stop_video() -> camera_stop_encode().

 

Also, be sure your callback functions are static if they are C++ class members.

 

Cheers,

Sean

New Developer
sachinhambar
Posts: 14
Registered: ‎12-06-2012
My Device: BB10

Re: H264 encoder callback not getting called

I got the reason for callback not gettig called. It is related to thread priority assigned in our code. In our code, all thread priority are set to high

 

const int maxPrio = sched_get_priority_max(policy);
// Set same priority for all threads
param.sched_priority = maxPrio - 1;
error_code = pthread_setschedparam(thread_, policy, &param);

 

It seems the encoder thread has lower priority so the callback is not getting called. Once I removed the thread priorities, callback got called.

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: H264 encoder callback not getting called

yes, please don't try to use maximum priority.

there are a number of system services and interrupt handlers, etc. which could get starved out if your threads are poorly behaved.

I would suggest working in a small relative range from your starting priority.

we only typically set priorities to current priority, or current+1 relative to the parent thread.