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