Commit 3f6b1f18 authored by Simon Morlat's avatar Simon Morlat

fixes and optimisations

parent 1707c71a
......@@ -346,12 +346,23 @@ MS2_PUBLIC int ms_filter_call_method(MSFilter *f, unsigned int id, void *arg);
* Call a filter's method to set options.
* @param f A MSFilter object.
* @param id A private filter ID for the option.
* @param id A method ID.
* Returns: 0 if successfull, -1 otherwise.
MS2_PUBLIC int ms_filter_call_method_noarg(MSFilter *f, unsigned int id);
* Returns whether the filter implements a given method
* @param f A MSFilter object.
* @param id A method ID.
* Returns: 0 if successfull, -1 otherwise.
MS2_PUBLIC bool_t ms_filter_has_method(MSFilter *f, unsigned int id);
* Set a callback on filter's to be informed of private filter's event.
* This callback is called from the filter's MSTicker, unless a global event queue
......@@ -211,6 +211,14 @@ int ms_filter_call_method(MSFilter *f, unsigned int id, void *arg){
return -1;
bool_t ms_filter_has_method(MSFilter *f, unsigned int id){
MSFilterMethod *methods=f->desc->methods;
int i;
for(i=0;methods!=NULL && methods[i].method!=NULL; i++)
if (methods[i].id==id) return TRUE;
return FALSE;
int ms_filter_call_method_noarg(MSFilter *f, unsigned int id){
return ms_filter_call_method(f,id,NULL);
......@@ -492,6 +492,8 @@ void video_stream_update_video_params(VideoStream *stream){
void video_stream_change_camera(VideoStream *stream, MSWebCam *cam){
bool_t keep_source=(cam==stream->cam);
if (stream->ticker && stream->source){
/*unlink source filters and subsequent post processin filters */
......@@ -499,12 +501,12 @@ void video_stream_change_camera(VideoStream *stream, MSWebCam *cam){
ms_filter_unlink (stream->pixconv, 0, stream->sizeconv, 0);
ms_filter_unlink (stream->sizeconv, 0, stream->tee, 0);
/*destroy the filters */
if (!keep_source) ms_filter_destroy(stream->source);
/*re create new ones and configure them*/
stream->source = ms_web_cam_create_reader(cam);
if (!keep_source) stream->source = ms_web_cam_create_reader(cam);
......@@ -597,13 +599,13 @@ void video_stream_set_native_preview_window_id(VideoStream *stream, unsigned lon
unsigned long video_stream_get_native_preview_window_id(VideoStream *stream){
unsigned long id=0;
#if TARGET_OS_IPHONE==1 && !defined(ANDROID)
MSFilter* target_filter=stream->output2;
MSFilter* target_filter=stream->source;/*preview is managed at the src filter level*/
if (target_filter){
if (ms_filter_call_method(target_filter,MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID,&id)==0)
if (stream->output2){
if (ms_filter_call_method(stream->output2,MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID,&id)==0)
return id;
if (stream->source){
if (ms_filter_has_method(stream->source,MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID)
&& ms_filter_call_method(stream->source,MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID,&id)==0)
return id;
return stream->preview_window_id;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment