incubator-bluesky-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r819898 [3/5] - in /incubator/bluesky/trunk/RealClass/Student-1.0: ./ src/ src/pic/
Date Tue, 29 Sep 2009 12:17:19 GMT
Added: incubator/bluesky/trunk/RealClass/Student-1.0/src/en_de_video.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Student-1.0/src/en_de_video.cpp?rev=819898&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Student-1.0/src/en_de_video.cpp (added)
+++ incubator/bluesky/trunk/RealClass/Student-1.0/src/en_de_video.cpp Tue Sep 29 12:17:17 2009
@@ -0,0 +1,2099 @@
+
+static char *primary_version = "";
+static char *video_version_ = "1.0";
+
+//V4l classes.
+#include <deque>
+#include <unistd.h>
+#include <string>
+#include <sstream>
+#include <iostream>
+#include <iomanip>
+
+#include <pthread.h>
+
+#include <gtk/gtk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "en_de_video.h"
+
+extern int v4l_dev_num = 0;
+extern int delay_time = 0;
+
+extern "C"
+{
+#include <sys/types.h>
+#include <sys/soundcard.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+}
+
+static int ENCODE_YUV = 0;
+
+/** Send a request to the v4l device associated to a V4LStruct object.
+ */
+
+bool V4LDevice::request(int req, V4LStruct *v4l)
+{
+	ENCODE_YUV = getenv("KINO_V4L_PATCHED") != NULL;
+	return request(req, v4l->getStruct());
+}
+
+/** Send a request to the v4l device associated to an arbitrary address.
+ */
+
+bool V4LDevice::request(int req, void *addr)
+{
+	return ioctl(getHandle(), req, addr) != -1;
+}
+
+V4LCapability::V4LCapability(V4LDevice *device)
+{
+	device->request(VIDIOCGCAP, this);
+}
+
+V4LCapability::~V4LCapability()
+{
+}
+
+void *V4LCapability::getStruct()
+{
+	return &capability;
+}
+
+char *V4LCapability::getName()
+{
+	return capability.name;
+}
+
+int V4LCapability::getNumberOfChannels()
+{
+	return capability.channels;
+}
+
+int V4LCapability::getNumberOfAudioDevices()
+{
+	return capability.audios;
+}
+
+int V4LCapability::getMinWidth()
+{
+	return capability.minwidth;
+}
+
+int V4LCapability::getMinHeight()
+{
+	return capability.minheight;
+}
+
+int V4LCapability::getMaxWidth()
+{
+	return capability.maxwidth;
+}
+
+int V4LCapability::getMaxHeight()
+{
+	return capability.maxheight;
+}
+
+bool V4LCapability::canCapture()
+{
+	return capability.type & VID_TYPE_CAPTURE;
+}
+
+bool V4LCapability::hasTuner()
+{
+	return capability.type & VID_TYPE_TUNER;
+}
+
+bool V4LCapability::hasChromakey()
+{
+	return capability.type & VID_TYPE_CHROMAKEY;
+}
+
+bool V4LCapability::hasClipping()
+{
+	return capability.type & VID_TYPE_CLIPPING;
+}
+
+bool V4LCapability::hasOverwrite()
+{
+	return capability.type & VID_TYPE_FRAMERAM;
+}
+
+bool V4LCapability::hasScaling()
+{
+	return capability.type & VID_TYPE_SCALES;
+}
+
+bool V4LCapability::isMonochrome()
+{
+	return capability.type & VID_TYPE_MONOCHROME;
+}
+
+bool V4LCapability::canSubCapture()
+{
+	return capability.type & VID_TYPE_SUBCAPTURE;
+}
+
+void V4LCapability::report()
+{
+
+}
+
+V4LTuner::V4LTuner(V4LDevice *device, int index)
+{
+	this->device = device;
+	this->tuner.tuner = index;
+	this->device->request(VIDIOCGTUNER, this);
+}
+
+void *V4LTuner::getStruct()
+{
+	return &tuner;
+}
+
+void V4LTuner::report()
+{
+}
+
+int V4LTuner::getRangeLow()
+{
+	return tuner.rangelow;
+}
+
+void V4LTuner::setRangeLow(int low)
+{
+	tuner.rangelow = low;
+}
+
+int V4LTuner::getRangeHigh()
+{
+	return tuner.rangehigh;
+}
+
+void V4LTuner::setRangeHigh(int high)
+{
+	tuner.rangehigh = high;
+}
+
+int V4LTuner::getFlags()
+{
+	return tuner.flags;
+}
+
+void V4LTuner::setFlags(int flags)
+{
+	tuner.flags = flags;
+}
+
+int V4LTuner::getMode()
+{
+	return tuner.mode;
+}
+
+void V4LTuner::setMode(int mode)
+{
+	tuner.mode = mode;
+}
+
+int V4LTuner::getSignal()
+{
+	return tuner.signal;
+}
+
+V4LChannel::V4LChannel(V4LDevice *device, int index)
+{
+	memset(&channel, 0, sizeof(struct video_channel));
+	this->device = device;
+	this->channel.channel = index;
+	device->request(VIDIOCGCHAN, this);
+	device->request(VIDIOCSCHAN, this);
+	for (unsigned int i = 0; i < getNumberOfTuners(); i++)
+	{
+		V4LTuner *tuner = new V4LTuner(this->device, i);
+		tuners.insert(tuners.end(), tuner);
+	}
+}
+
+V4LChannel::~V4LChannel()
+{
+}
+
+void *V4LChannel::getStruct()
+{
+	return &channel;
+}
+
+char *V4LChannel::getName()
+{
+	return channel.name;
+}
+
+bool V4LChannel::setTuner(unsigned int index)
+{
+	if (index >= 0 && index < tuners.size())
+	{
+		current = tuners[index];
+		current->setRangeLow(0);
+		current->setRangeHigh(0xffff);
+		return device->request(VIDIOCSTUNER, current);
+	}
+	else
+	{
+		return false;
+	}
+}
+
+unsigned int V4LChannel::getNumberOfTuners()
+{
+	return channel.tuners;
+}
+
+V4LTuner *V4LChannel::getTuner(unsigned int index)
+{
+	if (index >= 0 && index < tuners.size())
+	{
+		return tuners[index];
+	}
+	else
+	{
+		return NULL;
+	}
+}
+
+int V4LChannel::getSignal()
+{
+	device->request(VIDIOCGTUNER, current);
+	return current->getSignal();
+}
+
+void V4LChannel::report()
+{
+	
+}
+
+/** Constructor for the V4L class.*/
+
+V4L::V4L()
+{
+
+}
+
+void V4L::setInfo(char *device, char *input, char *audio, int sample)
+{
+	this->device = device;
+	this->input = input;
+	this->audio = audio;
+	this->sample = sample;
+}
+
+bool V4L::openDevice()
+{
+	bool ret = true;
+
+	if (!strcmp(this->input, "PAL"))
+	{
+		this->width = VideoWidth;
+		this->height = VideoHeight;
+		this->fps = 25;
+		this->frameSample = this->sample / this->fps;
+	}
+	else if (!strcmp(this->input, "NTSC"))
+	{
+		this->width = 720;
+		this->height = 480;
+		this->fps = 30;
+		this->frameSample = this->sample / this->fps;
+	}
+
+	this->current = NULL;
+	this->fd = open(device, O_RDWR);
+	if (fd == -1)
+	{
+		perror("Unable to open video device");
+		return false;
+	}
+
+	{
+		video_capability capability;
+		if (ioctl(fd, VIDIOCGCAP, &capability) != -1)
+		{
+			printf(" query was successful\n");
+		}
+		else
+		{
+			perror("query");
+		}
+
+		if ((capability.type & VID_TYPE_CAPTURE) != 0)
+		{
+			printf("this device can capture video to memory\n");
+		}
+		else
+		{
+			perror("can't capture video to memtory");
+		}
+
+		struct video_channel queryChannel;
+		int i = 0;
+		while (i < capability.channels)
+		{
+			queryChannel.channel = i;
+			if (ioctl(fd, VIDIOCGCHAN, &queryChannel) != -1)
+			{ // ioctl success, queryChannel contains information about this channel
+				printf(" information about this channel:%d, %s\n",
+						queryChannel.channel, queryChannel.name);
+			}
+			
+			++i;
+		}
+
+		struct video_channel selectedChannel;
+		selectedChannel.channel = 0;
+		selectedChannel.norm = VIDEO_MODE_PAL;
+		if (ioctl(fd, VIDIOCSCHAN, &selectedChannel) == -1)
+		{
+			return false;
+		}
+
+		struct video_window captureWindow;
+		memset(&captureWindow, 0, sizeof(captureWindow));
+		captureWindow.width = VideoWidth;
+		captureWindow.height = VideoHeight;
+		
+		memset(&captureWindow, 0, sizeof(captureWindow));
+		if (ioctl(fd, VIDIOCGWIN, &captureWindow) == -1)
+		{
+			return false;
+		}
+
+		width = captureWindow.width;
+		height = captureWindow.height;
+		printf("width=%d,height=%d\n", width, height);
+
+	}
+
+	int depth;
+	int palette;
+	struct video_picture imageProperties;
+
+	if (ioctl(fd, VIDIOCGPICT, &imageProperties) == -1)
+	{ // failed to retrieve default image properties
+		return false;
+	}
+	depth = imageProperties.depth;
+	palette = imageProperties.palette;
+	printf("\nVideo:depth=%d,palette=%d\n", depth, palette);
+	if (ioctl(fd, VIDIOCSPICT, &imageProperties) == -1)
+	{ // failed to retrieve default image properties
+		return false;
+	}
+
+	return ret;
+}
+
+/** Destructor for the V4L device.*/
+
+V4L::~V4L()
+{
+	if (fd != -1)
+	{
+		close( fd);
+		for (unsigned int index = 0; index < channels.size(); index++)
+			delete channels[index];
+		delete this->capability;
+	}
+}
+
+
+
+bool V4L::deviceAvailable()
+{
+	return fd != -1;
+}
+
+
+int V4L::getHandle()
+{
+	return fd;
+}
+
+
+bool V4L::setChannel(unsigned int channel)
+{
+	if (channel >= 0 && channel < channels.size())
+	{
+		current = channels[channel];
+		return this->request(VIDIOCSCHAN, current);
+	}
+	else
+	{
+		return false;
+	}
+}
+
+unsigned int V4L::getNumberOfChannels()
+{
+	return channels.size();
+}
+
+V4LChannel *V4L::getChannel(unsigned int channel)
+{
+	if (channel >= 0 && channel < channels.size())
+		return channels[channel];
+	else
+		return NULL;
+}
+
+bool V4L::setTuner(unsigned int tuner)
+{
+	if (current != NULL)
+		return current->setTuner(tuner);
+	else
+		return false;
+}
+
+unsigned int V4L::getNumberOfTuners()
+{
+	if (current != NULL)
+		return current->getNumberOfTuners();
+	else
+		return 0;
+}
+
+
+V4LTuner *V4L::getTuner(unsigned int tuner)
+{
+	if (current != NULL)
+		return current->getTuner(tuner);
+	else
+		return NULL;
+}
+
+
+bool V4L::setCaptureResolution(int width, int height)
+{
+	if (width > capability->getMaxWidth() || width < capability->getMinWidth())
+		return false;
+	if (height > capability->getMaxHeight() || height
+			< capability->getMinHeight())
+		return false;
+	if (!capability->hasScaling() && (width != capability->getMaxWidth()
+			|| height != capability->getMaxHeight()))
+		return false;
+	this->width = width;
+	this->height = height;
+	return true;
+}
+
+int V4L::getWidth()
+{
+	return width;
+}
+
+int V4L::getHeight()
+{
+	return height;
+}
+
+void V4L::startAudio()
+{
+	struct video_audio audio;
+	ioctl(fd, VIDIOCGAUDIO, &audio);
+	if (audio.flags & VIDEO_AUDIO_MUTE)
+		audio.flags ^= VIDEO_AUDIO_MUTE;
+	audio.volume = 65535;
+	ioctl(fd, VIDIOCSAUDIO, &audio);
+}
+
+void V4L::stopAudio()
+{
+	struct video_audio audio;
+	ioctl(fd, VIDIOCGAUDIO, &audio);
+	audio.flags |= VIDEO_AUDIO_MUTE;
+	audio.volume = 0;
+	ioctl(fd, VIDIOCSAUDIO, &audio);
+}
+
+int V4L::mappedMemorySize(bool init)
+{
+	static video_mbuf buf;
+	if (init == true)
+	{
+		init = 1;
+		ioctl(fd, VIDIOCGMBUF, &buf);
+		frame_maps = buf.frames;
+	}
+	return buf.size;
+}
+
+bool V4L::initialiseCapture(int format)
+{
+	size = width * height * 4;
+
+	map = mmap(0, mappedMemorySize(true), PROT_READ | PROT_WRITE, MAP_SHARED,
+			fd, 0);
+
+	if (map != NULL)
+	{
+		for (int i = 0; i < frame_maps; i++)
+		{
+			frame[i].frame = i;
+			frame[i].width = getWidth();
+			frame[i].height = getHeight();
+			frame[i].format = format;
+		}
+
+		struct timeval tv;
+		gettimeofday(&tv, NULL);
+		starttime = tv.tv_sec * 1000000 + tv.tv_usec;
+		frames = 0;
+		frame_next = 0;
+
+		int retry = 0;
+		while (ioctl(fd, VIDIOCMCAPTURE, &frame[0]) == -1 && retry++
+				< frame_maps + 1)
+			;
+
+		return true;
+	}
+	else
+	{
+		return false;
+	}
+}
+void *V4L::getNextFrame()
+{
+	unsigned char * ret = NULL;
+
+	int current = frame_next;
+	frame_next = (frame_next + 1) % frame_maps;
+
+	if (ioctl(fd, VIDIOCMCAPTURE, &frame[frame_next]) == -1)
+		; //cout << "Frame 1 Failed to initialise" << endl;
+	if (ioctl(fd, VIDIOCSYNC, &frame[current].frame) == -1)
+		; //cout << "Frame 0 Failed to sync" << endl;
+	ret = (unsigned char *) map + current * (mappedMemorySize() / frame_maps);
+
+	frames++;
+
+	return (void *) ret;
+}
+
+void V4L::stopCapture()
+{
+	if (map != NULL)
+	{
+		struct timeval tv;
+		gettimeofday(&tv, NULL);
+		long long endtime = tv.tv_sec * 1000000 + tv.tv_usec;
+		double fps = (frames) / (((double) (endtime - starttime)) / 1000000);
+		munmap(map, mappedMemorySize());
+		map = NULL;
+		int enable = 0;
+		ioctl(getHandle(), VIDIOCCAPTURE, &enable);
+	}
+}
+
+int V4L::getFrequency()
+{
+	unsigned long current;
+	ioctl(fd, VIDIOCGFREQ, &current);
+	return (int) current;
+}
+
+/** Set the current frequency of the tuner.
+ 
+ \param	frequency	frequency to set
+ \return	the current tuned in frequency.
+ */
+
+bool V4L::setFrequency(int frequency)
+{
+	unsigned long val = (unsigned long) frequency & 0xffff;
+	return ioctl(fd, VIDIOCSFREQ, &val) != -1;
+}
+
+/** Get the signal of the current tuned in frequency.
+ */
+
+int V4L::getSignal()
+{
+	return current->getSignal();
+}
+
+void V4L::report()
+{
+	capability->report();
+
+	for (unsigned int index = 0; index < channels.size(); index++)
+	{
+		channels[index] ->report();
+	}
+}
+
+//V4l classes.
+
+
+extern void PErrorText(const char* error);
+
+int CVDecoder::input_pixfmt = PIX_FMT_RGBA32;
+
+#define STARTTIME { static int MaxTime=0;                         \
+	                static int MinTime=1000;                      \
+	                static int largecount=0;                      \
+	                int IntervalTime=0;                           \
+	                int64_t start_time=av_gettime();
+
+#define ENDTIME     IntervalTime = av_gettime()-start_time;       \
+	                if(IntervalTime>40000)                         \
+	                    largecount++;                             \
+	                if(MaxTime<IntervalTime)                      \
+	                    MaxTime=IntervalTime;                     \
+	                if(MinTime>IntervalTime)                      \
+	                    MinTime=IntervalTime;                     \
+	                printf("\nMaxTime=%d, MinTime=%d, largecount=%d, IntervalTime=%d\n", MaxTime, MinTime, largecount, IntervalTime);}
+
+//CVDecoder class.
+
+CVDecoder::CVDecoder()
+{
+	m_pCodec = 0;
+	m_pCodecCtx = 0;
+	m_pOutFrame = 0;
+	m_bInit = false;
+
+	m_display = 0;
+	m_win = 0;
+	m_image = 0;
+
+}
+
+CVDecoder::~CVDecoder()
+{
+	m_bInit = false;
+
+	if (m_pOutFrame)
+	{
+		free( m_pOutFrame);
+		m_pOutFrame = 0;
+	}
+	if (m_pCodecCtx)
+	{
+		if (m_pCodecCtx->extradata)
+		{
+			free(m_pCodecCtx->extradata);
+			m_pCodecCtx->extradata = 0;
+			m_pCodecCtx->extradata_size = 0;
+		}
+		avcodec_close( m_pCodecCtx);
+		m_pCodecCtx = 0;
+	}
+
+	if (m_image)
+	{
+		XDestroyImage( m_image);
+		//m_image->f.destroy_image(m_image);
+		m_image = 0;
+	}
+
+	if (m_display)
+	{
+		if (m_win)
+		{
+			XClearWindow(m_display, m_win);
+			m_win = 0;
+		}
+		if (m_d)
+		{
+			XClearWindow(m_display, m_d);
+			m_d = 0;
+		}
+
+		XCloseDisplay( m_display);
+		m_display = 0;
+	}
+
+}
+
+void CVDecoder::GetColorInfo(XImage *image, ColorInfo *ci /* return struct */)
+{
+	unsigned long red_mask, green_mask, blue_mask, alpha_mask;
+	// the shifts are unsigned longs as well
+
+	if (!ci)
+		return;
+
+	// setting shifts and bit_depths to zero
+	ci->red_shift = ci->green_shift = ci->blue_shift = ci->alpha_shift = 0;
+	ci->red_bit_depth = ci->green_bit_depth = ci->blue_bit_depth
+			= ci->alpha_bit_depth = 0;
+
+	red_mask = image->red_mask;
+	if (red_mask > 0)
+	{
+		// shift red_mask to the right till all empty bits have been
+		// shifted out and count how many they were
+		while ((red_mask & 0x01) == 0)
+		{
+			red_mask >>= 1;
+			ci->red_shift++;
+		}
+		// count how many bits are set in the mask = depth
+		while ((red_mask & 0x01) == 1)
+		{
+			red_mask >>= 1;
+			ci->red_bit_depth++;
+		}
+	}
+
+	ci->red_max_val = (1 << ci->red_bit_depth) - 1;
+
+	green_mask = image->green_mask;
+	if (green_mask > 0)
+	{
+		while ((green_mask & 0x01) == 0)
+		{
+			green_mask >>= 1;
+			ci->green_shift++;
+		}
+		while ((green_mask & 0x01) == 1)
+		{
+			green_mask >>= 1;
+			ci->green_bit_depth++;
+		}
+	}
+	ci->green_max_val = (1 << ci->green_bit_depth) - 1;
+
+	blue_mask = image->blue_mask;
+	if (blue_mask > 0)
+	{
+		while ((blue_mask & 0x01) == 0)
+		{
+			blue_mask >>= 1;
+			ci->blue_shift++;
+		}
+		while ((blue_mask & 0x01) == 1)
+		{
+			blue_mask >>= 1;
+			ci->blue_bit_depth++;
+		}
+	}
+	ci->blue_max_val = (1 << ci->blue_bit_depth) - 1;
+
+	/* over all max values */
+	// whatever they are good for
+	ci->max_val = max(ci->red_max_val, ci->green_max_val);
+	ci->max_val = max(ci->blue_max_val, ci->max_val);
+	ci->bit_depth = max(ci->red_bit_depth, ci->green_bit_depth);
+	ci->bit_depth = max(ci->blue_bit_depth, ci->bit_depth);
+	if (image->bits_per_pixel > image->depth)
+	{
+		/* alpha? */
+		// this seems to not reflect X's ignorance of alpha in its
+		// masks
+		ci->alpha_mask = ~(image->red_mask | image->blue_mask
+				| image->green_mask);
+		alpha_mask = ci->alpha_mask;
+		if (alpha_mask > 0)
+		{
+			while ((alpha_mask & 0x01) == 0)
+			{
+				alpha_mask >>= 1;
+				ci->alpha_shift++;
+			}
+			while ((alpha_mask & 0x01) == 1)
+			{
+				alpha_mask >>= 1;
+				ci->alpha_bit_depth++;
+			}
+		}
+		ci->alpha_max_val = (1 << ci->alpha_bit_depth) - 1;
+	}
+}
+
+bool CVDecoder::CreateXImage(Drawable parent, int x, int y, int width,
+		int height)
+{
+	int screen_num;
+
+	GdkPixbuf *original_pixbuf;
+
+	gint original_width, original_height;
+	GdkColorspace original_color;
+	gboolean original_alpha;
+	gboolean pixbuf_has_alpha;
+	XSetWindowAttributes win_attr;
+	XImage *p_image = NULL;
+	if (!m_bInit)
+		return false;
+
+	CloseXImage();
+
+	m_imagemutex.Lock();
+
+	m_display = XOpenDisplay(NULL);
+	screen_num = DefaultScreen(m_display);
+	m_gc = DefaultGC(m_display, screen_num);
+	m_d = RootWindow(m_display, screen_num);
+
+	m_win = XCreateWindow(m_display, parent, x, y, width, height, 1,
+			XDefaultDepth(m_display, screen_num), InputOutput, CopyFromParent,
+			0, &win_attr);
+
+	if (gdk_pixbuf_new_from_file("pic/teacher2.bmp", NULL) == NULL)
+	{
+		XSetWindowBackgroundPixmap(m_display, m_win, ParentRelative);
+		XMapWindow(m_display, m_win);
+	}
+
+	else
+	{
+		original_pixbuf = gdk_pixbuf_new_from_file("pic/teacher2.bmp", NULL);
+		pixbuf_has_alpha = gdk_pixbuf_get_has_alpha(original_pixbuf);
+		original_color = gdk_pixbuf_get_colorspace(original_pixbuf);
+		original_alpha = gdk_pixbuf_get_has_alpha(original_pixbuf);
+		original_width = gdk_pixbuf_get_width(original_pixbuf);
+		original_height = gdk_pixbuf_get_height(original_pixbuf);
+		printf("original_alpha = %d\n", original_alpha);
+		printf("original_color = %d\n", original_color);
+		printf("original_width = %d\n", original_width);
+		printf("original_height = %d\n", original_height);
+		printf("n_channles = %d\n", gdk_pixbuf_get_n_channels(original_pixbuf));
+
+		Pixmap pixmap = XCreatePixmap(m_display, m_win, original_width,
+				original_height, XDefaultDepth(m_display, screen_num));
+		XSetWindowBackgroundPixmap(m_display, m_win, pixmap);
+
+		p_image = XGetImage(m_display, m_d, 0, 0, original_width,
+				original_height, AllPlanes, ZPixmap);
+		if (!p_image)
+		{
+			printf("error\n");
+			exit(10);
+		}
+
+		AVPicture pic_rgb24, pic_rgb32;
+		if (m_display && p_image && pixmap)
+		{
+			avpicture_fill(&pic_rgb32, (uint8_t*) p_image->data,
+					PIX_FMT_RGBA32, original_width, original_height);
+			avpicture_fill(&pic_rgb24, gdk_pixbuf_get_pixels(original_pixbuf),
+					PIX_FMT_RGB24, original_width, original_height);
+
+			if (img_convert(&pic_rgb32, PIX_FMT_RGBA32, &pic_rgb24,
+					PIX_FMT_RGB24, original_width, original_height) < 0)
+			{
+				printf("Error pixel format conversion");
+				return -1;
+			}
+
+			XPutImage(m_display, pixmap, m_gc, p_image, 0, 0, 0, 0,
+					original_width, original_height);
+
+		}
+
+		XMapWindow(m_display, m_win);
+		XFreePixmap(m_display, pixmap);
+		gdk_pixbuf_unref(original_pixbuf);
+		XDestroyImage(p_image);
+	}
+
+	m_image = XGetImage(m_display, m_d, 0, 0, m_width, m_height, AllPlanes,
+			ZPixmap);
+
+	if (!m_image)
+	{
+		printf("XGetImage error\n");
+		m_imagemutex.Unlock();
+		return false;
+	}
+
+	m_imagemutex.Unlock();
+	return true;
+}
+
+void CVDecoder::CloseXImage()
+{
+	if (!m_bInit)
+		return;
+
+	m_imagemutex.Lock();
+
+	if (m_image)
+	{
+		XDestroyImage( m_image);
+		m_image = 0;
+	}
+
+	if (m_display)
+	{
+		if (m_win)
+		{
+			XUnmapWindow(m_display, m_win);
+			XClearWindow(m_display, m_win);
+			m_win = 0;
+		}
+
+		if (m_d)
+		{
+			XClearWindow(m_display, m_d);
+			m_d = 0;
+		}
+
+		XCloseDisplay( m_display);
+		m_display = 0;
+	}
+
+	m_imagemutex.Unlock();
+	return;
+}
+
+bool CVDecoder::Init(int width, int height, enum CodecID nCodecID)
+{
+	if (m_bInit)
+		return true;
+
+	avcodec_init();
+	avcodec_register_all();
+
+	if (!m_imagemutex.IsInitialized())
+	{
+		if (m_imagemutex.Init() < 0)
+			return false;
+	}
+
+	m_width = width;
+	m_height = height;
+
+	// find the video decoder
+	m_pCodec = avcodec_find_decoder(nCodecID);
+	if (!m_pCodec)
+	{
+		PErrorText("Codec not found\n");
+		return false;
+	}
+
+	if (m_pOutFrame)
+	{
+		free( m_pOutFrame);
+		m_pOutFrame = 0;
+	}
+	m_pOutFrame = avcodec_alloc_frame();
+
+	if (m_pCodecCtx)
+	{
+		if (m_pCodecCtx->extradata)
+		{
+			free(m_pCodecCtx->extradata);
+			m_pCodecCtx->extradata = 0;
+			m_pCodecCtx->extradata_size = 0;
+		}
+		avcodec_close( m_pCodecCtx);
+		m_pCodecCtx = 0;
+	}
+	m_pCodecCtx = avcodec_alloc_context();
+	m_pCodecCtx->extradata = 0;
+	m_pCodecCtx->extradata_size = 0;
+
+	// put sample parameters
+	m_pCodecCtx->bit_rate = 512 * 1024;
+	// resolution must be a multiple of two 
+	m_pCodecCtx->width = m_width;
+	m_pCodecCtx->height = m_height;
+	// frames per second
+	m_pCodecCtx->frame_rate = V_CODEC_framerate;
+	m_pCodecCtx->frame_rate_base = V_CODEC_frame_rate_base;
+	// emit one intra frame every ten frames
+	m_pCodecCtx->gop_size = V_CODEC_gop_size;
+
+	m_pCodecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
+	m_pCodecCtx->extradata = malloc(V_De_ExtraHeaderSize);
+	if (m_pCodecCtx->extradata == 0)
+	{
+		return false;
+	}
+	m_pCodecCtx->extradata_size = V_De_ExtraHeaderSize;
+
+	// we dont send complete frames
+	if (m_pCodec->capabilities & CODEC_CAP_TRUNCATED)
+		m_pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+
+	// open it
+	if (avcodec_open(m_pCodecCtx, m_pCodec) < 0)
+	{
+		PErrorText("could not open codec");
+		return false;
+	}
+
+	m_bInit = true;
+	return true;
+}
+
+int CVDecoder::DecodeProcess(uint8_t *encodeddata_v,
+		const int encodeddatasize_v)
+{
+	bool isPaintPic;
+	int realsize, i;
+	int got_picture;
+
+	if (!m_bInit)
+	{
+		return -1;
+	}
+
+	int left = 0;
+	int len;
+
+	m_imagemutex.Lock();
+
+	for (i = 0;; i++)
+	{
+		if (encodeddatasize_v - i * V_De_INBUF_SIZE >= V_De_INBUF_SIZE)
+			realsize = V_De_INBUF_SIZE;
+		else
+			realsize = encodeddatasize_v - i * V_De_INBUF_SIZE;
+
+		if (realsize <= 0)
+			break;
+
+		left = 0;
+		isPaintPic = false;
+		while (realsize > 0)
+		{
+
+			m_pCodecCtx->width = m_width;
+			m_pCodecCtx->height = m_height;
+
+			len = avcodec_decode_video(m_pCodecCtx, m_pOutFrame, &got_picture,
+					(encodeddata_v + i * V_De_INBUF_SIZE + left), realsize);
+			if (len < 0)
+			{
+				PErrorText("Error while decoding");
+				m_imagemutex.Unlock();
+				return -2;
+			}
+
+			if (m_image != 0)
+			{
+				GetColorInfo(m_image, &c_info);
+				switch (m_image->bits_per_pixel)
+				{
+				case 8:
+					input_pixfmt = PIX_FMT_PAL8;
+					break;
+				case 16:
+					if (m_image->red_mask == 0xF800 && m_image->green_mask
+							== 0x07E0 && m_image->blue_mask == 0x1F)
+					{
+						input_pixfmt = PIX_FMT_RGB565;
+					}
+					else if (m_image->red_mask == 0x7C00 && m_image->green_mask
+							== 0x03E0 && m_image->blue_mask == 0x1F)
+					{
+						input_pixfmt = PIX_FMT_RGB555;
+					}
+					else
+					{
+						fprintf(
+								stderr,
+								"xtoffmpeg.XImageToFFMPEG(): rgb ordering at image depth %i not supported ... aborting\n",
+								m_image->bits_per_pixel);
+						fprintf(
+								stderr,
+								"xtoffmpeg.XImageToFFMPEG(): color masks: r 0x%.6lX g 0x%.6lX b 0x%.6lX\n",
+								m_image->red_mask, m_image->green_mask,
+								m_image->blue_mask);
+					}
+					break;
+				case 24:
+					if (m_image->red_mask == 0xFF0000 && m_image->green_mask
+							== 0xFF00 && m_image->blue_mask == 0xFF)
+					{
+						input_pixfmt = PIX_FMT_BGR24;
+					}
+					else if (m_image->red_mask == 0xFF && m_image->green_mask
+							== 0xFF00 && m_image->blue_mask == 0xFF0000)
+					{
+						input_pixfmt = PIX_FMT_RGB24;
+					}
+					else
+					{
+						PErrorText(
+								"xtoffmpeg.XImageToFFMPEG(): rgb ordering at image depth not supported ... aborting\n");
+						PErrorText("xtoffmpeg.XImageToFFMPEG(): color masks");
+						return false;
+					}
+					break;
+				case 32:
+					if (c_info.alpha_mask == 0xFF000000 && m_image->green_mask
+							== 0xFF00)
+					{
+						input_pixfmt = PIX_FMT_RGBA32;
+					}
+					else
+					{
+						PErrorText(
+								"xtoffmpeg.XImageToFFMPEG(): image depth not supported ... aborting");
+						return false;
+					}
+					break;
+				default:
+					PErrorText(
+							"xtoffmpeg.XImageToFFMPEG(): image depth not supported ... aborting");
+					return false;
+				}
+
+			}
+
+			if (got_picture)
+			{
+				if (!isPaintPic)
+				{
+					if (m_display && m_image && m_win)
+					{
+
+						avpicture_fill(&pic_rgb, (uint8_t*) m_image->data,
+								input_pixfmt, m_width, m_height);
+
+						if (img_convert(&pic_rgb, input_pixfmt,
+								(AVPicture*) m_pOutFrame, PIX_FMT_YUV420P,
+								m_width, m_height) < 0)
+						{
+							PErrorText("Error pixel format conversion");
+							m_imagemutex.Unlock();
+							return -3;
+						}
+
+						XPutImage(m_display, m_win, m_gc, m_image, 0, 0, 0, 0,
+								m_width, m_height);
+
+					}
+				}
+				isPaintPic = true;
+
+			}
+			realsize -= len;
+			left += len;
+		}
+	}
+
+	m_imagemutex.Unlock();
+	return 0;
+}
+
+void CVDecoder::CloseCodec()
+{
+	m_bInit = false;
+
+	if (m_pOutFrame)
+	{
+		free( m_pOutFrame);
+		m_pOutFrame = 0;
+	}
+	if (m_pCodecCtx)
+	{
+		if (m_pCodecCtx->extradata)
+		{
+			free(m_pCodecCtx->extradata);
+			m_pCodecCtx->extradata = 0;
+			m_pCodecCtx->extradata_size = 0;
+		}
+		avcodec_close( m_pCodecCtx);
+		m_pCodecCtx = 0;
+	}
+
+}
+
+bool CVDecoder::ResetCodec(const int width, const int height)
+{
+	CodecID nCodecID = m_pCodecCtx->codec_id;
+	CloseCodec();
+	m_bInit = false;
+
+	m_width = width;
+	m_height = height;
+
+	// find the video decoder
+	m_pCodec = avcodec_find_decoder(nCodecID);
+	if (!m_pCodec)
+	{
+		PErrorText("Codec not found");
+		return false;
+	}
+
+	if (m_pOutFrame)
+	{
+		free( m_pOutFrame);
+		m_pOutFrame = 0;
+	}
+	m_pOutFrame = avcodec_alloc_frame();
+
+	if (m_pCodecCtx)
+	{
+		if (m_pCodecCtx->extradata)
+		{
+			free(m_pCodecCtx->extradata);
+			m_pCodecCtx->extradata = 0;
+			m_pCodecCtx->extradata_size = 0;
+		}
+		avcodec_close( m_pCodecCtx);
+		m_pCodecCtx = 0;
+	}
+	m_pCodecCtx = avcodec_alloc_context();
+	m_pCodecCtx->extradata = 0;
+	m_pCodecCtx->extradata_size = 0;
+
+	// put sample parameters
+	m_pCodecCtx->bit_rate = 512 * 1024;
+	// resolution must be a multiple of two 
+	m_pCodecCtx->width = m_width;
+	m_pCodecCtx->height = m_height;
+	// frames per second
+	m_pCodecCtx->frame_rate = V_CODEC_framerate;
+	m_pCodecCtx->frame_rate_base = V_CODEC_frame_rate_base;
+	// emit one intra frame every ten frames
+	m_pCodecCtx->gop_size = V_CODEC_gop_size;
+
+	m_pCodecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
+	m_pCodecCtx->extradata = malloc(V_De_ExtraHeaderSize);
+	if (m_pCodecCtx->extradata == 0)
+	{
+		return false;
+	}
+	m_pCodecCtx->extradata_size = V_De_ExtraHeaderSize;
+
+	// we dont send complete frames
+	if (m_pCodec->capabilities & CODEC_CAP_TRUNCATED)
+		m_pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+
+	// open it
+	if (avcodec_open(m_pCodecCtx, m_pCodec) < 0)
+	{
+		PErrorText("could not open codec");
+		return false;
+	}
+
+	m_bInit = true;
+	return true;
+
+}
+
+//CVideoReceiver class.
+
+CVideoReceiver::CVideoReceiver()
+{
+	m_bInit = false;
+}
+
+CVideoReceiver::~CVideoReceiver()
+{
+
+}
+
+bool CVideoReceiver::Init()
+{
+	if (m_bInit)
+		return m_bInit;
+
+	if (!m_vdecoder.Init(320, 240, CODEC_ID_MPEG4))
+	{
+		return false;
+	}
+
+	m_bInit = true;
+	return m_bInit;
+
+}
+
+bool CVideoReceiver::CreateXImage(Drawable parent, int x, int y, int width,
+		int height)
+{
+	bool ret;
+	ret = m_vdecoder.CreateXImage(parent, x, y, width, height);
+
+	return ret;
+}
+
+void CVideoReceiver::CloseXImage()
+{
+	m_vdecoder.CloseXImage();
+}
+
+#define MAX_PACKET_SIZE 10*1024
+int CVideoReceiver::Start(int nHostPort)
+{
+	if (!m_bInit)
+		return -1;
+
+	if (IsActive())
+		return 0;
+
+	//init rtpsession.
+	RTPSessionParams sessParams1;
+	sessParams1.SetOwnTimestampUnit(1.0 / 30.0); //30 video frames per second
+	sessParams1.SetUsePollThread(1); //background thread to call virtual callbacks - set by default, but just to be sure
+	sessParams1.SetMaximumPacketSize(MAX_PACKET_SIZE);
+	//setup transmission parameters
+	RTPUDPv4TransmissionParams transParams1;
+	transParams1.SetPortbase(nHostPort);
+	//CREATE THE SESSION
+	int status1 = Create(sessParams1, &transParams1);
+	if (status1)
+	{
+		//		ReportError(status1);
+		return -2; //unable to create the session
+	}
+
+	return 0;
+}
+
+void CVideoReceiver::Stop()
+{
+	Destroy();
+}
+
+void CVideoReceiver::ProcessFrame(unsigned char* framedata, int framelen)
+{
+	pVideo = (VideoHeader*) framedata;
+	if (pVideo->width != m_vdecoder.m_width || pVideo->height
+			!= m_vdecoder.m_height)
+	{
+		m_vdecoder.ResetCodec(pVideo->width, pVideo->height);
+	}
+	m_vdecoder.DecodeProcess(framedata + sizeof(VideoHeader), framelen
+			- sizeof(VideoHeader));
+}
+
+//CV4LVEncoder class.
+
+CV4LVEncoder::CV4LVEncoder()
+{
+	m_pFrameBuf = 0;
+	m_pFrame = 0;
+	m_pCodec = 0;
+	m_pCodecCtx = 0;
+	m_bInit = false;
+
+}
+
+CV4LVEncoder::~CV4LVEncoder()
+{
+	if (m_pFrameBuf)
+	{
+		free( m_pFrameBuf);
+		m_pFrameBuf = 0;
+	}
+	if (m_pFrame)
+	{
+		free( m_pFrame);
+		m_pFrame = 0;
+	}
+	if (m_pCodecCtx)
+	{
+		avcodec_close( m_pCodecCtx);
+		m_pCodecCtx = 0;
+	}
+	m_bInit = false;
+
+}
+
+bool CV4LVEncoder::Init(int width, int height, enum CodecID nCodecID /*=CODEC_ID_MPEG4*/)
+{
+	m_bInit = false;
+	/*Init for encode*/
+	avcodec_init();
+	avcodec_register_all();
+	printf("1 good end\n");
+	if (m_pFrame)
+	{
+		free( m_pFrame);
+		m_pFrame = 0;
+	}
+	m_pFrame = avcodec_alloc_frame();
+	if (m_pFrame == 0)
+	{
+		return false;
+	}
+
+	/* find the video encoder */
+	m_pCodec = avcodec_find_encoder(nCodecID);
+	if (!m_pCodec)
+	{
+		PErrorText("codec not found");
+
+		printf("\ncodec not found\n");
+		return false;
+	}
+
+	if (m_pCodecCtx)
+	{
+		avcodec_close( m_pCodecCtx);
+		m_pCodecCtx = 0;
+	}
+	printf("avcodec_find_encoder OK %d\n", nCodecID);
+
+	m_pCodecCtx = avcodec_alloc_context();
+	/* resolution must be a multiple of two */
+	m_pCodecCtx->width = width;
+	m_pCodecCtx->height = height;
+	/* frames per second */
+	m_pCodecCtx->frame_rate = V_CODEC_framerate;
+	m_pCodecCtx->frame_rate_base = V_CODEC_frame_rate_base;
+
+	m_pCodecCtx->bit_rate = 512 * 1024; //1128kbps->512kbps
+	m_pCodecCtx->gop_size = V_CODEC_gop_size; /* emit one intra frame every ten frames */
+	m_pCodecCtx->codec_type = CODEC_TYPE_VIDEO;
+	m_pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
+
+	/* open it */
+	printf("avcodec_open start\n");
+
+	if (avcodec_open(m_pCodecCtx, m_pCodec) < 0)
+	{
+		PErrorText("could not open codec");
+		return false;
+	}
+	printf("avcodec_open OK\n");
+
+	//malloc outbuf.
+	if (m_pFrameBuf)
+	{
+		free( m_pFrameBuf);
+		m_pFrameBuf = 0;
+	}
+
+	int image_size = avpicture_get_size(PIX_FMT_YUV420P, m_pCodecCtx->width,
+			m_pCodecCtx->height);
+
+	m_pFrameBuf = (uint8_t*) malloc(image_size);
+	if (m_pFrameBuf == 0)
+	{
+		PErrorText("FrameBuf malloc failed!");
+		return false;
+	}
+	/*Init for encode*/
+
+	avpicture_fill((AVPicture*) m_pFrame, m_pFrameBuf, PIX_FMT_YUV420P,
+			m_pCodecCtx->width, m_pCodecCtx->height);
+	m_pFrame->type = FF_BUFFER_TYPE_SHARED;
+	
+	m_bInit = true;
+	return true;
+}
+
+int CV4LVEncoder::EncodeProcess(char *frameaddress, uint8_t *pOutBuf,
+		int nOutsize)
+{
+
+	if (!m_bInit)
+		return -1;
+
+	if (nOutsize < V_En_OutBufSize)
+		return -2;
+
+	avpicture_fill(&m_pic_rgb, (uint8_t *) frameaddress, PIX_FMT_BGR24,
+			m_pCodecCtx->width, m_pCodecCtx->height);
+	avpicture_fill((AVPicture*) m_pFrame, m_pFrameBuf, PIX_FMT_YUV420P,
+			m_pCodecCtx->width, m_pCodecCtx->height);
+
+	if (img_convert((AVPicture*) m_pFrame, PIX_FMT_YUV420P, &m_pic_rgb,
+			PIX_FMT_BGR24, m_pCodecCtx->width, m_pCodecCtx->height) < 0)
+	{
+		fprintf(
+				stderr,
+				"xtoffmpeg.XImageToFFMPEG(): pixel format conversion not handled ... aborting\n");
+		return -3;
+	}
+
+	m_VideoHeader.width = m_pCodecCtx->width;
+	m_VideoHeader.height = m_pCodecCtx->height;
+	memcpy((char *) pOutBuf, &m_VideoHeader, sizeof(VideoHeader));
+
+	int iii = avcodec_encode_video(m_pCodecCtx, pOutBuf + sizeof(VideoHeader),
+			nOutsize, m_pFrame);
+
+	if (iii <= 0)
+		return -4;
+
+	return iii + sizeof(VideoHeader);
+}
+
+bool CV4LVEncoder::GetCapSize(int &width, int &height)
+{
+	if (!m_bInit)
+		return false;
+
+	width = m_pCodecCtx->width;
+	height = m_pCodecCtx->height;
+
+	return true;
+}
+
+//CV4LStuVideoSender class.
+
+CV4LStuVideoSender::CV4LStuVideoSender()
+{
+	stop = false;
+	m_bInit = 0;
+
+	m_pOutBuf = 0;
+	m_mode = ModeNone;
+	m_pV4Ldev = 0;
+
+	if (!m_initmutex.IsInitialized())
+	{
+		m_initmutex.Init();
+	}
+
+	m_display = 0;
+	m_win = 0;
+	m_d = 0;
+	m_image = 0;
+}
+
+CV4LStuVideoSender::~CV4LStuVideoSender()
+{
+	//first stop thread, because  m_pOutBuf is being used by Thread();
+	Stop();
+
+	//free buffer.
+	if (m_pOutBuf != 0)
+	{
+		free( m_pOutBuf);
+		m_pOutBuf = 0;
+	}
+
+	// for image
+	if (m_image)
+	{
+		XDestroyImage( m_image);
+		m_image = 0;
+	}
+
+	if (m_display)
+	{
+		if (m_win)
+		{
+			XUnmapWindow(m_display, m_win);
+			XClearWindow(m_display, m_win);
+			m_win = 0;
+		}
+
+		if (m_d)
+		{
+			XClearWindow(m_display, m_d);
+			m_d = 0;
+		}
+
+		XCloseDisplay( m_display);
+		m_display = 0;
+	}
+
+	CloseVideo();
+}
+
+bool CV4LStuVideoSender::Init(int nHostPort)
+{
+	m_initmutex.Lock();
+	m_bInit = false;
+
+	if (!m_imagemutex.IsInitialized())
+	{
+		if (m_imagemutex.Init() < 0)
+		{
+			m_initmutex.Unlock();
+			return false;
+		}
+	}
+
+	if (!OpenVideo())
+	{
+		m_initmutex.Unlock();
+		return false;
+	}
+
+	//init rtpsession.
+	RTPSessionParams sessParams1;
+	sessParams1.SetOwnTimestampUnit(1.0 / 30.0); //30 video frames per second
+	sessParams1.SetUsePollThread(0); //background thread to call virtual callbacks - set by default, but just to be sure
+	sessParams1.SetMaximumPacketSize(MAX_PACKET_SIZE);
+	//setup transmission parameters
+	RTPUDPv4TransmissionParams transParams1;
+	transParams1.SetPortbase(nHostPort);
+	//CREATE THE SESSION
+	int status1 = m_fecrtpsession.Create(sessParams1, &transParams1);
+	if (status1)
+	{
+		return false; //unable to create the session
+	}
+
+	//must set for fec SendFECPacket. 
+	m_fecrtpsession.SetDefaultMark(true);
+	m_fecrtpsession.SetDefaultPayloadType(1);
+	m_fecrtpsession.SetDefaultTimestampIncrement(0);
+
+	if (m_pOutBuf == 0)
+	{
+		m_pOutBuf = (uint8_t*) malloc(CV4LVEncoder::V_En_OutBufSize);
+		if (m_pOutBuf == 0)
+		{
+			m_initmutex.Unlock();
+			return false;
+		}
+
+	}
+	//Init sencoder.
+	if (!m_vencoder.Init(VideoWidth, VideoHeight, CODEC_ID_MPEG4))
+	{
+		m_initmutex.Unlock();
+		return false;
+	}
+
+	if (!m_modemutex.IsInitialized())
+	{
+		if (m_modemutex.Init() < 0)
+		{
+			m_initmutex.Unlock();
+			return false;
+		}
+
+	}
+
+	m_bInit = true;
+	m_initmutex.Unlock();
+	return true;
+}
+
+bool CV4LStuVideoSender::OpenVideo()
+{
+	CloseVideo();
+
+	m_pV4Ldev = new V4L();
+
+	if (m_pV4Ldev == 0)
+		return false;
+
+	m_pV4Ldev->setInfo("/dev/video0", "PAL", "", 0);
+
+	if (!m_pV4Ldev->openDevice())
+	{
+		return false;
+	}
+
+	if (!m_pV4Ldev->initialiseCapture(VIDEO_PALETTE_RGB24))
+	{
+		return false;
+	}
+
+	return true;
+}
+
+void CV4LStuVideoSender::CloseVideo()
+{
+	if (m_pV4Ldev != 0)
+	{
+		delete m_pV4Ldev;
+		m_pV4Ldev = 0;
+	}
+}
+
+bool CV4LStuVideoSender::IsInitialized()
+{
+	bool b;
+
+	m_initmutex.Lock();
+	b = m_bInit;
+	m_initmutex.Unlock();
+
+	return b;
+}
+
+bool CV4LStuVideoSender::CreateXImage(Drawable parent, int x, int y, int width,
+		int height)
+{
+
+	int screen_num;
+	XSetWindowAttributes win_attr;
+	GdkPixbuf *original_pixbuf;
+	//GdkPixbuf *scaled_pixbuf;
+	gint original_width, original_height;
+	GdkColorspace original_color;
+	gboolean original_alpha;
+	gboolean pixbuf_has_alpha;
+
+	XImage *p_image = NULL;
+	if (!m_bInit)
+		return false;
+
+	CloseXImage();
+
+	m_imagemutex.Lock();
+
+	m_display = XOpenDisplay(NULL);
+	screen_num = DefaultScreen(m_display);
+	m_gc = DefaultGC(m_display, screen_num);
+	m_d = RootWindow(m_display, screen_num);
+
+	m_win = XCreateWindow(m_display, parent, x, y, width, height, 1,
+			XDefaultDepth(m_display, screen_num), InputOutput, CopyFromParent,
+			0, &win_attr);
+
+	if (gdk_pixbuf_new_from_file("pic/teacher2.bmp", NULL) == NULL)
+	{
+		XSetWindowBackgroundPixmap(m_display, m_win, ParentRelative);
+
+		XMapWindow(m_display, m_win);
+	}
+
+	else
+	{
+		original_pixbuf = gdk_pixbuf_new_from_file("pic/teacher2.bmp", NULL);
+		pixbuf_has_alpha = gdk_pixbuf_get_has_alpha(original_pixbuf);
+		original_color = gdk_pixbuf_get_colorspace(original_pixbuf);
+		original_alpha = gdk_pixbuf_get_has_alpha(original_pixbuf);
+		original_width = gdk_pixbuf_get_width(original_pixbuf);
+		original_height = gdk_pixbuf_get_height(original_pixbuf);
+		printf("original_alpha = %d\n", original_alpha);
+		printf("original_color = %d\n", original_color);
+		printf("original_width = %d\n", original_width);
+		printf("original_height = %d\n", original_height);
+		printf("n_channles = %d\n", gdk_pixbuf_get_n_channels(original_pixbuf));
+
+		Pixmap pixmap = XCreatePixmap(m_display, m_win, original_width,
+				original_height, XDefaultDepth(m_display, screen_num));
+		XSetWindowBackgroundPixmap(m_display, m_win, pixmap);
+
+		p_image = XGetImage(m_display, m_d, 0, 0, original_width, original_height, AllPlanes, ZPixmap);
+		if (!p_image)
+		{
+			printf("error\n");
+			exit(10);
+		}
+
+		AVPicture pic_rgb24, pic_rgb32;
+		if (m_display && p_image && pixmap)
+		{
+			avpicture_fill(&pic_rgb32, (uint8_t*) p_image->data,
+					PIX_FMT_RGBA32, original_width, original_height);
+			avpicture_fill(&pic_rgb24, gdk_pixbuf_get_pixels(original_pixbuf),
+					PIX_FMT_RGB24, original_width, original_height);
+
+			if (img_convert(&pic_rgb32, PIX_FMT_RGBA32, &pic_rgb24,
+					PIX_FMT_RGB24, original_width, original_height) < 0)
+			{
+				printf("Error pixel format conversion");
+				return -1;
+			}
+
+			XPutImage(m_display, pixmap, m_gc, p_image, 0, 0, 0, 0,
+					original_width, original_height);
+
+		}
+
+		XMapWindow(m_display, m_win);
+		XFreePixmap(m_display, pixmap);
+		gdk_pixbuf_unref(original_pixbuf);
+		XDestroyImage(p_image);
+	}
+	int imagewidth, imageheight;
+	m_vencoder.GetCapSize(imagewidth, imageheight);
+
+	m_image = XGetImage(m_display, m_d, 0, 0, imagewidth, imageheight,
+			AllPlanes, ZPixmap);
+	if (!m_image)
+	{
+		PErrorText("GetImage error");
+		m_imagemutex.Unlock();
+		return false;
+	}
+
+	m_imagemutex.Unlock();
+	return true;
+
+}
+
+void CV4LStuVideoSender::CloseXImage()
+{
+
+	if (!IsInitialized())
+		return;
+
+	m_imagemutex.Lock();
+
+	if (m_image)
+	{
+		XDestroyImage( m_image);
+		m_image = 0;
+	}
+
+	if (m_display)
+	{
+		if (m_win)
+		{
+			XUnmapWindow(m_display, m_win);
+			XClearWindow(m_display, m_win);
+			m_win = 0;
+		}
+
+		if (m_d)
+		{
+			XClearWindow(m_display, m_d);
+			m_d = 0;
+		}
+
+		XCloseDisplay( m_display);
+		m_display = 0;
+	}
+
+	m_imagemutex.Unlock();
+}
+
+void CV4LStuVideoSender::Playback(uint8_t* videodata)
+{
+	AVPicture pic_rgb24, pic_rgb32;
+	int width, height;
+
+	if (!IsInitialized())
+		return;
+
+	m_vencoder.GetCapSize(width, height);
+
+	m_imagemutex.Lock();
+
+	if (m_display && m_image && m_win)
+	{
+
+		avpicture_fill(&pic_rgb32, (uint8_t*) m_image->data,
+				CVDecoder::input_pixfmt, width, height);
+		avpicture_fill(&pic_rgb24, videodata, PIX_FMT_BGR24, width, height);
+
+		if (img_convert(&pic_rgb32, CVDecoder::input_pixfmt, &pic_rgb24,
+				PIX_FMT_BGR24, width, height) < 0)
+		{
+			PErrorText("Error pixel format conversion");
+			m_imagemutex.Unlock();
+			return;
+		}
+
+		XPutImage(m_display, m_win, m_gc, m_image, 0, 0, 0, 0, width, height);
+	}
+
+	m_imagemutex.Unlock();
+	return;
+}
+
+int CV4LStuVideoSender::Start()
+{
+
+	if (!IsInitialized())
+		return -1;
+
+	if (JThread::IsRunning())
+		return 0;
+
+	if (!stopmutex.IsInitialized())
+	{
+		if (stopmutex.Init() < 0)
+			return -2;
+	}
+
+	stop = false;
+
+	if (JThread::Start() < 0)
+	{
+		return -6;
+	}
+
+	return 0;
+}
+
+void CV4LStuVideoSender::Stop()
+{
+	if (!IsRunning())
+		return;
+
+	stopmutex.Lock();
+	stop = true;
+	stopmutex.Unlock();
+
+	int count = 0;
+	while (1)
+	{
+		if (count >= 100)
+		{
+			if (JThread::IsRunning())
+			{
+				JThread::Kill();
+			}
+			break;
+		}
+
+		if (JThread::IsRunning())
+		{
+			count++;
+			usleep(10000);
+			continue;
+		}
+
+		break;
+	}
+
+	stop = false;
+
+}
+
+void CV4LStuVideoSender::SetMode(V4LSTUVIDEO_SEND_MODE mode)
+{
+
+	if (!IsInitialized())
+		return;
+
+	if (mode == ModeCapture || mode == ModeTransmit || mode == ModeNone)
+	{
+
+		m_modemutex.Lock();
+		m_mode = mode;
+		m_modemutex.Unlock();
+	}
+
+}
+
+void *CV4LStuVideoSender::Thread()
+{
+	char * data;
+	int OutBufSzie;
+	int status;
+
+	JThread::ThreadStarted();
+
+	bool stopthread;
+	V4LSTUVIDEO_SEND_MODE mode;
+
+	stopmutex.Lock();
+	stopthread = stop;
+	stopmutex.Unlock();
+
+	int64_t pre_time, cur_time;
+	useconds_t delay, delay1;
+	pre_time = av_gettime();
+	if (m_vencoder.m_pCodecCtx->frame_rate != 0)
+	{
+		if (m_vencoder.m_pCodecCtx->frame_rate_base != 0)
+			delay1 = 1000000 * m_vencoder.m_pCodecCtx->frame_rate_base
+					/ m_vencoder.m_pCodecCtx->frame_rate;
+		else
+			delay1 = 1000000 / m_vencoder.m_pCodecCtx->frame_rate;
+	}
+	else
+	{
+		delay1 = 62500;
+	}
+
+	// for utility rate of CPU
+	cur_time = pre_time = av_gettime();
+	pre_time -= delay1;
+
+	while (!stopthread)
+	{
+		delay = cur_time - pre_time;
+		if (delay < delay1)
+		{
+			usleep(delay1 - delay);
+		}
+		pre_time = av_gettime();
+
+		m_modemutex.Lock();
+		mode = m_mode;
+		m_modemutex.Unlock();
+
+		if (mode == ModeNone)
+		{
+			stopmutex.Lock();
+			stopthread = stop;
+			stopmutex.Unlock();
+
+			cur_time = av_gettime();
+			continue;
+		}
+
+		if ((status = Capture((uint8_t**) &data)) < 0)
+		{
+			printf("\nvideo: capture vital error.");
+			stopthread = true;
+			continue;
+		}
+		else
+		{
+			if (mode == ModeCapture || mode == ModeTransmit)
+			{
+				Playback((uint8_t*) data);
+				if (mode == ModeCapture)
+				{
+					stopmutex.Lock();
+					stopthread = stop;
+					stopmutex.Unlock();
+
+					cur_time = av_gettime();
+					continue;
+				}
+			}
+
+			OutBufSzie = CV4LVEncoder::V_En_OutBufSize;
+			if ((status = m_vencoder.EncodeProcess(data, m_pOutBuf, OutBufSzie))
+					< 0)
+			{
+				printf("\nvideo: encode vital error.");
+				stopthread = true;
+				continue;
+			}
+			else
+			{
+				if (status > 0 && mode == ModeTransmit)
+				{
+					m_fecrtpsession.SendFECPacket(m_pOutBuf, status, 10000);
+				}
+			}
+		}
+
+		cur_time = av_gettime();
+	}
+
+	stopmutex.Lock();
+	stopthread = stop;
+	stopmutex.Unlock();
+
+	printf("\nvideo capture thread stoped.\n");
+	return 0;
+}
+
+bool CV4LStuVideoSender::AddDestination(const RTPIPv4Address &des)
+{
+
+	if (!IsInitialized())
+		return false;
+
+	if (m_fecrtpsession.AddDestination(des) < 0)
+		return false;
+
+	return true;
+}
+
+void CV4LStuVideoSender::ClearDestinations()
+{
+
+	if (!IsInitialized())
+		return;
+
+	m_fecrtpsession.ClearDestinations();
+}
+
+int CV4LStuVideoSender::Capture(uint8_t** data)
+{
+	*data = (uint8_t*) m_pV4Ldev->getNextFrame();
+	return 0;
+}

Added: incubator/bluesky/trunk/RealClass/Student-1.0/src/en_de_video.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Student-1.0/src/en_de_video.h?rev=819898&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Student-1.0/src/en_de_video.h (added)
+++ incubator/bluesky/trunk/RealClass/Student-1.0/src/en_de_video.h Tue Sep 29 12:17:17 2009
@@ -0,0 +1,390 @@
+//en_de_video.h
+
+// rtp
+#include "fecrtpsession.h"
+
+#ifndef _KINO_V4L_H
+#define _KINO_V4L_H
+
+#include <vector>
+#include <deque>
+using std::vector;
+using std::deque;
+
+#include <string>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+
+#include <time.h>
+#include <sys/time.h>
+
+#define _DEVICE_H_
+#define _LINUX_TIME_H
+#include <linux/videodev.h>
+
+class V4LStruct
+{
+public:
+	virtual ~V4LStruct()
+	{
+	}
+	virtual void *getStruct() = 0;
+};
+
+class V4LDevice
+{
+public:
+	virtual ~V4LDevice()
+	{
+	}
+	virtual int getHandle() = 0;
+	bool request(int req, V4LStruct *v4l);
+	bool request(int req, void *addr);
+};
+
+class V4LCapability: public V4LStruct
+{
+private:
+	struct video_capability capability;
+
+public:
+	V4LCapability(V4LDevice *device);
+	virtual ~V4LCapability();
+	void *getStruct();
+	char *getName();
+	int getNumberOfChannels();
+	int getNumberOfAudioDevices();
+	int getMinWidth();
+	int getMinHeight();
+	int getMaxWidth();
+	int getMaxHeight();
+	bool canCapture();
+	bool hasTuner();
+	bool hasChromakey();
+	bool hasClipping();
+	bool hasOverwrite();
+	bool hasScaling();
+	bool isMonochrome();
+	bool canSubCapture();
+	void report();
+};
+
+class V4LTuner: public V4LStruct
+{
+private:
+	V4LDevice *device;
+	struct video_tuner tuner;
+
+public:
+	V4LTuner(V4LDevice *device, int index);
+	void *getStruct();
+	void report();
+	int getRangeLow();
+	void setRangeLow(int low);
+	int getRangeHigh();
+	void setRangeHigh(int high);
+	int getFlags();
+	void setFlags(int flags);
+	int getMode();
+	void setMode(int mode);
+	int getSignal();
+};
+
+class V4LChannel: public V4LStruct
+{
+private:
+	V4LDevice *device;
+	struct video_channel channel;
+	vector<V4LTuner *> tuners;
+	V4LTuner *current;
+
+public:
+	V4LChannel(V4LDevice *device, int index);
+	virtual ~V4LChannel();
+	void *getStruct();
+	char *getName();
+	bool setTuner(unsigned int index);
+	unsigned int getNumberOfTuners();
+	V4LTuner *getTuner(unsigned int index);
+	int getSignal();
+	void report();
+};
+
+class V4L: public V4LDevice
+{
+
+private:
+	enum V4LPARA
+	{
+		VideoWidth = 320, VideoHeight = 240
+	};
+
+private:
+	int fd;
+	vector<V4LChannel *> channels;
+	V4LChannel *current;
+	int width;
+	int height;
+	void *map;
+	struct video_mmap frame[32];
+	int frame_maps;
+	int frame_next;
+	int size;
+	int frames;
+	long long starttime;
+	char *device;
+	char *input;
+	int sample;
+	int fps;
+public:
+	char *audio;
+	V4LCapability *capability;
+	V4L();
+	virtual ~V4L();
+	void setInfo(char *device, char *input, char *audio, int sample);
+	bool openDevice();
+	bool deviceAvailable();
+	int getHandle();
+	unsigned int getNumberOfChannels();
+	V4LChannel *getChannel(unsigned int);
+	bool setChannel(unsigned int channel);
+	unsigned int getNumberOfTuners();
+	V4LTuner *getTuner(unsigned int);
+	bool setTuner(unsigned int tuner);
+	bool setCaptureResolution(int width, int height);
+	int getWidth();
+	int getHeight();
+	void startAudio();
+	void stopAudio();
+	bool initialiseCapture(int format);
+	void *getNextFrame();
+	void stopCapture();
+	int getFrequency();
+	bool setFrequency(int frequency);
+	int getSignal();
+	void report();
+	int mappedMemorySize(bool init = false);
+	int frameSample;
+};
+
+#endif
+
+// Linux sys.
+#include <iostream>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <linux/types.h>
+#include <linux/videodev.h>
+// FFmpeg
+#include <ffmpeg/avcodec.h>
+#include <ffmpeg/avformat.h>
+// Time
+#include <time.h>
+// X11
+#include <X11/Intrinsic.h>
+#include <X11/XWDFile.h>
+// Jthread and JMutex
+#include <jthread.h>
+#include <jmutex.h>
+
+#include "en_de_sendthread.h"
+#include "en_de_screen.h"
+
+#if !defined(_EN_DE_VIDEO_H__INCLUDED_)
+#define _EN_DE_VIDEO_H__INCLUDED_
+
+typedef void (*VideoPlayback)(uint8_t* videodata, int width, int height);
+
+typedef struct VideoHeader
+{
+	int width;
+	int height;
+} VideoHeader;
+
+//Video decoder.
+class CVDecoder
+{
+	friend class CVideoReceiver;
+
+private:
+	enum VDECODERBUFSIZE
+	{
+		V_De_ExtraHeaderSize = 10000,
+		V_De_SDLBufSize = 512 * 1024,
+		V_De_INBUF_SIZE = 1024
+	};
+public:
+	CVDecoder();
+	virtual ~CVDecoder();
+public:
+	int DecodeProcess(uint8_t *encodeddata_v, const int encodeddatasize_v);
+	bool Init(int width, int height, enum CodecID nCodecID);
+	enum VIDEO_CODEC_PARA
+	{
+		V_CODEC_width = 320,
+		V_CODEC_height = 240,
+		V_CODEC_framerate = 25,
+		V_CODEC_frame_rate_base = 1,
+		V_CODEC_gop_size = 8,
+		V_CODEC_max_b_frames = 1
+	};
+
+public:
+	bool CreateXImage(Drawable parent, int x, int y, int width, int height);
+	void CloseXImage();
+	void GetColorInfo(XImage *image, ColorInfo *ci /* return struct */);
+
+private:
+
+	void CloseCodec();
+	bool ResetCodec(const int width, const int height);
+	bool m_bInit;
+	AVCodec *m_pCodec;
+	AVCodecContext *m_pCodecCtx;
+	AVFrame *m_pOutFrame;
+	AVPicture pic_rgb;
+	int m_width;
+	int m_height;
+	//for ximage
+	Display *m_display;
+	GC m_gc;
+	Window m_d;
+
+	Window m_win;
+	XImage *m_image;
+	JMutex m_imagemutex;
+	ColorInfo c_info;
+public:
+	static int input_pixfmt;
+
+};
+
+
+class CVideoReceiver: public CFECRtpSession
+{
+public:
+	VideoHeader* pVideo;
+	CVideoReceiver();
+	virtual ~CVideoReceiver();
+
+	bool Init();
+	int Start(int nHostPort);
+	void Stop();
+
+public:
+	bool CreateXImage(Drawable parent, int x, int y, int width, int height);
+	void CloseXImage();
+
+private:
+	virtual void ProcessFrame(unsigned char* framedata, int framelen);
+
+private:
+	bool m_bInit;
+	CVDecoder m_vdecoder;
+};
+
+class CV4LVEncoder
+{
+	friend class CV4LStuVideoSender;
+
+private:
+	enum V4L_VENCODE_BUFSIZE
+	{
+		V_En_OutBufSize = 400 * 1024
+	};
+	enum V4L_VIDEO_CODEC_PARA
+	{
+		V_CODEC_framerate = 16,
+		V_CODEC_frame_rate_base = 1,
+		V_CODEC_gop_size = 12,
+		V_CODEC_max_b_frames = 1
+	};
+public:
+	bool GetCapSize(int &width, int &height);
+	int EncodeProcess(char * frameaddress, uint8_t * pOutBuf, int nOutsize);
+	bool Init(int width, int height, enum CodecID nCodecID = CODEC_ID_MPEG4);
+	CV4LVEncoder();
+	virtual ~CV4LVEncoder();
+
+private:
+	bool m_bInit;
+
+	AVPicture m_pic_rgb;
+	uint8_t *m_pFrameBuf;
+	AVFrame *m_pFrame;
+	AVCodec *m_pCodec;
+	AVCodecContext *m_pCodecCtx;
+	VideoHeader m_VideoHeader;
+};
+
+// V4L video for student sender.
+class CV4LStuVideoSender: private JThread
+{
+public:
+	enum V4LSTUVIDEO_SEND_MODE
+	{
+		ModeNone = 0, ModeCapture = 1, ModeTransmit = 2
+	};
+private:
+	enum V4LSTUVIDEO_SEND_PARA
+	{
+		VideoWidth = 320, VideoHeight = 240
+	};
+public:
+	CV4LStuVideoSender();
+	~CV4LStuVideoSender();
+	bool Init(int nHostPort);
+	bool AddDestination(const RTPIPv4Address &des);
+	void ClearDestinations();
+	int Start();
+	void Stop();
+	void SetMode(V4LSTUVIDEO_SEND_MODE mode);
+	bool CreateXImage(Drawable parent, int x, int y, int width, int height);
+	void CloseXImage();
+	bool IsInitialized();
+
+private:
+	bool OpenVideo();
+	void CloseVideo();
+	int Capture(uint8_t** data);
+	bool IsHavedV4LVideo();
+
+	void Playback(uint8_t* videodata);
+	void *Thread();
+	bool stop;
+	JMutex stopmutex;
+private:
+	CV4LVEncoder m_vencoder;
+	uint8_t *m_pOutBuf;
+	bool m_bInit;
+	JMutex m_initmutex;
+	V4LSTUVIDEO_SEND_MODE m_mode;
+	JMutex m_modemutex;
+
+	//for fec transmmiosn.
+	CFECRtpSession m_fecrtpsession;
+	//for ximage
+	Window m_d;
+
+	Display *m_display;
+	GC m_gc;
+	Window m_win;
+	XImage *m_image;
+	JMutex m_imagemutex;
+	ColorInfo c_info;
+	
+	V4L *m_pV4Ldev;
+
+};
+
+#endif // !defined(_EN_DE_VIDEO_H__INCLUDED_)

Added: incubator/bluesky/trunk/RealClass/Student-1.0/src/error.cc
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Student-1.0/src/error.cc?rev=819898&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Student-1.0/src/error.cc (added)
+++ incubator/bluesky/trunk/RealClass/Student-1.0/src/error.cc Tue Sep 29 12:17:17 2009
@@ -0,0 +1,122 @@
+/*
+ * error.cc Error handling
+ * Copyright (C) 2000 - 2002 Arne Schirmacher <arne@schirmacher.de>
+ *
+ * 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.
+ *
+ * Tag: $Name:  $
+ *
+ * Change log:
+ * 
+ * $Log: error.cc,v $
+ * Revision 1.4  2003/11/17 00:15:19  ddennedy
+ * bump version, remove a couple more strstream, fixup man page
+ *
+ * Revision 1.3  2003/11/16 22:36:49  ddennedy
+ * run make pretty and remove deprecated strstream
+ *
+ * Revision 1.2  2003/09/17 22:10:12  ddennedy
+ * major new features: namely interactive mode and AV/C control
+ *
+ * Revision 1.1.1.1  2003/02/07 04:08:33  ddennedy
+ * initial import of dvgrab
+ *
+ * Revision 1.1  2002/03/04 19:24:57  arne
+ * updated to latest Kino avi code
+ *
+ */
+
+// C includes
+
+#include <errno.h>
+#include <string.h>
+
+// C++ includes
+
+#include <string>
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+
+using std::ostringstream;
+using std::string;
+using std::endl;
+using std::ends;
+
+// local includes
+
+#include "error.h"
+
+void real_fail_neg(int eval, const char *eval_str, const char *func,
+		const char *file, int line)
+{
+	if (eval < 0)
+	{
+		string exc;
+		ostringstream sb;
+
+		sb << file << ":" << line << ": In function \"" << func << "\": \""
+				<< eval_str << "\" evaluated to " << eval;
+		if (errno != 0)
+			sb << endl << file << ":" << line << ": errno: " << errno << " ("
+					<< strerror(errno) << ")";
+		sb << ends;
+		exc = sb.str();
+		throw exc;
+	}
+}
+
+/** error handler for NULL result codes
+ 
+ Whenever this is called with a NULL argument, it will throw an
+ exception. Typically used with functions like malloc() and new().
+ 
+ */
+
+void real_fail_null(const void *eval, const char *eval_str, const char *func,
+		const char *file, int line)
+{
+	if (eval == NULL)
+	{
+
+		string exc;
+		ostringstream sb;
+
+		sb << file << ":" << line << ": In function \"" << func << "\": "
+				<< eval_str << " is NULL" << ends;
+		exc = sb.str();
+		throw exc;
+	}
+}
+
+void real_fail_if(bool eval, const char *eval_str, const char *func,
+		const char *file, int line)
+{
+	if (eval == true)
+	{
+
+		string exc;
+		ostringstream sb;
+
+		sb << file << ":" << line << ": In function \"" << func
+				<< "\": condition \"" << eval_str << "\" is true";
+		if (errno != 0)
+			sb << endl << file << ":" << line << ": errno: " << errno << " ("
+					<< strerror(errno) << ")";
+		sb << ends;
+		exc = sb.str();
+		throw exc;
+	}
+}

Added: incubator/bluesky/trunk/RealClass/Student-1.0/src/error.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Student-1.0/src/error.h?rev=819898&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Student-1.0/src/error.h (added)
+++ incubator/bluesky/trunk/RealClass/Student-1.0/src/error.h Tue Sep 29 12:17:17 2009
@@ -0,0 +1,61 @@
+/*
+ * error.h Error handling
+ * Copyright (C) 2000 - 2002 Arne Schirmacher <arne@schirmacher.de>
+ *
+ * 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.
+ *
+ * Tag: $Name:  $
+ *
+ * Change log:
+ * 
+ * $Log: error.h,v $
+ * Revision 1.3  2003/11/16 22:36:49  ddennedy
+ * run make pretty and remove deprecated strstream
+ *
+ * Revision 1.2  2003/09/17 22:10:12  ddennedy
+ * major new features: namely interactive mode and AV/C control
+ *
+ * Revision 1.1.1.1  2003/02/07 04:08:33  ddennedy
+ * initial import of dvgrab
+ *
+ * Revision 1.1  2002/03/04 19:24:57  arne
+ * updated to latest Kino avi code
+ *
+ */
+
+#ifndef _ERROR_H
+#define _ERROR_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define fail_neg(eval)  real_fail_neg  (eval, #eval, __ASSERT_FUNCTION, __FILE__, __LINE__)
+#define fail_null(eval) real_fail_null (eval, #eval, __ASSERT_FUNCTION, __FILE__, __LINE__)
+#define fail_if(eval)   real_fail_if   (eval, #eval, __ASSERT_FUNCTION, __FILE__, __LINE__)
+
+void real_fail_neg(int eval, const char * eval_str, const char * func,
+		const char * file, int line);
+void real_fail_null(const void * eval, const char * eval_str,
+		const char * func, const char * file, int line);
+void real_fail_if(bool eval, const char * eval_str, const char * func,
+		const char * file, int line);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Added: incubator/bluesky/trunk/RealClass/Student-1.0/src/errormessage.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/Student-1.0/src/errormessage.h?rev=819898&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/Student-1.0/src/errormessage.h (added)
+++ incubator/bluesky/trunk/RealClass/Student-1.0/src/errormessage.h Tue Sep 29 12:17:17 2009
@@ -0,0 +1,124 @@
+
+#define  screensize_error "Screen config failure "
+
+#define  screensize_errorms "\n\nPlease set screen as 1024×768 "
+
+#define  getIP_error "Can't obtain local IP!"
+
+#define  getIP_errorms "\n\nManual configure please!"
+
+#define  usename_error "Logon failure"
+
+#define  usename_errorms "\n\nNo user name!"
+
+#define  usename_error1 "Logon failure"
+
+#define  usename_error1ms "User name too long!\n No more than 10 Chinese characters \nor 30 English characters"
+
+#define  config_error1 "Receive port error!"
+
+#define  config_error1ms "\nPlease set the port as an \neven number greater than 1024."
+
+#define  load_error1 "Logon server failure!"
+
+#define  load_error1ms "\nCan't logon server.\nCheck the configuration please."
+
+#define  load_error2 "Can't logon system."
+
+#define  load_error2ms "\nUser name have been used.\nChange another one please!"
+
+#define  load_error3 "Can't logon system."
+
+#define  load_error3ms "\n\nStudents client overload."
+
+#define  load_error4 "Can't logon system."
+
+#define  load_error4ms "\n\nNetwork error.Logon again!"
+
+#define  getclasslist_error "Obtain group message error."
+
+#define  getclasslist_errorms "\nJoin class later \nor logon system again."
+
+#define  addclass_error "Join class failure."
+
+#define  addclass_errorms "\n\nSelect class again please."
+
+#define  addclass_error1 "Join class failure."
+
+#define  addclass_error1ms "\nSorry!Too many students \njoin this class.Try later."
+
+#define  exitclass_error " "
+
+#define  exitclass_errorms "Quit class failure,try again!"
+
+#define  focus_error1 "Apply for focus failure."
+
+#define  focus_error1ms "\nFocus already exist.\nTry later."
+
+#define  focus_error2 "Apply for focus failure."
+
+#define  focus_error2ms "\nTeacher client deny.\nTry later."
+
+#define  killfocus_error "Kill focus failure."
+
+#define  killfocus_errorms "\nCan't get teacher's permit.\nTry later."
+
+#define  getstulist_error "Can't obtain the students list.\nTry again."
+
+#define  port_error "Receive port configuration error."
+
+#define  port_errorms "\nPlease set the port as an \neven number greater than 1024."
+
+//#define  screensize_error "   屏幕设置失败 "
+//#define  screensize_errorms "\n\n 请将屏幕设置为1024×768 "
+
+//#define  getIP_error "     		无法自动获取本机IP地址"
+//#define  getIP_errorms "\n\n请点击高级按钮手动设置" 
+
+//#define  usename_error     "     登陆失败! "
+//#define usename_errorms  "\n\n用户名不能为空"
+
+//#define usename_error1 "     登陆失败! "
+//#define usename_error1ms "\n\n用户名过长,请输入少于10个汉字或者30个英文字符"
+
+ 
+ //#define config_error1 "     接收端口设置错误    "
+ //#define config_error1ms " \n\n请将接收基准端口设为大于1024的偶数 "
+ 
+//#define load_error1  "        			登录失败!     "  
+//#define load_error1ms "\n\n无法连接课堂服务中心,请修改配置参数是否正确"
+
+//#define load_error2  "      无法登陆系统!      "
+//#define  load_error2ms   " \n\n该用户该用户已经存在,请更换用户名 "
+
+//#define  load_error3    "		无法登陆系统!"
+//#define  load_error3ms  "\n\n听课端人数已满"
+
+//#define  load_error4    " 		无法登陆系统!"
+//#define  load_error4ms  "\n\n网络出现故障,请重新登陆"
+
+//#define  getclasslist_error   "		获取组消息失败"
+//#define getclasslist_errorms "\n\n重新加入课堂或者稍候重新登陆系统"
+
+//#define addclass_error    "				加入课堂失败"
+//#define  addclass_errorms   "\n\n请重新选择课堂"
+
+//#define addclass_error1 "				加入课堂失败"
+//#define addclass_error1ms "\n\n对不起,该课堂人数已满,请稍候再试"
+
+//#define  exitclass_error "  "
+//#define  exitclass_errorms   "		退出课堂失败,请重试		"
+
+//#define focus_error1 "  		申请焦点失败"
+//#define  focus_error1ms"\n\n已经存在一个焦点,请稍候再试"
+
+//#define  focus_error2  "					申请焦点失败"
+//#define  focus_error2ms "\n\n教师端没有同意您的申请,请稍候再试"
+
+//#define  killfocus_error  "					撤消焦点失败"
+//#define  killfocus_errorms "\n\n您暂时未得到老师的同意撤消焦点,请稍候再试"
+
+//#define  getstulist_error   "无法得到学生列表,请重试"
+
+//#define port_error " 基准端口设置错误"
+//#define port_errorms " \n\n请将基准端口设置为大于1024的偶数"



Mime
View raw message