blob: b5994d4e00665ee73c35f4c2dbacbd90833d1f6a
1 | #include <utils/Log.h> |
2 | #include "TvPlay.h" |
3 | #include "../include/tvcmd.h" |
4 | |
5 | TvPlay::TvPlay() { |
6 | mpObserver = NULL; |
7 | tvSession = TvClient::connect(); |
8 | tvSession->setListener(this); |
9 | } |
10 | |
11 | TvPlay::~TvPlay() { |
12 | tvSession.clear(); |
13 | } |
14 | |
15 | int TvPlay::setTvObserver ( TvPlayObserver *ob ) { |
16 | mpObserver = ob; |
17 | return 0; |
18 | } |
19 | |
20 | void TvPlay::notify(int32_t msgType, const Parcel &p) { |
21 | ALOGD("TvPlay-------notify-------"); |
22 | if (mpObserver != NULL) |
23 | mpObserver->onTvEvent(msgType, p); |
24 | } |
25 | |
26 | int TvPlay::StartTv() { |
27 | Parcel p, r; |
28 | p.writeInt32(START_TV); |
29 | tvSession->processCmd(p, &r); |
30 | return r.readInt32(); |
31 | } |
32 | |
33 | int TvPlay::StopTv() { |
34 | Parcel p, r; |
35 | p.writeInt32(STOP_TV); |
36 | tvSession->processCmd(p, &r); |
37 | return r.readInt32(); |
38 | } |
39 | |
40 | int TvPlay::SwitchSourceInput(tv_source_input_t source_input) { |
41 | Parcel p, r; |
42 | p.writeInt32(SET_SOURCE_INPUT); |
43 | p.writeInt32(source_input); |
44 | tvSession->processCmd(p, &r); |
45 | return r.readInt32(); |
46 | } |
47 | |
48 | int TvPlay::DoSuspend(int type) { |
49 | Parcel p, r; |
50 | p.writeInt32(DO_SUSPEND); |
51 | p.writeInt32(type); |
52 | tvSession->processCmd(p, &r); |
53 | return r.readInt32(); |
54 | } |
55 | |
56 | int TvPlay::DoResume(int type) { |
57 | Parcel p, r; |
58 | p.writeInt32(DO_RESUME); |
59 | p.writeInt32(type); |
60 | tvSession->processCmd(p, &r); |
61 | return r.readInt32(); |
62 | } |
63 | |
64 | int TvPlay::GetSourceConnectStatus(tv_source_input_t source_input) { |
65 | Parcel p, r; |
66 | p.writeInt32(GET_SOURCE_CONNECT_STATUS); |
67 | p.writeInt32(source_input); |
68 | tvSession->processCmd(p, &r); |
69 | return r.readInt32(); |
70 | } |
71 | |
72 | int TvPlay::GetCurrentSourceInput() { |
73 | Parcel p, r; |
74 | p.writeInt32(SSM_READ_SOURCE_INPUT); |
75 | tvSession->processCmd(p, &r); |
76 | return r.readInt32(); |
77 | } |
78 | |
79 | int TvPlay::GetHdmiAvHotplugDetectOnoff() { |
80 | Parcel p, r; |
81 | p.writeInt32(HDMIAV_HOTPLUGDETECT_ONOFF); |
82 | tvSession->processCmd(p, &r); |
83 | return r.readInt32(); |
84 | } |
85 | |
86 |