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 "DeathNotifier.h" 22 23 #include <media/AudioSystem.h> 24 #include <media/IMediaRecorder.h> 25 26 #include <vector> 27 28 namespace android { 29 30 struct MediaRecorderBase; 31 class MediaPlayerService; 32 class ICameraRecordingProxy; 33 34 class MediaRecorderClient : public BnMediaRecorder 35 { 36 class AudioDeviceUpdatedNotifier: public AudioSystem::AudioDeviceCallback 37 { 38 public: 39 AudioDeviceUpdatedNotifier(const sp<IMediaRecorderClient>& listener); 40 virtual ~AudioDeviceUpdatedNotifier(); 41 virtual void onAudioDeviceUpdate( 42 audio_io_handle_t audioIo, 43 audio_port_handle_t deviceId); 44 private: 45 wp<IMediaRecorderClient> mListener; 46 }; 47 48 public: 49 virtual status_t setCamera(const sp<hardware::ICamera>& camera, 50 const sp<ICameraRecordingProxy>& proxy); 51 virtual status_t setPreviewSurface(const sp<IGraphicBufferProducer>& surface); 52 virtual status_t setVideoSource(int vs); 53 virtual status_t setAudioSource(int as); 54 virtual status_t setOutputFormat(int of); 55 virtual status_t setVideoEncoder(int ve); 56 virtual status_t setAudioEncoder(int ae); 57 virtual status_t setOutputFile(int fd); 58 virtual status_t setNextOutputFile(int fd); 59 virtual status_t setVideoSize(int width, int height); 60 virtual status_t setVideoFrameRate(int frames_per_second); 61 virtual status_t setParameters(const String8& params); 62 virtual status_t setListener( 63 const sp<IMediaRecorderClient>& listener); 64 virtual status_t setClientName(const String16& clientName); 65 virtual status_t prepare(); 66 virtual status_t getMaxAmplitude(int* max); 67 virtual status_t getMetrics(Parcel* reply); 68 virtual status_t start(); 69 virtual status_t stop(); 70 virtual status_t reset(); 71 virtual status_t pause(); 72 virtual status_t resume(); 73 virtual status_t init(); 74 virtual status_t close(); 75 virtual status_t release(); 76 virtual status_t dump(int fd, const Vector<String16>& args); 77 virtual status_t setInputSurface(const sp<PersistentSurface>& surface); 78 virtual sp<IGraphicBufferProducer> querySurfaceMediaSource(); 79 virtual status_t setInputDevice(audio_port_handle_t deviceId); 80 virtual status_t getRoutedDeviceId(audio_port_handle_t* deviceId); 81 virtual status_t enableAudioDeviceCallback(bool enabled); 82 virtual status_t getActiveMicrophones( 83 std::vector<media::MicrophoneInfo>* activeMicrophones); 84 virtual status_t setPreferredMicrophoneDirection(audio_microphone_direction_t direction); 85 virtual status_t setPreferredMicrophoneFieldDimension(float zoom); 86 status_t getPortId(audio_port_handle_t *portId) override; 87 88 private: 89 friend class MediaPlayerService; // for accessing private constructor 90 91 MediaRecorderClient( 92 const sp<MediaPlayerService>& service, 93 pid_t pid, 94 const String16& opPackageName); 95 virtual ~MediaRecorderClient(); 96 97 std::vector<DeathNotifier> mDeathNotifiers; 98 sp<AudioDeviceUpdatedNotifier> mAudioDeviceUpdatedNotifier; 99 100 pid_t mPid; 101 Mutex mLock; 102 MediaRecorderBase *mRecorder; 103 sp<MediaPlayerService> mMediaPlayerService; 104 }; 105 106 }; // namespace android 107 108 #endif // ANDROID_MEDIARECORDERCLIENT_H 109