videodisplay.c 3.39 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 23
#ifdef HAVE_CONFIG_H
#include "mediastreamer-config.h"
#endif

24 25
#include <signal.h>

aymeric's avatar
aymeric committed
26 27 28 29
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/msvideoout.h"
#include "mediastreamer2/msv4l.h"

30 31 32 33 34 35
static int stopped=FALSE;

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

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

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

aymeric's avatar
aymeric committed
45 46 47 48
	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());
49 50

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

59
        for(n=0;n<60000 && !stopped;++n){
aymeric's avatar
aymeric committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#ifdef WIN32
			MSG msg;
    		Sleep(100);
			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

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

			    vs->tee = ms_filter_new(MS_TEE_ID);

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

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

			  }
			if (n==500)
			  {
			    int corner=1;
96
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
97 98 99 100
			  }
			if (n==600)
			  {
			    int corner=2;
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==700)
			  {
			    int corner=3;
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==800)
			  {
			    int corner=-1;
111
			    ms_filter_call_method(vs->output2,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE,&corner);
aymeric's avatar
aymeric committed
112 113 114 115 116 117
			  }
			if (n==900)
			  {
			    ms_ticker_detach (vs->ticker, vs->source);

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

123
			    ms_filter_link(vs->pixconv,0, vs->output2,0);
aymeric's avatar
aymeric committed
124 125 126 127 128 129 130 131 132

			    
			    ms_ticker_attach (vs->ticker, vs->source);
			  }
		}
		video_preview_stop(vs);
	}
	return 0;
}
133