videodisplay.c 3.66 KB
Newer Older
aymeric's avatar
aymeric committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
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
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
aymeric's avatar
aymeric committed
18 19
*/

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;
37
	MSFactory* factory;
aymeric's avatar
aymeric committed
38
	int i;
39 40 41 42

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

43 44 45
	ortp_init();
	ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
	//ms_init();
46

47 48 49 50
	factory = ms_factory_new();
	ms_factory_init_voip(factory);
	ms_factory_init_plugins(factory);

51
	cam=ms_web_cam_manager_get_cam(ms_factory_get_web_cam_manager(factory),"StaticImage: Static picture");
52
	//cam=ms_web_cam_manager_get_cam(ms_web_cam_manager_get(),"StaticImage: Static picture");
53 54

	signal(SIGINT,stop);
aymeric's avatar
aymeric committed
55 56 57
	/* this is to test the sequence start/stop */
	for(i=0;i<1;++i){
		int n;
Simon Morlat's avatar
Simon Morlat committed
58
		vs=video_preview_new(factory);
59

60
		/*video_preview_set_display_filter_name(vs,"MSVideoOut");*/
Simon Morlat's avatar
Simon Morlat committed
61 62
		video_preview_set_size(vs,vsize);
		video_preview_start(vs, cam);
aymeric's avatar
aymeric committed
63

64
        for(n=0;n<60000 && !stopped;++n){
65
#ifdef _WIN32
aymeric's avatar
aymeric committed
66
			MSG msg;
67
			Sleep(100);
aymeric's avatar
aymeric committed
68 69 70 71 72 73 74 75 76 77 78 79 80
			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

81
/* test code */
aymeric's avatar
aymeric committed
82 83
			if (n==400)
			  {
84
			    ms_ticker_detach (vs->ms.sessions.ticker, vs->source);
aymeric's avatar
aymeric committed
85

86
			    vs->tee = ms_factory_create_filter(factory, MS_TEE_ID);
aymeric's avatar
aymeric committed
87

88
			    ms_filter_unlink(vs->pixconv,0, vs->output2,0);
aymeric's avatar
aymeric committed
89 90

			    ms_filter_link(vs->pixconv,0,vs->tee,0);
91 92
			    ms_filter_link(vs->tee,0,vs->output2,0);
			    ms_filter_link(vs->tee,1,vs->output2,1);
93

aymeric's avatar
aymeric committed
94
			    //ms_filter_unlink(vs->tee,0,vs->output,0);
95
			    ms_ticker_attach (vs->ms.sessions.ticker, vs->source);
aymeric's avatar
aymeric committed
96 97 98 99 100

			  }
			if (n==500)
			  {
			    int corner=1;
101
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
102 103 104 105
			  }
			if (n==600)
			  {
			    int corner=2;
106
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
107 108 109 110
			  }
			if (n==700)
			  {
			    int corner=3;
111
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
112 113 114 115
			  }
			if (n==800)
			  {
			    int corner=-1;
116
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
117 118 119
			  }
			if (n==900)
			  {
120
			    ms_ticker_detach (vs->ms.sessions.ticker, vs->source);
aymeric's avatar
aymeric committed
121 122

			    ms_filter_unlink(vs->pixconv,0,vs->tee,0);
123 124
			    ms_filter_unlink(vs->tee,0,vs->output2,0);
			    ms_filter_unlink(vs->tee,1,vs->output2,1);
aymeric's avatar
aymeric committed
125 126 127
			    ms_filter_destroy(vs->tee);
			    vs->tee=NULL;

128
			    ms_filter_link(vs->pixconv,0, vs->output2,0);
aymeric's avatar
aymeric committed
129

130

131
			    ms_ticker_attach (vs->ms.sessions.ticker, vs->source);
aymeric's avatar
aymeric committed
132 133 134 135 136 137
			  }
		}
		video_preview_stop(vs);
	}
	return 0;
}
138