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