enable dual camera
[platform/framework/native/media.git] / src / FMedia_VideoRecorderImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 /**
19  * @file                        FMedia_VideoRecorderImpl.h
20  * @brief                       This is the header file for the %_VideoRecorderImpl class.
21  */
22 #ifndef _FMEDIA_INTERNAL_VIDEORECORDER_IMPL_H_
23 #define _FMEDIA_INTERNAL_VIDEORECORDER_IMPL_H_
24
25 #include <unique_ptr.h>
26 #include <recorder.h>
27 #include <FBaseColIList.h>
28 #include <FGrpDimension.h>
29 #include <FMediaTypes.h>
30 #include <FMediaVideoRecorderTypes.h>
31 #include "FMedia_ICameraCoordinatorListener.h"
32 #include "FMedia_CameraTypes.h"
33 #include "FMedia_RecorderTypes.h"
34
35 namespace Tizen { namespace Media
36 {
37 class Camera;
38 class VideoRecorder;
39 class IVideoRecorderEventListener;
40 class _AudioStreamCoordinator;
41 class IAudioStreamFilter;
42
43 class _CameraCoordinator;
44 class _RecorderRef;
45 class _VideoRecorderEvent;
46 class _VideoSourceAdapter;
47
48 /**
49  * @class       _VideoRecorderImpl
50  * @brief       This class records a video.
51  */
52 class _VideoRecorderImpl
53         : public Tizen::Base::Object
54         , public _ICameraCoordinatorListener
55 {
56 public:
57         /**
58          * This is the default constructor for this class.
59          *
60          * @remarks     The object is not fully constructed after this constructor is called. For full construction,
61          * the Construct() method must be called right after calling this constructor.
62          * @see  Construct()
63          */
64         _VideoRecorderImpl(void);
65
66         /**
67          * This is the destructor for this class. @n
68          * All allocated resources are deallocated by this method. This method should be called in the same thread in
69          * which the Construct() method is called. This polymorphic destructor should be overridden if required.
70          * This way, the destructors of the derived classes are called when the destructor of this interface is called.
71          *
72          * @see  Construct()
73          */
74         virtual ~_VideoRecorderImpl(void);
75
76         /**
77         * Initializes this instance of _VideoRecorderImpl with an associated listener and an input source.
78         *
79         * @return               An error code
80         * @param[in]    listener                        An event listener object
81         * @param[in]    camera                          A Camera object for the input source
82         * @exception    E_SUCCESS                       The method is successful.
83         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
84         * @exception    E_SYSTEM                        A system error has occurred.
85         * @exception    E_DEVICE_BUSY           The device cannot be approached because of other operations.
86         */
87         result Construct(IVideoRecorderEventListener& listener, const Camera& camera);
88
89         /**
90         * Creates a video file for a recording.
91         *
92         * @return               An error code
93         * @param[in]    destMediaPath                           The destination for the file be written @n
94         *                                                                               The available paths start with prefixes retrieved from the functions such as: @n
95         *                                                                               Tizen::App::App::GetInstance()->GetAppRootPath() @n
96         *                                                                               Tizen::System::Environment::GetMediaPath() @n
97         *                                                                               Tizen::System::Environment::GetExternalStoragePath()
98         * @param[in]    overwrite                                       Set to @c true to overwrite the file, @n
99         *                                                                                       else @c false
100         * @exception    E_SUCCESS                                       The method is successful.
101         * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
102         * @exception    E_RESOURCE_UNAVAILABLE          The required file path is unavailable.
103         * @exception    E_FILE_ALREADY_EXIST            The specified file already exists.
104         * @exception    E_STORAGE_FULL                          The storage is full.
105         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
106         * @see            Close()
107         */
108         result CreateVideoFile(const Tizen::Base::String& destMediaPath, bool overwrite);
109
110         /**
111         * Closes the video file. @n
112         * This is a synchronous method.
113         *
114         * @return               An error code
115         * @exception    E_SUCCESS                               The method is successful.
116         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
117         * @exception    E_SYSTEM                                A system error has occurred.
118         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
119         * @see                  CreateVideoFile()
120         */
121         result Close(void);
122
123         /**
124         * Starts the recording. @n
125         * Resumes the recording if Pause() has been called.
126         *
127         * @return               An error code
128         * @exception    E_SUCCESS                               The method is successful.
129         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
130         * @exception    E_SYSTEM                                A system error has occurred.
131         * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
132         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
133         * @remarks        This method must be called after the input media source is started (for example, Camera::StartPreview()).
134         * @see                  Stop(), Pause()
135         */
136         result Record(void);
137
138         /**
139         * Stops the recording.
140         *
141         * @return               An error code
142         * @exception    E_SUCCESS                               The method is successful.
143         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
144         * @exception    E_SYSTEM                                A system error has occurred.
145         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
146         * @see                  Record(), Pause()
147         */
148         result Stop(void);
149
150         /**
151         * Pauses the recording. @n
152         * To resume the recording after this method is called, Record() must be called.
153         *
154         * @return               An error code
155         * @exception    E_SUCCESS                               The method is successful.
156         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
157         * @exception    E_SYSTEM                                A system error has occurred.
158         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
159         * @see                  Stop(), Record()
160         */
161         result Pause(void);
162
163         /**
164         * Cancels the recording operation without saving the data.
165         *
166         * @return               An error code
167         * @exception    E_SUCCESS                               The method is successful.
168         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
169         * @exception    E_SYSTEM                                A system error has occurred.
170         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
171         * @remarks              When this method is called, the state is changed to ::RECORDER_STATE_STOPPING. @n
172         *                               After IVideoRecorderEventListener::OnVideoRecorderCanceled is called, the state is changed to
173         *                               ::RECORDER_STATE_STOPPED.
174         * @see                  Record(), Stop()
175         */
176         result Cancel(void);
177
178         /**
179         * Gets the state of a recorder.
180         *
181         * @see                  CreateVideoFile(), Close(), Record(), Stop(), Pause(), RecorderState()
182         */
183         RecorderState GetState(void) const;
184
185         /**
186         * Gets the current recording time.
187         *
188         * @return               The current recording time in milliseconds, @n
189         *                               else @c -1 if the recording has not started as yet
190         */
191         long GetRecordingTime(void) const;
192
193         /**
194         * Gets the current recording size.
195         *
196         * @return               A @c long value indicating the current recording size in bytes, @n
197         *                               else @c -1 if the recording has not started as yet
198         */
199         long GetRecordingSize(void) const;
200
201         /**
202         * Sets the time limit for the recording in milliseconds.
203         *
204         * @return               An error code
205         * @param[in]    msTime                          The maximum recording time in milliseconds @n
206         *                                                                       The time must be greater than @c 0.
207         * @exception    E_SUCCESS                       The method is successful.
208         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
209         * @exception    E_OUT_OF_RANGE          The specified time is out of range.
210         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
211         * @remarks              The default time is @c 60 seconds.
212         * @see                  GetMaxRecordingTime()
213         */
214         result SetMaxRecordingTime(long msTime);
215
216         /**
217         * Gets the time limit of the recording in milliseconds.
218         *
219         * @return               A @c long value indicating the maximum recording time in milliseconds @n
220         *                               else @c -1 if the recording has not started as yet
221         * @see                  SetMaxRecordingTime()
222         */
223         long GetMaxRecordingTime(void) const;
224
225         /**
226         * Sets the codec for the recorder. @n
227         * Initially, the default codec from the internal configuration is set.
228         *
229         * @return               An error code
230         * @param[in]    codec                                   The codec name @n
231         *                                                                               It should be one of the strings listed by GetSupportedCodecListN(). @n
232         *                                                                               GetSupportedCodecListN() returns the list of strings in the following formats: @n
233         *                                                                               - "VIDEO_CODEC_H263" @n
234         *                                                                               - "VIDEO_CODEC_MPEG4SP" @n
235         *                                                                               The returned strings are different depending on each device. @n
236         *                                                                               The following string is always operated upon. This value is different
237         *                                                                               for each device. @n
238         *                                                                               "VIDEO_CODEC_DEFAULT": the default codec
239         * @exception    E_SUCCESS                               The method is successful.
240         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
241         * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
242         * @exception    E_SYSTEM                                A system error has occurred.
243         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
244         * @see                  GetCodec(), GetSupportedCodecListN()
245         */
246         result SetCodec(const Tizen::Base::String& codec);
247
248         /**
249         * Gets the codec for the recorder.
250         *
251         * @return               The current codec
252         * @see                  SetCodec(), GetSupportedCodecListN()
253         */
254         Tizen::Base::String GetCodec(void) const;
255
256         /**
257         * Gets the list of supported video recorder codecs. @n
258         * Each item in the list is a Tizen::Base::String value.
259         *
260         * @return          The list of strings that represents the supported video recorder codecs, @n
261         *                               else @c null if no codec is supported or if an exception occurs
262         * @exception    E_SUCCESS                                       The method is successful.
263         * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
264         * @exception    E_SYSTEM                                        A system error has occurred.
265         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
266         * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
267         *                          The return value must be released by the caller. @n
268         *                          All items in the list must be released by the caller.
269         * @see                  SetCodec(), GetCodec()
270         */
271         Tizen::Base::Collection::IList* GetSupportedCodecListN(void) const;
272
273         /**
274         * Gets the list of supported audio codecs. @n
275         * Each item in the list has a ::CodecType value.
276         *
277         * @return          A list of supported audio codecs, @n
278         *                               else @c null if no codec is supported or if an exception occurs
279         * @exception    E_SUCCESS                       The method is successful.
280         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
281         * @exception    E_SYSTEM                        A system error has occurred.
282         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
283         * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
284         *                          The return value must be released by the caller.
285         * @see            SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container ),
286         *                               GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
287         */
288         Tizen::Base::Collection::ArrayListT <CodecType>* GetSupportedAudioCodecListN(void) const;
289
290         /**
291         * Gets the list of supported video codecs. @n
292         * Each item in the list has a ::CodecType value.
293         *
294         * @return          A list of supported video codecs, @n
295         *                               else @c null if no codec is supported or if an exception occurs
296         * @exception    E_SUCCESS                               The method is successful.
297         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
298         * @exception    E_SYSTEM                                A system error has occurred.
299         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
300         * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
301         *                          The return value must be released by the caller.
302         * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container ), GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
303         */
304         Tizen::Base::Collection::ArrayListT <CodecType>* GetSupportedVideoCodecListN(void) const;
305
306         /**
307         * Gets the list of supported containers. @n
308         * Each item in the list has a ::MediaContainerType value.
309         *
310         * @return          A list of supported containers, @n
311         *                               else @c null if no container is supported or if an exception occurs
312         * @exception    E_SUCCESS                               The method is successful.
313         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
314         * @exception    E_SYSTEM                                A system error has occurred.
315         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
316         * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
317         *                          The return value must be released by the caller.
318         * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container ),
319         *                               GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
320         */
321         Tizen::Base::Collection::ArrayListT <MediaContainerType>* GetSupportedContainerListN(void) const;
322
323         /**
324         * Sets the video format of the recorder. @n
325         * Initially, the default format from internal configuration is set.
326         *
327         * @return               An error code
328         * @param[in]    format                                  The video format @n
329         *                                                                               ::VIDEORECORDING_FORMAT_DEFAULT sets the system's default recording format.
330         * @exception    E_SUCCESS                               The method is successful.
331         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
332         * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
333         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
334         * @see                  GetFormat()
335         */
336         result SetFormat(VideoRecordingFormat format);
337
338         /**
339         * Gets the current format that has been set for the recorder.
340         *
341         * @return               The current video format, @n
342         *                          else the default format if SetFormat() is not called before this method
343         * @see                  SetFormat()
344         */
345         VideoRecordingFormat GetFormat(void) const;
346
347         /**
348         * Sets the mode of the recorder.
349         *
350         * @return               An error code
351         * @param[in]    mode                            The mode for the recording @n
352         *                                                                       The default mode is ::VIDEORECORDER_MODE_VIDEO_WITH_AUDIO.
353         * @exception    E_SUCCESS                       The method is successful.
354         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
355         * @exception    E_INVALID_ARG           The specified @c mode is not supported.
356         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
357         * @see                  GetMode()
358         */
359         result SetMode(VideoRecorderMode mode);
360
361         /**
362         * Gets the mode of the recorder.
363         *
364         * @return               The current mode
365         * @see                  SetMode()
366         */
367         VideoRecorderMode GetMode(void) const;
368
369         /**
370         * Sets the audio and video codecs, and the container of the recorder. @n
371         * Initially, the default codec and container format are set with the internal configuration.
372         *
373         * @return               An error code
374         * @param[in]    audioCodec                              The audio codec to set @n
375         *                                                                               ::CODEC_NONE makes the audio stream empty.
376         * @param[in]    videoCodec                              The video codec to set @n
377         *                                                                               ::CODEC_NONE cannot be set.
378         * @param[in]    container                               The media container to set
379         * @exception    E_SUCCESS                               The method is successful.
380         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
381         * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
382         * @exception    E_UNSUPPORTED_FORMAT    The specified container format is not supported.
383         * @exception    E_SYSTEM                                A system error has occurred.
384         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
385         * @remarks              If the audio codec is ::CODEC_NONE, the audio will be ignored, and only the video stream will be recorded. @n
386         *                               If the specified container does not support the specified codec, E_UNSUPPORTED_FORMAT may be thrown.
387         * @see                  GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
388         */
389         result SetFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container);
390
391         /**
392         * Gets the audio and video codecs, and the container of the recorder.
393         *
394         * @return               An error code
395         * @param[out]   audioCodec                      The retrieved audio codec
396         * @param[out]   videoCodec                      The retrieved video codec
397         * @param[out]   container                       The retrieved container
398         * @remarks              The default codecs and container are retrieved, if SetFormat( CodecType audioCodec, CodecType
399         *                               videoCodec, MediaContainerType container) is not called before calling this method.
400         * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container )
401         */
402         void GetFormat(CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const;
403
404         /**
405         * Sets the quality of the recorder.
406         *
407         * @return               An error code
408         * @param[in]    quality                         The quality of the recorder @n
409         *                                                                       The default quality is ::RECORDING_QUALITY_MEDIUM.
410         * @exception    E_SUCCESS                       The method is successful.
411         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
412         * @exception    E_INVALID_ARG           The specified @c quality is not supported.
413         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
414         * @see                  GetQuality()
415         */
416         result SetQuality(RecordingQuality quality);
417
418         /**
419         * Gets the quality of the recorder.
420         *
421         * @return               The current quality
422         * @see                  SetQuality()
423         */
424         RecordingQuality GetQuality(void) const;
425
426         /**
427         * Sets the recording resolution of the recorder. @n
428         * Initially, the default resolution from the internal configuration is set.
429         *
430         * @return               An error code
431         * @param[in]    resolution                      The recording resolution @n
432         *                                                                       It should be one of the listed strings extracted from
433         *                                                                       GetSupportedRecordingResolutionListN().
434         * @exception    E_SUCCESS                       The method is successful.
435         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
436         * @exception    E_OUT_OF_RANGE          The specified resolution is out of range.
437         * @exception    E_SYSTEM                        A system error has occurred.
438         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
439         *                               of this recording resolution.
440         * @see                  GetRecordingResolution(), GetSupportedRecordingResolutionListN()
441         */
442         result SetRecordingResolution(const Tizen::Graphics::Dimension& resolution);
443
444         /**
445         * Gets the recording resolution.
446         *
447         * @return               The recording resolution
448         * @see                  SetRecordingResolution(), GetSupportedRecordingResolutionListN()
449         */
450         Tizen::Graphics::Dimension GetRecordingResolution(void) const;
451
452         /**
453         * Gets a list of the supported video recorder resolutions. @n
454         * Each list item is a Tizen::Graphics::Dimension value.
455         *
456         * @return               A list of strings representing the supported video recorder resolutions, @n
457         *                               else an empty list if no recording resolution is supported or if an exception occurs
458         * @exception    E_SUCCESS                               The method is successful.
459         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
460         * @exception    E_SYSTEM                                A system error has occurred.
461         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
462         * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
463         *                               The return value must be released by the calling method. @n
464         *                               All items in the list must be released by the calling method. @n
465         *                               This method works after the input media source is initialized (for example, Camera::PowerOn()).
466         * @see                  SetRecordingResolution(), GetRecordingResolution()
467         */
468         Tizen::Base::Collection::IList* GetSupportedRecordingResolutionListN(void) const;
469
470         /**
471         * Gets the maximum supported frame rate of the input resolution.
472         *
473         * @return               The maximum frame rate of the input recording resolution
474         * @param[in]    dim                                             The preview resolution of the Camera
475         * @exception    E_SUCCESS                               The method is successful.
476         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
477         * @exception    E_INVALID_ARG                   The specified input resolution is invalid.
478         * @exception    E_SYSTEM                                A system error has occurred.
479         * @remark               The specific error code can be accessed using the GetLastResult method. @n
480         *                               This method works after the input media source is initialized (for example: Camera::PowerOn()).
481         * @see                  Camera::SetPreviewFrameRate()
482         */
483         int GetSupportedMaxFrameRate(const Tizen::Graphics::Dimension& dim) const;
484
485         /**
486         * Enables or disables the mute state of a recorder.
487         *
488         * @return               An error code
489         * @param[in]    mute                            Set to @c true to enable the mute state of the recorder, @n
490         *                                                                       else @c false
491         *                                                                  By default, the mute state is disabled.
492         * @exception    E_SUCCESS                       The method is successful.
493         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
494         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
495         * @remarks              The recording continues even in the mute state.
496         * @see                  IsMuted()
497         */
498         result SetMute(bool mute);
499
500         /**
501         * Checks whether the mute state of the recorder is enabled.
502         *
503         * @return               The mute state of the recorder
504         * @see                  SetMute()
505         */
506         bool IsMuted(void) const;
507
508         /**
509         * Sets the rotation of the recorder.
510         *
511         * @return               An error code
512         * @param[in]    rotation                        The rotation of the recorder
513         * @exception    E_SUCCESS                       The method is successful.
514         * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
515         * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
516         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
517         * @remarks              Before recording a video, the rotate information is tagged to the recording file. @n
518         *                     Using this information, a video player shows the video correctly regardless of the device orientation.
519         * @see                  GetRecordingRotation()
520         */
521         result SetRecordingRotation(RecordingRotation rotation);
522
523         /**
524         * Gets the rotation of the recorder.
525         *
526         * @return               The current rotation
527         * @see                  SetRecordingRotation()
528         */
529         RecordingRotation GetRecordingRotation(void) const;
530
531         /**
532         * Called when the mode is prepared to change.
533         *
534         * @return               An error code
535         * @param[in]     mode           recorder mode
536         */
537         result OnCameraCoordinatorModeChangePrepared(_CameraMode mode);
538
539         /**
540         * Called when the mode is changed.
541         *
542         * @return               An error code
543         * @param[in]     mode           recorder mode
544         */
545         result OnCameraCoordinatorModeChanged(_CameraMode mode);
546
547         /**
548         * Called when the other module is removed
549         *
550         * @return               An error code
551         */
552         result OnCameraCoordinatorOtherRemoved(void);
553
554         /**
555         * Sets the state.
556         *
557         * @param[in]    state              new _VideoRecorder's state
558         */
559         void SetState(RecorderState state);
560
561         /**
562         * Sets the recording time
563         *
564         * @param[in]    recTime                  recording time in milliseconds
565         */
566         void SetRecordingTime(long recTime);
567
568         /**
569         * Sets the recording size
570         *
571         * @param[in]    recSize                  recording size in bytes
572         */
573         void SetRecordingSize(long recSize);
574
575         /**
576         * Gets the device type
577         *
578         * @return               The current device type
579         */
580         _RecorderDeviceType GetDeviceType(void) const;
581
582         /**
583         * Called when the event is received from the %_ICameraCoordinatorListener object.
584         *
585         *
586         * @param[in]    previous                 Previous recorder state
587         * @param[in]    current          Current recorder state
588         * @param[in]    byPolicy                true if the state is changed by policy, otherewise false
589         * @param[in]    pUserData               User data
590         */
591         static void StateChangedCb(recorder_state_e previous, recorder_state_e current, bool byPolicy, void* pUserData);
592
593         /**
594         * Recording Status callback function
595         *
596         * @param[in]    elapsedTime       recording time elapsed
597         * @param[in]    fileSize                 size of file written
598         * @param[in]    pUserData               User data
599         */
600         static void RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData);
601
602         /**
603         * Audio stream callback function
604         *
605         * @param[in]    pStream           Stream data
606         * @param[in]    format          Sample format
607         * @param[in]    channel         Sample channel
608         * @param[in]    timeStampl      The time stamp
609         * @param[in]    pUserData               User data
610          */
611         static void AudioStreamCb(void* pStream, int size, audio_sample_type_e format, int channel, unsigned int timeStamp, void *pUserData);
612
613         /**
614         * Limit reached callback function
615         *
616         * @param[in]    type              Limit reached reason
617         * @param[in]    pUserData               User data
618          */
619         static void LimitReachedCb(recorder_recording_limit_type_e type, void *pUserData);
620
621         /**
622         * Message callback function
623         *
624         * @param[in]    error                   Error reason
625         * @param[in]    state           Error state
626         * @param[in]    pUserData               User data
627          */
628         static void ErrorCb(recorder_error_e error, recorder_state_e state, void *pUserData);
629
630         /**
631         * Message callback function
632         *
633         * @param[in]    policy          The policy which occurs the interruption
634         * @param[in]    previous                Previous recorder state
635         * @param[in]    current         Current recorder state
636         * @param[in]    pUserData               User data
637          */
638         static void InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData);
639
640         /**
641          * Gets the Impl instance.
642          *
643          * @return              The pointer to %_VideoRecorderImpl
644          * @param[in]   pVideoRecorder          The %VideoRecorder pointer
645          */
646         static _VideoRecorderImpl* GetInstance(VideoRecorder *pVideoRecorder);
647
648         /**
649          * Gets the Impl instance.
650          *
651          * @return              The pointer to %_VideoRecorderImpl
652          * @param[in]   pVideoRecorder          The %VideoRecorder pointer
653          */
654         static const _VideoRecorderImpl* GetInstance(const VideoRecorder *pVideoRecorder);
655
656         /**
657         * Adds the stream filter to process the audio stream data while recording.
658         *
659         * @return               An error code
660         * @param[in]    filter                  An instance of IAudioStreamFilter
661         * @exception    E_SUCCESS                       The method is successful.
662         * @exception    E_OBJ_ALREADY_EXIST     The filter already exists.
663         * @exception    E_OUT_OF_MEMORY     The memory is insufficient.
664         */
665         result AddAudioStreamFilter(IAudioStreamFilter& filter);
666
667         /**
668         * Removes the stream filter to stop processing the audio stream data.
669         *
670         * @return               An error code
671         * @param[in]    filter                  An instance of IAudioStreamFilter
672         * @exception    E_SUCCESS                       The method is successful.
673         * @exception    E_OBJ_NOT_FOUND        The filter is not found.
674         */
675         result RemoveAudioStreamFilter(IAudioStreamFilter& filter);
676
677 private:
678         /**
679         * Converts the error from recorder to Result.
680         *
681         * @return          An error code
682         * @param[in]    err                      recorder error
683         */
684         result ConvertResult(int err) const;
685
686         /**
687         * Converts codecType to String
688         *
689         * @return          void
690         * @param[in]    codecType       video codec type
691         * @param[out]   codec   Codec in string format
692         */
693         void GetCodecString(const CodecType videoCodec, Tizen::Base::String& codec) const;
694
695         /**
696         * Transfer the state.
697         *
698         * @return          An error code
699         * @param[in]    mmState                  recorder's destinationed state
700         * @param[in]    reason             state change reason
701         * @remarks      This method makes the recorder's state change. @n
702         *                       Sometimes, acccording to this, Recorder's state is changed.
703         */
704         result ChangeStateTo(recorder_state_e mmDestState, _RecorderStateChangeReason reason);
705
706         /**
707         * Checks the operation is for completing.
708         *
709         * @return               The state change reason
710         * @remarks      If the Cancel() is called, this value is false, because the Record() is not completed.
711         */
712         _RecorderStateChangeReason GetStateChangeReason(void) const;
713
714         /**
715         * Gets the recorder's state.
716         *
717         * @return                  The state
718         *
719         */
720         recorder_state_e GetMmState(void) const;
721
722         /**
723         * Get the event processing object.
724         *
725         * @return          The event processing object.
726         * @remarks      This event is working synchronously.
727         */
728         _VideoRecorderEvent* GetEvent(void) const;
729
730         /**
731         * Converts String to codecType
732         *
733         * @return          CodecType
734         * @param[in]    codec   Codec in string format
735         * @param[out]   audioCodec   Audio codec type
736         * @param[out]   videoCodec   Video codec type
737         * @param[out]container   Container type
738         */
739         void GetMediaType(const Base::String& codec, CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const;
740
741         /**
742         * Gets the new media type from the old type.
743         *
744         * @param[in]    format            recording type
745         * @param[out]   audioCodec        audiocodec type matching the input format
746         * @param[out]   videoCodec        videocodec type matching the input format
747         * @param[out]   container          container type matching the input format
748         *
749         */
750         void GetMediaType(VideoRecordingFormat format, CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const;
751
752         /**
753         * Re-load configuration.
754         *
755         * @return          An error code
756         * @param[in]    reload                            reload configuration field
757         * @exception    E_SUCCESS                               The method is successful.
758         * @exception    E_SYSTEM                                A system error has occurred.
759         * @remarks      Multiple configuration field can be set using reloadConf parameter appending.
760         */
761         result ReloadConfiguration(int reload);
762
763         /**
764         * Load default configuration.
765         *
766         * @return          An error code
767         * @param[in]    reload                            reload configuration field
768         * @exception    E_SUCCESS                               The method is successful.
769         * @exception    E_SYSTEM                                A system error has occurred.
770         */
771         result LoadDefaultConfiguration(int reload);
772
773         /**
774         * Sets the format of the recorder.
775         *
776         * @return               An error code
777         * @param[in]    audioCodec                              The audioCodec of the recorder
778         * @param[in]    videoCodec                              The videoCodec of the recorder
779         * @param[in]    container                               The container of the recorder
780         * @exception    E_SUCCESS                       The method is successful.
781         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
782         * @exception    E_INVALID_ARG           The specified @c quality is not supported.
783         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
784         * @see                  SetFormat()
785         */
786         result SetFormatAttr(CodecType audioCodec, CodecType videoCodec, MediaContainerType container);
787
788         /**
789         * Sets the quality of the recorder.
790         *
791         * @return               An error code
792         * @param[in]    quality                         The quality of the recorder
793         * @param[in]    audioCodec                              The audioCodec of the recorder
794         * @param[in]    videoCodec                              The videoCodec of the recorder
795         * @exception    E_SUCCESS                       The method is successful.
796         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
797         * @exception    E_INVALID_ARG           The specified @c quality is not supported.
798         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
799         * @see                  SetQuality()
800         */
801         result SetQualityAttr(RecordingQuality quality,         CodecType audioCodec, CodecType videoCodec);
802
803         /**
804         * Enables or disables the mute state of a recorder.
805         *
806         * @return               An error code
807         * @param[in]    mute                            Set to @c true to enable the mute state of the recorder, @n
808         *                                                                       else @c false
809         *                                                                  By default, the mute state is disabled.
810         * @exception    E_SUCCESS                       The method is successful.
811         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
812         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
813         * @remarks              The recording continues even in the mute state.
814         * @see                  SetMute()
815         */
816         result SetMuteAttr(bool mute);
817
818         /**
819         * Gets the time limit of the recording in milliseconds.
820         *
821         * @return               A @c long value indicating the maximum recording time in milliseconds @n
822         *                               else @c -1 if the recording has not started as yet
823         * @exception    E_SUCCESS                               The method is successful.
824         * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
825         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
826         * @remarks              The specific error code can be accessed using the GetLastResult() method.
827         * @see                  SetMaxRecordingTime()
828         */
829         result SetMaxRecordingTimeAttr(long msTime);
830
831         /**
832         * Sets the orientation of the recorder.
833         *
834         * @return               An error code
835         * @param[in]    rotation                        The rotation of the recorder
836         * @exception    E_SUCCESS                       The method is successful.
837         * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
838         * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
839         */
840         result SetRecordingOrientationAttr(RecordingRotation rotation);
841
842         /**
843         * Sets the callback of the recorder.
844         *
845         * @return               An error code
846         * @exception    E_SUCCESS                       The method is successful.
847         * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
848         * @exception    E_INVALID_ARG           The specified @c quality is not supported.
849         * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
850         * @see                  ReloadConfiguration()
851         */
852         result SetCallback(void);
853
854         _VideoRecorderImpl(const _VideoRecorderImpl& _VideoRecorderImpl);
855         _VideoRecorderImpl& operator =(const _VideoRecorderImpl& _VideoRecorderImpl);
856
857         _CameraCoordinator* __pCoordinator;
858         std::unique_ptr <_RecorderRef> __pRecorderRef;
859         std::unique_ptr <_VideoRecorderEvent> __pVideoRecorderEvent;
860         IVideoRecorderEventListener* __pVideoRecorderEventListener;
861         std::unique_ptr <_VideoSourceAdapter> __pVideoSourceAdapter;
862         bool __isConstructed;
863         RecorderState __state;
864         long __recTime;
865         long __recSize;
866         long __maxTime;
867         VideoRecordingFormat __format;
868         CodecType __audioCodec;
869         CodecType __videoCodec;
870         MediaContainerType __container;
871         VideoRecorderMode __mode;
872         RecordingQuality __quality;
873         bool __mute;
874         RecordingRotation __rotation;
875         _RecorderHandle __handle;
876         _RecorderDeviceType     __deviceType;
877         Tizen::Graphics::Dimension __recordingResolution;
878         camera_pixel_format_e __mmSourceFormat;
879         Tizen::Base::String __filePath;
880         _RecorderStateChangeReason __stateChangeReason;
881         std::unique_ptr <_AudioStreamCoordinator> __pAudioStreamCoordinator;
882         int __audioStreamTimeDuration;
883         bool __audioStreamCallback;
884
885 };
886
887 }}// Tizen::Media
888
889 #endif