videodisplay.c 3.47 KB
Newer Older
aymeric's avatar
aymeric committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006  Simon MORLAT (simon.morlat@linphone.org)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

Simon Morlat's avatar
Simon Morlat committed
20

21 22
#include <signal.h>

aymeric's avatar
aymeric committed
23 24 25 26
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/msvideoout.h"
#include "mediastreamer2/msv4l.h"

27 28 29 30 31 32
static int stopped=FALSE;

static void stop(int signum){
	stopped=TRUE;
}

aymeric's avatar
aymeric committed
33 34 35
int main(int argc, char *argv[]){
	VideoStream *vs;
	MSWebCam *cam;
36
	MSVideoSize vsize;
aymeric's avatar
aymeric committed
37
	int i;
38 39 40 41

	vsize.width=MS_VIDEO_SIZE_CIF_W;
	vsize.height=MS_VIDEO_SIZE_CIF_H;

aymeric's avatar
aymeric committed
42 43 44 45
	ortp_init();
	ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
	ms_init();
	cam=ms_web_cam_manager_get_default_cam(ms_web_cam_manager_get());
46
	//cam=ms_web_cam_manager_get_cam(ms_web_cam_manager_get(),"StaticImage: Static picture");
47 48

	signal(SIGINT,stop);
aymeric's avatar
aymeric committed
49 50 51
	/* this is to test the sequence start/stop */
	for(i=0;i<1;++i){
		int n;
Simon Morlat's avatar
Simon Morlat committed
52
		vs=video_preview_new();
53
		/*video_preview_set_display_filter_name(vs,"MSVideoOut");*/
Simon Morlat's avatar
Simon Morlat committed
54 55
		video_preview_set_size(vs,vsize);
		video_preview_start(vs, cam);
aymeric's avatar
aymeric committed
56

57
        for(n=0;n<60000 && !stopped;++n){
aymeric's avatar
aymeric committed
58 59
#ifdef WIN32
			MSG msg;
60
			Sleep(100);
aymeric's avatar
aymeric committed
61 62 63 64 65 66 67 68 69 70 71 72 73
			while (PeekMessage(&msg, NULL, 0, 0,1)){
        			TranslateMessage(&msg);
        			DispatchMessage(&msg);
			}
#else
			struct timespec ts;
			ts.tv_sec=0;
			ts.tv_nsec=10000000;
			nanosleep(&ts,NULL);

			if (vs) video_stream_iterate(vs);
#endif

74
/* test code */
aymeric's avatar
aymeric committed
75 76
			if (n==400)
			  {
77
			    ms_ticker_detach (vs->ms.sessions.ticker, vs->source);
aymeric's avatar
aymeric committed
78 79 80

			    vs->tee = ms_filter_new(MS_TEE_ID);

81
			    ms_filter_unlink(vs->pixconv,0, vs->output2,0);
aymeric's avatar
aymeric committed
82 83

			    ms_filter_link(vs->pixconv,0,vs->tee,0);
84 85
			    ms_filter_link(vs->tee,0,vs->output2,0);
			    ms_filter_link(vs->tee,1,vs->output2,1);
aymeric's avatar
aymeric committed
86 87
			    
			    //ms_filter_unlink(vs->tee,0,vs->output,0);
88
			    ms_ticker_attach (vs->ms.sessions.ticker, vs->source);
aymeric's avatar
aymeric committed
89 90 91 92 93

			  }
			if (n==500)
			  {
			    int corner=1;
94
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
95 96 97 98
			  }
			if (n==600)
			  {
			    int corner=2;
99
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
100 101 102 103
			  }
			if (n==700)
			  {
			    int corner=3;
104
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
105 106 107 108
			  }
			if (n==800)
			  {
			    int corner=-1;
109
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
110 111 112
			  }
			if (n==900)
			  {
113
			    ms_ticker_detach (vs->ms.sessions.ticker, vs->source);
aymeric's avatar
aymeric committed
114 115

			    ms_filter_unlink(vs->pixconv,0,vs->tee,0);
116 117
			    ms_filter_unlink(vs->tee,0,vs->output2,0);
			    ms_filter_unlink(vs->tee,1,vs->output2,1);
aymeric's avatar
aymeric committed
118 119 120
			    ms_filter_destroy(vs->tee);
			    vs->tee=NULL;

121
			    ms_filter_link(vs->pixconv,0, vs->output2,0);
aymeric's avatar
aymeric committed
122 123

			    
124
			    ms_ticker_attach (vs->ms.sessions.ticker, vs->source);
aymeric's avatar
aymeric committed
125 126 127 128 129 130
			  }
		}
		video_preview_stop(vs);
	}
	return 0;
}
131