| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef _ANDROID_MEDIA_TV_DVR_CLIENT_H_ |
| 18 |
#define _ANDROID_MEDIA_TV_DVR_CLIENT_H_ |
| 19 |
|
| 20 |
#include <aidl/android/hardware/tv/tuner/DvrSettings.h> |
| 21 |
#include <aidl/android/hardware/tv/tuner/Result.h> |
| 22 |
#include <aidl/android/media/tv/tuner/BnTunerDvrCallback.h> |
| 23 |
#include <aidl/android/media/tv/tuner/ITunerDvr.h> |
| 24 |
#include <fmq/AidlMessageQueue.h> |
| 25 |
|
| 26 |
#include "DvrClientCallback.h" |
| 27 |
#include "FilterClient.h" |
| 28 |
|
| 29 |
using Status = ::ndk::ScopedAStatus; |
| 30 |
using ::aidl::android::hardware::common::fmq::MQDescriptor; |
| 31 |
using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite; |
| 32 |
using ::aidl::android::hardware::tv::tuner::DvrSettings; |
| 33 |
using ::aidl::android::hardware::tv::tuner::PlaybackStatus; |
| 34 |
using ::aidl::android::hardware::tv::tuner::RecordStatus; |
| 35 |
using ::aidl::android::hardware::tv::tuner::Result; |
| 36 |
using ::aidl::android::media::tv::tuner::BnTunerDvrCallback; |
| 37 |
using ::aidl::android::media::tv::tuner::ITunerDvr; |
| 38 |
|
| 39 |
using namespace std; |
| 40 |
|
| 41 |
namespace android { |
| 42 |
|
| 43 |
using AidlMQ = AidlMessageQueue<int8_t, SynchronizedReadWrite>; |
| 44 |
using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>; |
| 45 |
|
| 46 |
class TunerDvrCallback : public BnTunerDvrCallback { |
| 47 |
|
| 48 |
public: |
| 49 |
TunerDvrCallback(sp<DvrClientCallback> dvrClientCallback); |
| 50 |
|
| 51 |
Status onRecordStatus(RecordStatus status); |
| 52 |
Status onPlaybackStatus(PlaybackStatus status); |
| 53 |
|
| 54 |
private: |
| 55 |
sp<DvrClientCallback> mDvrClientCallback; |
| 56 |
}; |
| 57 |
|
| 58 |
struct DvrClient : public RefBase { |
| 59 |
|
| 60 |
public: |
| 61 |
DvrClient(shared_ptr<ITunerDvr> tunerDvr); |
| 62 |
~DvrClient(); |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
void setFd(int32_t fd); |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
int64_t readFromFile(int64_t size); |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
int64_t readFromBuffer(int8_t* buffer, int64_t size); |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
int64_t writeToFile(int64_t size); |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
int64_t seekFile(int64_t pos); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
int64_t writeToBuffer(int8_t* buffer, int64_t size); |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
Result configure(DvrSettings settings); |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
Result attachFilter(sp<FilterClient> filterClient); |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
Result detachFilter(sp<FilterClient> filterClient); |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
Result start(); |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
Result stop(); |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
Result flush(); |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
Result close(); |
| 128 |
|
| 129 |
private: |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
shared_ptr<ITunerDvr> mTunerDvr; |
| 135 |
|
| 136 |
AidlMQ* mDvrMQ; |
| 137 |
EventFlag* mDvrMQEventFlag; |
| 138 |
string mFilePath; |
| 139 |
int32_t mFd; |
| 140 |
}; |
| 141 |
} |
| 142 |
|
| 143 |
#endif |