blob: a3f2a3f4ff00a512cf4780d000cc9e602b89030b
1 | #ifndef _ANDROID_TV_CLIENT_H_ |
2 | #define _ANDROID_TV_CLIENT_H_ |
3 | |
4 | #include <utils/Timers.h> |
5 | #include <include/ITvClient.h> |
6 | #include <binder/MemoryHeapBase.h> |
7 | #include <binder/MemoryBase.h> |
8 | #include <utils/threads.h> |
9 | |
10 | using namespace android; |
11 | |
12 | class ITvService; |
13 | class ITv; |
14 | |
15 | // ref-counted object for callbacks |
16 | class TvListener: virtual public RefBase { |
17 | public: |
18 | virtual void notify(int32_t msgType, const Parcel &ext) = 0; |
19 | }; |
20 | |
21 | class TvClient : public BnTvClient, public IBinder::DeathRecipient { |
22 | public: |
23 | // construct a tv client from an existing remote |
24 | static sp<TvClient> create(const sp<ITv> &tv); |
25 | static sp<TvClient> connect(); |
26 | ~TvClient(); |
27 | void init(); |
28 | status_t reconnect(); |
29 | void disconnect(); |
30 | status_t lock(); |
31 | status_t unlock(); |
32 | |
33 | status_t getStatus() { return mStatus; } |
34 | status_t processCmd(const Parcel &p, Parcel *r); |
35 | status_t createSubtitle(const sp<IMemory> &share_mem); |
36 | status_t createVideoFrame(const sp<IMemory> &share_mem, int iSourceMode, int iCapVideoLayerOnly); |
37 | void setListener(const sp<TvListener> &listener); |
38 | |
39 | // ITvClient interface |
40 | virtual void notifyCallback(int32_t msgType, const Parcel &p); |
41 | |
42 | sp<ITv> remote(); |
43 | |
44 | private: |
45 | TvClient(); |
46 | TvClient(const TvClient &); |
47 | TvClient &operator = (const TvClient); |
48 | virtual void binderDied(const wp<IBinder> &who); |
49 | |
50 | class DeathNotifier: public IBinder::DeathRecipient { |
51 | public: |
52 | DeathNotifier() {} |
53 | virtual void binderDied(const wp<IBinder> &who); |
54 | }; |
55 | |
56 | static sp<DeathNotifier> mDeathNotifier; |
57 | |
58 | // helper function to obtain tv service handle |
59 | static const sp<ITvService> &getTvService(); |
60 | |
61 | sp<ITv> mTv; |
62 | status_t mStatus; |
63 | |
64 | sp<TvListener> mListener; |
65 | |
66 | friend class DeathNotifier; |
67 | |
68 | static Mutex mLock; |
69 | static sp<ITvService> mTvService; |
70 | |
71 | sp<MemoryHeapBase> mBmpMemHeap; |
72 | sp<MemoryBase> mBmpMemBase; |
73 | }; |
74 | #endif/*_ANDROID_TV_CLIENT_H_*/ |
75 | |
76 |