blob: 505f2bbc9abb4645ee81046f0abdb3f50659013e
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() |
34 | { |
35 | return mStatus; |
36 | } |
37 | status_t processCmd(const Parcel &p, Parcel *r); |
38 | status_t createSubtitle(const sp<IMemory> &share_mem); |
39 | status_t createVideoFrame(const sp<IMemory> &share_mem, int iSourceMode, int iCapVideoLayerOnly); |
40 | void setListener(const sp<TvListener> &listener); |
41 | |
42 | // ITvClient interface |
43 | virtual void notifyCallback(int32_t msgType, const Parcel &p); |
44 | |
45 | sp<ITv> remote(); |
46 | |
47 | private: |
48 | TvClient(); |
49 | TvClient(const TvClient &); |
50 | TvClient &operator = (const TvClient); |
51 | virtual void binderDied(const wp<IBinder> &who); |
52 | |
53 | class DeathNotifier: public IBinder::DeathRecipient { |
54 | public: |
55 | DeathNotifier() {} |
56 | virtual void binderDied(const wp<IBinder> &who); |
57 | }; |
58 | |
59 | static sp<DeathNotifier> mDeathNotifier; |
60 | |
61 | // helper function to obtain tv service handle |
62 | static const sp<ITvService> &getTvService(); |
63 | |
64 | sp<ITv> mTv; |
65 | status_t mStatus; |
66 | |
67 | sp<TvListener> mListener; |
68 | |
69 | friend class DeathNotifier; |
70 | |
71 | static Mutex mLock; |
72 | static sp<ITvService> mTvService; |
73 | |
74 | sp<MemoryHeapBase> mBmpMemHeap; |
75 | sp<MemoryBase> mBmpMemBase; |
76 | }; |
77 | #endif/*_ANDROID_TV_CLIENT_H_*/ |
78 | |
79 |