summaryrefslogtreecommitdiff
path: root/TvPlay.cpp (plain)
blob: 266e2645f1149b0d9b6c1fdd2cdc1ffa88541a66
1#define LOG_TAG "TvPlay"
2
3#include <utils/Log.h>
4#include <string.h>
5#include "TvPlay.h"
6#include "tvcmd.h"
7
8TvPlay::TvPlay()
9{
10 mpObserver = NULL;
11 tvSession = TvClient::connect();
12 tvSession->setListener(this);
13}
14
15TvPlay::~TvPlay()
16{
17 tvSession.clear();
18}
19
20int TvPlay::setTvObserver ( TvPlayObserver *ob )
21{
22 mpObserver = ob;
23 return 0;
24}
25
26void TvPlay::notify(int32_t msgType, const Parcel &p)
27{
28 ALOGD("TvPlay-------notify-------");
29 if (mpObserver != NULL)
30 mpObserver->onTvEvent(msgType, p);
31}
32
33int TvPlay::StartTv()
34{
35 Parcel p, r;
36 p.writeInt32(START_TV);
37 tvSession->processCmd(p, &r);
38 return r.readInt32();
39}
40
41int TvPlay::StopTv()
42{
43 Parcel p, r;
44 p.writeInt32(STOP_TV);
45 tvSession->processCmd(p, &r);
46 return r.readInt32();
47}
48
49int TvPlay::SwitchSourceInput(tv_source_input_t source_input)
50{
51 Parcel p, r;
52 p.writeInt32(SET_SOURCE_INPUT);
53 p.writeInt32(source_input);
54 tvSession->processCmd(p, &r);
55 return r.readInt32();
56}
57
58int TvPlay::DoSuspend(int type)
59{
60 Parcel p, r;
61 p.writeInt32(DO_SUSPEND);
62 p.writeInt32(type);
63 tvSession->processCmd(p, &r);
64 return r.readInt32();
65}
66
67int TvPlay::DoResume(int type)
68{
69 Parcel p, r;
70 p.writeInt32(DO_RESUME);
71 p.writeInt32(type);
72 tvSession->processCmd(p, &r);
73 return r.readInt32();
74}
75
76int TvPlay::GetSourceConnectStatus(tv_source_input_t source_input)
77{
78 Parcel p, r;
79 p.writeInt32(GET_SOURCE_CONNECT_STATUS);
80 p.writeInt32(source_input);
81 tvSession->processCmd(p, &r);
82 return r.readInt32();
83}
84
85int TvPlay::GetCurrentSourceInput()
86{
87 Parcel p, r;
88 p.writeInt32(SSM_READ_SOURCE_INPUT);
89 tvSession->processCmd(p, &r);
90 return r.readInt32();
91}
92
93int TvPlay::GetHdmiAvHotplugDetectOnoff()
94{
95 Parcel p, r;
96 p.writeInt32(HDMIAV_HOTPLUGDETECT_ONOFF);
97 tvSession->processCmd(p, &r);
98 return r.readInt32();
99}
100
101int TvPlay::getAllTvDevices(int *devices, int *count)
102{
103 Parcel p, r;
104 p.writeInt32(GET_ALL_TV_DEVICES);
105 tvSession->processCmd(p, &r);
106 const char *input_list = r.readCString();
107 ALOGD("input_list = %s", input_list);
108
109 int len = 0;
110 const char *seg = ",";
111 char *pT = strtok((char*)input_list, seg);
112 while (pT) {
113 len ++;
114 *devices = atoi(pT);
115 ALOGD("devices: %d: %d", len , *devices);
116 devices ++;
117 pT = strtok(NULL, seg);
118 }
119 *count = len;
120 return 0;
121}
122
123