summaryrefslogtreecommitdiff
path: root/orkbasecxx/messages/CaptureMsg.cpp
blob: 4cf17cf4deb42d0887b285418ecd3903ae42e4e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Oreka -- A media capture and retrieval platform
 * 
 * Copyright (C) 2005, orecx LLC
 *
 * http://www.orecx.com
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License.
 * Please refer to http://www.gnu.org/copyleft/gpl.html
 *
 */

#include "Utils.h"
#include "CaptureMsg.h"
//#include "LogManager.h"
//#include "CapturePluginProxy.h"

#define CAPTURE_CLASS "capture"
#define CAPTURE_RESPONSE_CLASS "captureresponse"
#define CAPTURE_STATE_PARAM "state"
#define COMMENT_PARAM "comment"

void CaptureResponseMsg::Define(Serializer* s)
{
	s->BoolValue(SUCCESS_PARAM, m_success);
	s->StringValue(COMMENT_PARAM, m_comment);
}

CStdString CaptureResponseMsg::GetClassName()
{
	return CStdString(CAPTURE_RESPONSE_CLASS);
}

ObjectRef CaptureResponseMsg::NewInstance()
{
	return ObjectRef(new CaptureResponseMsg);
}

//===============================

void CaptureMsg::Define(Serializer* s)
{
	CStdString captureClass(CAPTURE_CLASS);
	s->StringValue(OBJECT_TYPE_TAG, captureClass, true);
	s->StringValue(CAPTURE_PORT_PARAM, m_capturePort, true);
	s->EnumValue(CAPTURE_STATE_PARAM, (int&)m_eventType, CaptureEvent::EventTypeToEnum, CaptureEvent::EventTypeToString, true);
}


CStdString CaptureMsg::GetClassName()
{
	return  CStdString(CAPTURE_CLASS);
}

ObjectRef CaptureMsg::NewInstance()
{
	return ObjectRef(new CaptureMsg);
}

ObjectRef CaptureMsg::Process()
{
	CaptureResponseMsg* msg = new CaptureResponseMsg;
	ObjectRef ref(msg);

	if(m_eventType == CaptureEvent::EtStart)
	{
		//CapturePluginProxySingleton::instance()->StartCapture(m_capturePort);
		msg->m_success = true;
	}
	else if(m_eventType == CaptureEvent::EtStop)
	{
		//CapturePluginProxySingleton::instance()->StopCapture(m_capturePort);
		msg->m_success = true;
	}
	else
	{
		msg->m_success = false;
		msg->m_comment =  CAPTURE_STATE_PARAM;
		msg->m_comment += " needs to be start or stop";
	}
	return ref;
}