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