1 /* 2 ** 3 ** Copyright 2008, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 18 #ifndef ANDROID_MEDIARECORDERCLIENT_H 19 #define ANDROID_MEDIARECORDERCLIENT_H 20 21 #include <media/IMediaRecorder.h> 22 23 #include <android/hardware/media/omx/1.0/IOmx.h> 24 25 namespace android { 26 27 struct MediaRecorderBase; 28 class MediaPlayerService; 29 class ICameraRecordingProxy; 30 31 class MediaRecorderClient : public BnMediaRecorder 32 { 33 typedef ::android::hardware::media::omx::V1_0::IOmx IOmx; 34 35 class ServiceDeathNotifier : 36 public IBinder::DeathRecipient, 37 public ::android::hardware::hidl_death_recipient 38 { 39 public: 40 ServiceDeathNotifier( 41 const sp<IBinder>& service, 42 const sp<IMediaRecorderClient>& listener, 43 int which); 44 ServiceDeathNotifier( 45 const sp<IOmx>& omx, 46 const sp<IMediaRecorderClient>& listener, 47 int which); 48 virtual ~ServiceDeathNotifier(); 49 virtual void binderDied(const wp<IBinder>& who); 50 virtual void serviceDied( 51 uint64_t cookie, 52 const wp<::android::hidl::base::V1_0::IBase>& who); 53 void unlinkToDeath(); 54 private: 55 int mWhich; 56 sp<IBinder> mService; 57 sp<IOmx> mOmx; 58 wp<IMediaRecorderClient> mListener; 59 }; 60 61 void clearDeathNotifiers(); 62 63 public: 64 virtual status_t setCamera(const sp<hardware::ICamera>& camera, 65 const sp<ICameraRecordingProxy>& proxy); 66 virtual status_t setPreviewSurface(const sp<IGraphicBufferProducer>& surface); 67 virtual status_t setVideoSource(int vs); 68 virtual status_t setAudioSource(int as); 69 virtual status_t setOutputFormat(int of); 70 virtual status_t setVideoEncoder(int ve); 71 virtual status_t setAudioEncoder(int ae); 72 virtual status_t setOutputFile(int fd); 73 virtual status_t setNextOutputFile(int fd); 74 virtual status_t setVideoSize(int width, int height); 75 virtual status_t setVideoFrameRate(int frames_per_second); 76 virtual status_t setParameters(const String8& params); 77 virtual status_t setListener( 78 const sp<IMediaRecorderClient>& listener); 79 virtual status_t setClientName(const String16& clientName); 80 virtual status_t prepare(); 81 virtual status_t getMaxAmplitude(int* max); 82 virtual status_t getMetrics(Parcel* reply); 83 virtual status_t start(); 84 virtual status_t stop(); 85 virtual status_t reset(); 86 virtual status_t pause(); 87 virtual status_t resume(); 88 virtual status_t init(); 89 virtual status_t close(); 90 virtual status_t release(); 91 virtual status_t dump(int fd, const Vector<String16>& args); 92 virtual status_t setInputSurface(const sp<PersistentSurface>& surface); 93 virtual sp<IGraphicBufferProducer> querySurfaceMediaSource(); 94 95 private: 96 friend class MediaPlayerService; // for accessing private constructor 97 98 MediaRecorderClient( 99 const sp<MediaPlayerService>& service, 100 pid_t pid, 101 const String16& opPackageName); 102 virtual ~MediaRecorderClient(); 103 104 sp<ServiceDeathNotifier> mCameraDeathListener; 105 sp<ServiceDeathNotifier> mCodecDeathListener; 106 107 pid_t mPid; 108 Mutex mLock; 109 MediaRecorderBase *mRecorder; 110 sp<MediaPlayerService> mMediaPlayerService; 111 }; 112 113 }; // namespace android 114 115 #endif // ANDROID_MEDIARECORDERCLIENT_H 116