Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:50:46 +0000 (01:50 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:50:46 +0000 (01:50 +0900)
231 files changed:
CMakeLists.txt [new file with mode: 0755]
LICENSE.APLv2.0 [new file with mode: 0644]
NOTICE [new file with mode: 0644]
inc/FMedia.h [new file with mode: 0644]
inc/FMediaAudioDecoder.h [new file with mode: 0644]
inc/FMediaAudioEncoder.h [new file with mode: 0644]
inc/FMediaAudioEqualizer.h [new file with mode: 0644]
inc/FMediaAudioIn.h [new file with mode: 0644]
inc/FMediaAudioManagerTypes.h [new file with mode: 0644]
inc/FMediaAudioOut.h [new file with mode: 0644]
inc/FMediaAudioRecorder.h [new file with mode: 0755]
inc/FMediaAudioRecorderTypes.h [new file with mode: 0755]
inc/FMediaAudioRouteInfo.h [new file with mode: 0644]
inc/FMediaAudioRouteManager.h [new file with mode: 0755]
inc/FMediaAudioSessionManager.h [new file with mode: 0755]
inc/FMediaAudioStreamInfo.h [new file with mode: 0644]
inc/FMediaAudioTypes.h [new file with mode: 0644]
inc/FMediaCamera.h [new file with mode: 0755]
inc/FMediaCameraTypes.h [new file with mode: 0755]
inc/FMediaCapability.h [new file with mode: 0755]
inc/FMediaCapabilityTypes.h [new file with mode: 0755]
inc/FMediaIAudioInEventListener.h [new file with mode: 0644]
inc/FMediaIAudioOutEventListener.h [new file with mode: 0644]
inc/FMediaIAudioRecorderEventListener.h [new file with mode: 0755]
inc/FMediaIAudioRouteEventListener.h [new file with mode: 0644]
inc/FMediaIAudioSessionEventListener.h [new file with mode: 0644]
inc/FMediaICameraEventListener.h [new file with mode: 0755]
inc/FMediaIPlayerEventListener.h [new file with mode: 0644]
inc/FMediaIPlayerProgressiveDownloadListener.h [new file with mode: 0644]
inc/FMediaIPlayerVideoEventListener.h [new file with mode: 0644]
inc/FMediaITonePlayerEventListener.h [new file with mode: 0644]
inc/FMediaIVideoRecorderEventListener.h [new file with mode: 0755]
inc/FMediaMediaStreamInfo.h [new file with mode: 0644]
inc/FMediaOpenal.h [new file with mode: 0644]
inc/FMediaPlayer.h [new file with mode: 0644]
inc/FMediaPlayerTypes.h [new file with mode: 0644]
inc/FMediaRecorderTypes.h [new file with mode: 0755]
inc/FMediaTone.h [new file with mode: 0644]
inc/FMediaTonePlayer.h [new file with mode: 0644]
inc/FMediaToneTypes.h [new file with mode: 0644]
inc/FMediaVideoDecoder.h [new file with mode: 0644]
inc/FMediaVideoEncoder.h [new file with mode: 0644]
inc/FMediaVideoFrameExtractor.h [new file with mode: 0644]
inc/FMediaVideoRecorder.h [new file with mode: 0755]
inc/FMediaVideoRecorderTypes.h [new file with mode: 0755]
inc/FMediaVideoStreamInfo.h [new file with mode: 0644]
inc/FMediaVoipAudioSessionManager.h [new file with mode: 0755]
osp-media.manifest [new file with mode: 0644]
osp-media.pc.in [new file with mode: 0755]
packaging/osp-media.spec [new file with mode: 0755]
src/FMediaAudioDecoder.cpp [new file with mode: 0644]
src/FMediaAudioEncoder.cpp [new file with mode: 0644]
src/FMediaAudioEqualizer.cpp [new file with mode: 0644]
src/FMediaAudioIn.cpp [new file with mode: 0644]
src/FMediaAudioOut.cpp [new file with mode: 0644]
src/FMediaAudioRecorder.cpp [new file with mode: 0755]
src/FMediaAudioRouteInfo.cpp [new file with mode: 0644]
src/FMediaAudioRouteManager.cpp [new file with mode: 0644]
src/FMediaAudioSessionManager.cpp [new file with mode: 0644]
src/FMediaAudioStreamInfo.cpp [new file with mode: 0644]
src/FMediaCamera.cpp [new file with mode: 0755]
src/FMediaCapability.cpp [new file with mode: 0644]
src/FMediaMediaStreamInfo.cpp [new file with mode: 0644]
src/FMediaPlayer.cpp [new file with mode: 0644]
src/FMediaTone.cpp [new file with mode: 0644]
src/FMediaTonePlayer.cpp [new file with mode: 0644]
src/FMediaVideoDecoder.cpp [new file with mode: 0644]
src/FMediaVideoEncoder.cpp [new file with mode: 0644]
src/FMediaVideoFrameExtractor.cpp [new file with mode: 0644]
src/FMediaVideoRecorder.cpp [new file with mode: 0755]
src/FMediaVideoStreamInfo.cpp [new file with mode: 0644]
src/FMediaVoipAudioSessionManager.cpp [new file with mode: 0644]
src/FMedia_AacDecoder.cpp [new file with mode: 0644]
src/FMedia_AacDecoder.h [new file with mode: 0644]
src/FMedia_AacEncoder.cpp [new file with mode: 0644]
src/FMedia_AacEncoder.h [new file with mode: 0644]
src/FMedia_AlawDecoder.cpp [new file with mode: 0644]
src/FMedia_AlawDecoder.h [new file with mode: 0644]
src/FMedia_AmrDecoder.cpp [new file with mode: 0644]
src/FMedia_AmrDecoder.h [new file with mode: 0644]
src/FMedia_AmrEncoder.cpp [new file with mode: 0644]
src/FMedia_AmrEncoder.h [new file with mode: 0644]
src/FMedia_AudioDecoderImpl.cpp [new file with mode: 0644]
src/FMedia_AudioDecoderImpl.h [new file with mode: 0644]
src/FMedia_AudioEncoderImpl.cpp [new file with mode: 0644]
src/FMedia_AudioEncoderImpl.h [new file with mode: 0644]
src/FMedia_AudioEqualizerImpl.cpp [new file with mode: 0644]
src/FMedia_AudioEqualizerImpl.h [new file with mode: 0644]
src/FMedia_AudioInEvent.cpp [new file with mode: 0644]
src/FMedia_AudioInEvent.h [new file with mode: 0644]
src/FMedia_AudioInEventArg.cpp [new file with mode: 0644]
src/FMedia_AudioInEventArg.h [new file with mode: 0644]
src/FMedia_AudioInImpl.cpp [new file with mode: 0644]
src/FMedia_AudioInImpl.h [new file with mode: 0644]
src/FMedia_AudioManagerConvert.cpp [new file with mode: 0644]
src/FMedia_AudioManagerConvert.h [new file with mode: 0644]
src/FMedia_AudioOutEvent.cpp [new file with mode: 0644]
src/FMedia_AudioOutEvent.h [new file with mode: 0644]
src/FMedia_AudioOutEventArg.cpp [new file with mode: 0644]
src/FMedia_AudioOutEventArg.h [new file with mode: 0644]
src/FMedia_AudioOutImpl.cpp [new file with mode: 0644]
src/FMedia_AudioRecorderEvent.cpp [new file with mode: 0755]
src/FMedia_AudioRecorderEvent.h [new file with mode: 0755]
src/FMedia_AudioRecorderImpl.cpp [new file with mode: 0755]
src/FMedia_AudioRecorderImpl.h [new file with mode: 0755]
src/FMedia_AudioRouteEvent.cpp [new file with mode: 0644]
src/FMedia_AudioRouteEvent.h [new file with mode: 0644]
src/FMedia_AudioRouteEventArg.cpp [new file with mode: 0644]
src/FMedia_AudioRouteEventArg.h [new file with mode: 0644]
src/FMedia_AudioRouteInfoImpl.cpp [new file with mode: 0644]
src/FMedia_AudioRouteInfoImpl.h [new file with mode: 0644]
src/FMedia_AudioRouteManagerImpl.cpp [new file with mode: 0644]
src/FMedia_AudioSessionEvent.cpp [new file with mode: 0644]
src/FMedia_AudioSessionEvent.h [new file with mode: 0644]
src/FMedia_AudioSessionEventArg.cpp [new file with mode: 0644]
src/FMedia_AudioSessionEventArg.h [new file with mode: 0644]
src/FMedia_AudioSessionManagerImpl.cpp [new file with mode: 0644]
src/FMedia_AudioStreamInfoImpl.cpp [new file with mode: 0644]
src/FMedia_AudioStreamInfoImpl.h [new file with mode: 0644]
src/FMedia_BitWriter.cpp [new file with mode: 0644]
src/FMedia_BitWriter.h [new file with mode: 0644]
src/FMedia_CamPtrUtil.h [new file with mode: 0755]
src/FMedia_CameraBuffer.cpp [new file with mode: 0755]
src/FMedia_CameraBuffer.h [new file with mode: 0755]
src/FMedia_CameraCapability.cpp [new file with mode: 0755]
src/FMedia_CameraCapability.h [new file with mode: 0755]
src/FMedia_CameraCapabilitySession.cpp [new file with mode: 0755]
src/FMedia_CameraCapabilitySession.h [new file with mode: 0755]
src/FMedia_CameraCoordinator.cpp [new file with mode: 0755]
src/FMedia_CameraCoordinator.h [new file with mode: 0755]
src/FMedia_CameraEvent.cpp [new file with mode: 0755]
src/FMedia_CameraEvent.h [new file with mode: 0755]
src/FMedia_CameraEventArg.cpp [new file with mode: 0755]
src/FMedia_CameraEventArg.h [new file with mode: 0755]
src/FMedia_CameraImpl.cpp [new file with mode: 0755]
src/FMedia_CameraImpl.h [new file with mode: 0755]
src/FMedia_CameraManager.cpp [new file with mode: 0755]
src/FMedia_CameraManager.h [new file with mode: 0755]
src/FMedia_CameraPreProcessUtil.cpp [new file with mode: 0755]
src/FMedia_CameraRefHelper.cpp [new file with mode: 0644]
src/FMedia_CameraRefHelper.h [new file with mode: 0644]
src/FMedia_CameraTypes.h [new file with mode: 0755]
src/FMedia_CameraUtil.cpp [new file with mode: 0755]
src/FMedia_CameraUtil.h [new file with mode: 0755]
src/FMedia_CapabilityCommon.cpp [new file with mode: 0644]
src/FMedia_CapabilityImpl.cpp [new file with mode: 0755]
src/FMedia_CapabilityTypes.h [new file with mode: 0755]
src/FMedia_CodecFactory.cpp [new file with mode: 0644]
src/FMedia_CodecFactory.h [new file with mode: 0644]
src/FMedia_FfmpegUtil.cpp [new file with mode: 0644]
src/FMedia_H263Decoder.cpp [new file with mode: 0644]
src/FMedia_H263Decoder.h [new file with mode: 0644]
src/FMedia_H263Encoder.cpp [new file with mode: 0644]
src/FMedia_H263Encoder.h [new file with mode: 0644]
src/FMedia_H264Decoder.cpp [new file with mode: 0644]
src/FMedia_H264Decoder.h [new file with mode: 0644]
src/FMedia_IAudioDecoder.h [new file with mode: 0644]
src/FMedia_IAudioEncoder.h [new file with mode: 0644]
src/FMedia_ICameraCoordinatorListener.h [new file with mode: 0755]
src/FMedia_ISessionManagerListener.h [new file with mode: 0644]
src/FMedia_IVideoDecoder.h [new file with mode: 0644]
src/FMedia_IVideoEncoder.h [new file with mode: 0644]
src/FMedia_MediaStreamInfoImpl.cpp [new file with mode: 0644]
src/FMedia_MediaStreamInfoImpl.h [new file with mode: 0644]
src/FMedia_Mp3Decoder.cpp [new file with mode: 0644]
src/FMedia_Mp3Decoder.h [new file with mode: 0644]
src/FMedia_Mpeg4Decoder.cpp [new file with mode: 0644]
src/FMedia_Mpeg4Decoder.h [new file with mode: 0644]
src/FMedia_Mpeg4Encoder.cpp [new file with mode: 0644]
src/FMedia_Mpeg4Encoder.h [new file with mode: 0644]
src/FMedia_PlayerEvent.cpp [new file with mode: 0644]
src/FMedia_PlayerEventArg.cpp [new file with mode: 0644]
src/FMedia_PlayerEventArg.h [new file with mode: 0644]
src/FMedia_PlayerImpl.cpp [new file with mode: 0644]
src/FMedia_PlayerProgressiveDownloadEvent.cpp [new file with mode: 0644]
src/FMedia_PlayerProgressiveDownloadEventArg.cpp [new file with mode: 0644]
src/FMedia_PlayerVideoEvent.cpp [new file with mode: 0644]
src/FMedia_PlayerVideoEventArg.cpp [new file with mode: 0644]
src/FMedia_PlayerVideoEventArg.h [new file with mode: 0644]
src/FMedia_RecorderCapability.cpp [new file with mode: 0755]
src/FMedia_RecorderCapability.h [new file with mode: 0755]
src/FMedia_RecorderEventArg.cpp [new file with mode: 0755]
src/FMedia_RecorderEventArg.h [new file with mode: 0755]
src/FMedia_RecorderManager.cpp [new file with mode: 0755]
src/FMedia_RecorderManager.h [new file with mode: 0755]
src/FMedia_RecorderSession.cpp [new file with mode: 0755]
src/FMedia_RecorderSession.h [new file with mode: 0755]
src/FMedia_RecorderTypes.h [new file with mode: 0755]
src/FMedia_RecorderUtil.cpp [new file with mode: 0755]
src/FMedia_RecorderUtil.h [new file with mode: 0755]
src/FMedia_ToneGenerator.cpp [new file with mode: 0644]
src/FMedia_ToneGenerator.h [new file with mode: 0644]
src/FMedia_TonePlayerEvent.cpp [new file with mode: 0644]
src/FMedia_TonePlayerEvent.h [new file with mode: 0644]
src/FMedia_TonePlayerEventArg.cpp [new file with mode: 0644]
src/FMedia_TonePlayerEventArg.h [new file with mode: 0644]
src/FMedia_TonePlayerImpl.cpp [new file with mode: 0644]
src/FMedia_TonePlayerImpl.h [new file with mode: 0644]
src/FMedia_UlawDecoder.cpp [new file with mode: 0644]
src/FMedia_UlawDecoder.h [new file with mode: 0644]
src/FMedia_VideoDecoderImpl.cpp [new file with mode: 0644]
src/FMedia_VideoDecoderImpl.h [new file with mode: 0644]
src/FMedia_VideoEncoderImpl.cpp [new file with mode: 0644]
src/FMedia_VideoEncoderImpl.h [new file with mode: 0644]
src/FMedia_VideoFrameExtractorImpl.cpp [new file with mode: 0644]
src/FMedia_VideoFrameExtractorImpl.h [new file with mode: 0644]
src/FMedia_VideoRecorderEvent.cpp [new file with mode: 0755]
src/FMedia_VideoRecorderEvent.h [new file with mode: 0755]
src/FMedia_VideoRecorderImpl.cpp [new file with mode: 0755]
src/FMedia_VideoRecorderImpl.h [new file with mode: 0755]
src/FMedia_VideoSourceAdapter.cpp [new file with mode: 0755]
src/FMedia_VideoSourceAdapter.h [new file with mode: 0755]
src/FMedia_VideoStreamInfoImpl.cpp [new file with mode: 0644]
src/FMedia_VideoStreamInfoImpl.h [new file with mode: 0644]
src/FMedia_VoipAudioSessionManagerImpl.cpp [new file with mode: 0644]
src/FMedia_VorbisDecoder.cpp [new file with mode: 0644]
src/FMedia_VorbisDecoder.h [new file with mode: 0644]
src/inc/FMedia_AudioOutImpl.h [new file with mode: 0644]
src/inc/FMedia_AudioRouteManagerImpl.h [new file with mode: 0644]
src/inc/FMedia_AudioSessionManagerImpl.h [new file with mode: 0644]
src/inc/FMedia_CameraPreProcessUtil.h [new file with mode: 0755]
src/inc/FMedia_CapabilityImpl.h [new file with mode: 0755]
src/inc/FMedia_FfmpegUtil.h [new file with mode: 0644]
src/inc/FMedia_PlayerEvent.h [new file with mode: 0644]
src/inc/FMedia_PlayerEventTypes.h [new file with mode: 0644]
src/inc/FMedia_PlayerImpl.h [new file with mode: 0644]
src/inc/FMedia_PlayerProgressiveDownloadEvent.h [new file with mode: 0644]
src/inc/FMedia_PlayerProgressiveDownloadEventArg.h [new file with mode: 0644]
src/inc/FMedia_PlayerVideoEvent.h [new file with mode: 0644]
src/inc/FMedia_PlayerVideoEventTypes.h [new file with mode: 0644]
src/inc/FMedia_VoipAudioSessionManagerImpl.h [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..aa44be2
--- /dev/null
@@ -0,0 +1,213 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target osp-media)
+
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+
+INCLUDE_DIRECTORIES(
+       inc
+       src
+       src/inc
+       /usr/include
+       /usr/include/curl
+       /usr/include/glib-2.0 
+       /usr/lib/glib-2.0/include
+       /usr/include/libxml2
+       /usr/include/media
+       /usr/include/osp
+       /usr/include/osp/app
+       /usr/include/osp/base   
+       /usr/include/osp/io
+       /usr/include/osp/graphics
+       /usr/include/osp/media
+       /usr/include/osp/net
+       /usr/include/osp/security
+       /usr/include/osp/system
+       /usr/include/osp/ui
+       /usr/include/opencore-amrnb
+       /usr/include/ogg
+       /usr/include/system
+       /usr/lib/dbus-1.0/include
+       /usr/include/e_dbus-1
+       /usr/include/elementary-1
+       /usr/include/efreet-1
+       /usr/include/ecore-1
+       /usr/include/edje-1
+       /usr/include/evas-1
+       /usr/include/eet-1
+       /usr/include/eina-1
+       /usr/include/eina-1/eina
+       /usr/include/ethumb-1
+       )
+
+SET (${this_target}_SOURCE_FILES
+       src/FMediaAudioIn.cpp
+       src/FMedia_AudioInEvent.cpp
+       src/FMedia_AudioInEventArg.cpp
+       src/FMedia_AudioInImpl.cpp
+       src/FMediaAudioOut.cpp
+       src/FMedia_AudioOutImpl.cpp
+       src/FMedia_AudioOutEvent.cpp
+       src/FMedia_AudioOutEventArg.cpp
+       src/FMediaTonePlayer.cpp
+       src/FMediaTone.cpp
+       src/FMedia_TonePlayerImpl.cpp
+       src/FMedia_ToneGenerator.cpp
+       src/FMedia_TonePlayerEvent.cpp
+       src/FMedia_TonePlayerEventArg.cpp
+       src/FMedia_CodecFactory.cpp
+       src/FMedia_H264Decoder.cpp
+       src/FMedia_H263Decoder.cpp
+       src/FMedia_Mpeg4Decoder.cpp
+       src/FMedia_VideoDecoderImpl.cpp
+       src/FMedia_H263Encoder.cpp
+       src/FMedia_Mpeg4Encoder.cpp
+       src/FMedia_VideoEncoderImpl.cpp
+       src/FMedia_BitWriter.cpp
+       src/FMedia_AacDecoder.cpp
+       src/FMedia_AacEncoder.cpp
+       src/FMedia_Mp3Decoder.cpp
+       src/FMedia_AmrDecoder.cpp
+       src/FMedia_VorbisDecoder.cpp
+       src/FMedia_AlawDecoder.cpp
+       src/FMedia_UlawDecoder.cpp
+       src/FMedia_AmrEncoder.cpp
+       src/FMedia_AudioDecoderImpl.cpp
+       src/FMedia_AudioEncoderImpl.cpp
+       src/FMediaAudioDecoder.cpp
+       src/FMediaAudioEncoder.cpp
+       src/FMediaVideoDecoder.cpp
+       src/FMediaVideoEncoder.cpp
+       src/FMediaCapability.cpp
+       src/FMedia_CapabilityImpl.cpp
+       src/FMedia_CapabilityCommon.cpp
+       src/FMedia_CameraRefHelper.cpp
+       src/FMedia_CameraCapability.cpp
+       src/FMedia_CameraCoordinator.cpp
+       src/FMediaCamera.cpp
+       src/FMedia_CameraImpl.cpp
+       src/FMedia_CameraEvent.cpp
+       src/FMedia_CameraEventArg.cpp
+       src/FMedia_CameraUtil.cpp
+       src/FMedia_CameraManager.cpp
+       src/FMedia_CameraCapabilitySession.cpp
+       src/FMedia_CameraPreProcessUtil.cpp
+       src/FMedia_CameraBuffer.cpp
+       src/FMediaAudioRecorder.cpp
+       src/FMedia_AudioRecorderImpl.cpp
+       src/FMedia_AudioRecorderEvent.cpp
+       src/FMedia_FfmpegUtil.cpp
+       src/FMedia_RecorderEventArg.cpp
+       src/FMedia_RecorderCapability.cpp
+       src/FMedia_RecorderUtil.cpp
+       src/FMediaVideoRecorder.cpp
+       src/FMedia_VideoRecorderImpl.cpp
+       src/FMedia_VideoRecorderEvent.cpp
+       src/FMedia_VideoSourceAdapter.cpp
+       src/FMedia_RecorderManager.cpp
+       src/FMedia_RecorderSession.cpp
+       src/FMediaPlayer.cpp
+       src/FMedia_PlayerImpl.cpp
+       src/FMedia_PlayerEvent.cpp
+       src/FMedia_PlayerEventArg.cpp
+       src/FMedia_PlayerVideoEvent.cpp
+       src/FMedia_PlayerVideoEventArg.cpp
+       src/FMedia_PlayerProgressiveDownloadEvent.cpp
+       src/FMedia_PlayerProgressiveDownloadEventArg.cpp
+       src/FMediaAudioStreamInfo.cpp
+       src/FMediaVideoStreamInfo.cpp
+       src/FMediaMediaStreamInfo.cpp
+       src/FMedia_AudioStreamInfoImpl.cpp
+       src/FMedia_VideoStreamInfoImpl.cpp
+       src/FMedia_MediaStreamInfoImpl.cpp
+       src/FMediaAudioRouteInfo.cpp
+       src/FMedia_AudioRouteInfoImpl.cpp
+       src/FMediaAudioRouteManager.cpp
+       src/FMedia_AudioRouteManagerImpl.cpp
+       src/FMedia_AudioRouteEvent.cpp
+       src/FMedia_AudioRouteEventArg.cpp
+       src/FMediaVoipAudioSessionManager.cpp
+       src/FMedia_VoipAudioSessionManagerImpl.cpp
+       src/FMediaAudioSessionManager.cpp
+       src/FMedia_AudioSessionManagerImpl.cpp
+       src/FMedia_AudioSessionEvent.cpp
+       src/FMedia_AudioSessionEventArg.cpp
+       src/FMedia_AudioManagerConvert.cpp
+       src/FMediaAudioEqualizer.cpp
+       src/FMedia_AudioEqualizerImpl.cpp
+       src/FMediaVideoFrameExtractor.cpp
+       src/FMedia_VideoFrameExtractorImpl.cpp
+)
+
+## Definitions
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed")
+
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-image-core" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-uifw" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-image" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-net" )
+TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-media-audio-io")
+TARGET_LINK_LIBRARIES(${this_target} "-lxml2" )
+TARGET_LINK_LIBRARIES(${this_target} "-lexif" )
+TARGET_LINK_LIBRARIES(${this_target} "-lswscale" )
+TARGET_LINK_LIBRARIES(${this_target} "-lavcodec" )
+TARGET_LINK_LIBRARIES(${this_target} "-lavutil" )
+TARGET_LINK_LIBRARIES(${this_target} "-lvorbis" )
+TARGET_LINK_LIBRARIES(${this_target} "-logg" )
+TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
+TARGET_LINK_LIBRARIES(${this_target} "-lopencore-amrnb" )
+TARGET_LINK_LIBRARIES(${this_target} "-lmmffile" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-media-player")
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-media-sound-manager")
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-media-camera" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-media-recorder" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-media-metadata-extractor")
+TARGET_LINK_LIBRARIES(${this_target} "-levas")
+
+SET_TARGET_PROPERTIES(${this_target} 
+       PROPERTIES 
+       VERSION ${FULLVER}
+       SOVERSION ${MAJORVER}
+       CLEAN_DIRECT_OUTPUT 1
+       )
+
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+    POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} 
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+               COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+    COMMENT "strip ${this_target}"
+               )   
+
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp
+               FILES_MATCHING PATTERN "*.so*" 
+               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                      
+                    GROUP_EXECUTE GROUP_READ
+                    WORLD_EXECUTE WORLD_READ)
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug 
+               FILES_MATCHING PATTERN "*"
+               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                                          
+                                       GROUP_EXECUTE GROUP_READ
+                                       WORLD_EXECUTE WORLD_READ)
+
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/inc/ DESTINATION include/osp/media FILES_MATCHING PATTERN "*.h")
+
+# pkgconfig file
+CONFIGURE_FILE(${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION lib/pkgconfig)
diff --git a/LICENSE.APLv2.0 b/LICENSE.APLv2.0
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/inc/FMedia.h b/inc/FMedia.h
new file mode 100644 (file)
index 0000000..5faeead
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia.h
+ * @brief                      This is the header file for the %Media namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Tizen::Media namespace.
+ */
+
+#ifndef _FMEDIA_H_
+#define _FMEDIA_H_
+
+// Include
+#include "FMediaAudioDecoder.h"
+
+#include "FMediaAudioEncoder.h"
+
+#include "FMediaAudioEqualizer.h"
+
+#include "FMediaAudioIn.h"
+
+#include "FMediaAudioOut.h"
+
+#include "FMediaAudioRecorder.h"
+
+#include "FMediaAudioRouteInfo.h"
+
+#include "FMediaAudioRouteManager.h"
+
+#include "FMediaAudioSessionManager.h"
+
+#include "FMediaCapability.h"
+
+#include "FMediaCamera.h"
+
+#include "FMediaGifDecoder.h"
+
+#include "FMediaImage.h"
+
+#include "FMediaImageBuffer.h"
+
+#include "FMediaImageUtil.h"
+
+#include "FMediaMediaStreamInfo.h"
+
+#include "FMediaPlayer.h"
+
+#include "FMediaTonePlayer.h"
+
+#include "FMediaTypes.h"
+
+#include "FMediaVoipAudioSessionManager.h"
+
+#include "FMediaVideoDecoder.h"
+
+#include "FMediaVideoEncoder.h"
+
+#include "FMediaVideoFrameExtractor.h"
+
+#include "FMediaVideoRecorder.h"
+
+/**
+ * @namespace  Tizen::Media
+ * @brief      This namespace contains classes and interfaces for media processing services.
+ *
+ * @since              2.0
+ *
+ * @remarks    @b Header @b %file: @b \#include @b <FMedia.h> @n
+ *                     @b Library : @b osp-media, @b osp-image
+ *
+ * The %Media namespace defines interfaces and classes that
+ * lets the application to integrate with the audio, video, and image processing functions easily, including:
+ *  - Encoding and decoding images and videos
+ *  - Playing audio and video from media files stored on a device or streaming over the network
+ *  - Getting meta-data from audio/video stream data
+ *  - Recording audio and video
+ *  - Using the camera to display a live preview and capture a still image
+ *  - Using codec to encode and decode the audio/video data
+ *  - Playing the tone(s)
+ *
+ * For more information on the %Media namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/media/media_namespace.htm">Media Guide</a>.
+ *
+ * The following diagram illustrates the relationships between the classes belonging to the %Media namespace.
+ * @image html media_using_the_apis_classdiagram.png
+ *
+ */
+/**
+* @namespace   Tizen::Media
+* @brief               This namespace contains classes and interfaces for media processing services.
+*
+*/
+namespace Tizen
+{
+namespace Media
+{
+
+
+}
+
+}; // Tizen::Media
+
+#endif // _FMEDIA_H_
diff --git a/inc/FMediaAudioDecoder.h b/inc/FMediaAudioDecoder.h
new file mode 100644 (file)
index 0000000..dc1ca3d
--- /dev/null
@@ -0,0 +1,311 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMediaAudioDecoder.h
+ * @brief  This is the header file for the %AudioDecoder class.
+ *
+ * This header file contains the declarations of the %AudioDecoder class.
+ */
+
+#ifndef _FMEDIA_AUDIO_DECODER_H_
+#define _FMEDIA_AUDIO_DECODER_H_
+
+#include <FBase.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class AudioDecoder
+ * @brief This class decodes a compressed audio stream to a raw audio data.
+ *
+ * @since              2.0
+ *
+ * @remarks
+ * Source data of AAC and AMR decoder must be raw compressed data without header.
+ *
+ *  The %AudioDecoder class decodes a compressed audio stream to a raw audio data.
+ *  The audio decoding formats, such as CODEC_MP3, CODEC_AAC, and CODEC_AMR_NB, are supported.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_audio.htm">Encoding and Decoding Audio</a>.
+ *
+ * The following example demonstrates how to use the %AudioDecoder class in MP3 decoding.
+ *
+ *
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FIo.h>
+ * #include <FApp.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Io;
+ * using namespace Tizen::Media;
+ *
+ * #define DST_BUF_SIZE   (1024*16)
+ *
+ * result
+ * AudioDecoderSample(void)
+ * {
+ *      AudioDecoder dec;
+ *      result r;
+ *      ByteBuffer srcBuf, dstBuf;
+ *      File srcFile;
+ *      FileAttributes attr;
+ *      int sampleRate;
+ *      AudioChannelType channelType;
+ *      AudioSampleType sampleType;
+ *      String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp3";
+ *
+ *      // Loads src file into buffer
+ *      File::GetAttributes(filePath, attr);
+ *      srcBuf.Construct(attr.GetFileSize());
+ *      srcFile.Construct(filePath, "rb");
+ *      srcFile.Read(srcBuf);
+ *      srcBuf.Flip();  // Sets the position of source buffer to zero
+ *
+ *      // Adds code that skips ID3 tag in srcBuf
+ *
+ *      dstBuf.Construct(DST_BUF_SIZE);
+ *
+ *      dec.Construct(CODEC_MP3);
+ *      r = dec.Probe(srcBuf, sampleType, channelType, sampleRate);
+ *      if (IsFailed(r))
+ *      {
+ *              return r;
+ *      }
+ *
+ *      while (srcBuf.GetRemaining() > 0)
+ *      {
+ *              r = dec.Decode(srcBuf, dstBuf);
+ *              if (IsFailed(r))
+ *              {
+ *                      break;
+ *              }
+ *
+ *              // Adds code handling decoded data
+ *
+ *              dstBuf.Clear();
+ *      }
+ *
+ *      return r;
+ * }
+ * @endcode
+ */
+
+class _OSP_EXPORT_ AudioDecoder
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        *      The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        *      @since          2.0
+        *
+        *      @remarks        After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        *      @see            Construct()
+        */
+       AudioDecoder(void);
+
+       /**
+        *      This destructor overrides Tizen::Base::Object::~Object().
+        *
+        *      @since          2.0
+        */
+       virtual ~AudioDecoder(void);
+
+       /**
+        *      Initializes this instance of %AudioDecoder with the specified parameters. @n
+        *  The following example demonstrates how to use the %Construct() method as a simple decoder construction with optional parameters.
+        *  @code
+        *
+        * result OpenAacDecoder(void)
+        * {
+        *       AudioDecoder dec;
+        *       result r;
+        *       HashMap option;
+        *
+        *       option.Construct();
+        *       option.Add(*(new Integer(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE)), *(new Integer(AUDIO_CHANNEL_TYPE_STEREO)));
+        *       option.Add(*(new Integer(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE)), *(new Integer(44100)));
+        *
+        *       r = dec.Construct(CODEC_AAC, &option);
+        *       if (IsFailed(r))
+        *       {
+        *              goto CATCH;
+        *       }
+        *
+        *      return E_SUCCESS;
+        * CATCH:
+        *       return r;
+        * }
+        * @endcode
+        *
+        *      @since          2.0
+        *
+        *      @return         An error code
+        *      @param[in]      type                            The codec type
+        *      @param[in]      pOption                         The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_audio.htm#decoding_audio">optional parameters</a>
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_UNSUPPORTED_CODEC The specified decoder is not supported.
+        *      @exception      E_OUT_OF_RANGE          A specified input parameter has a value that is out of range.
+        *      @exception      E_OUT_OF_MEMORY         The memory is insufficient. 
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        *      @remarks        The key type of the specified option is Tizen::Base::Integer, and the value type varies depending on the key type.
+        */
+       result Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption = null);
+
+       /**
+        *
+        *      Probes whether the audio data can be decoded.
+        *
+        *      @since          2.0
+        *
+        *      @return  An error code
+        *      @param[in]      srcBuf                                  The source buffer that stores the compressed audio data
+        *      @param[out]     sampleType                              The sample type of the decoded audio sample
+        *      @param[out]     channelType                             The channel type of the decoded audio sample
+        *      @param[out]     sampleRate                              The sample rate of the decoded audio sample
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_ARG                   A specified source buffer is invalid.
+        *      @exception      E_UNSUPPORTED_FORMAT    The input data is not in a supported format.
+        *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient to decode the sample.
+        *      @exception  E_SYSTEM                            A system error has occurred.
+        *      @remarks        This method resets the internal state of an audio decoder.
+        */
+       result Probe(const Tizen::Base::ByteBuffer& srcBuf, AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate);
+
+       /**
+        *
+        *      Decodes the audio data from the source buffer and stores the decoded data into a destination buffer. @n
+        *      The %AudioDecoder class reads and decodes the audio data from the source buffer
+        *      and it also writes the decoded audio data into the destination buffer. @n
+        *  The position of the source buffer is moved to the end of the consumed data and the position of the destination buffer is moved to the end of the written data.
+        *
+        *      @since          2.0
+        *
+        *      @return  An error code
+        *      @param[in]      srcBuf                  The source buffer that stores the compressed audio data
+        *      @param[out]     dstBuf                  The destination buffer that stores the decoded audio data
+        *      @exception      E_SUCCESS               The method is successful.
+        *      @exception      E_INVALID_ARG                   A specified source or destination buffer is invalid.
+        *      @exception      E_UNSUPPORTED_FORMAT    The input data is not in a supported format.
+        *      @exception      E_OUT_OF_MEMORY                 The specified destination buffer is insufficient to store the decoded data.
+        *      @exception  E_SYSTEM                            A system error has occurred.
+        */
+       result Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf);
+
+       /**
+        *      Resets the internal state of the audio decoder to process a new audio stream.
+        *
+        *      @since          2.0
+        *
+        *      @return         An error code
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        */
+       result Reset(void);
+
+       /**
+        *      Gets the specified property type value of this instance.
+        *
+        *      @since          2.0
+        *
+        *      @return          An error code
+        *      @param[in]              key                                     The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_audio.htm#decoding_audio">key</a> for which the value is obtained
+        *      @param[out]             value                   The obtained property value
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_OBJ_NOT_FOUND                 The specified @c key is not found.
+        *      @exception      E_INVALID_ARG                   The specified @c key is not supported.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @remarks        The property whose value type is enum can be obtained using this method.
+        */
+       result GetValue(MediaPropertyType key, int& value) const;
+
+       /**
+        *      Gets the supported properties of this instance.
+        *
+        *      @since          2.0
+        *
+        *      @return  A list of supported properties, @n
+        *                              else @c null if no property is supported or if an exception occurs
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @exception      E_OBJ_NOT_FOUND                 This instance does not support any property.
+        *      @remarks        The specific error code can be accessed using the GetLastResult() method. @n
+        *                              The return value must be deleted.
+        */
+       Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       /**
+        *      Checks whether the specified property type is supported.
+        *
+        *      @since          2.0
+        *
+        *      @return  @c true if the property is supported, @n
+        *                              else @c false
+        *      @param[in]              key                             The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_audio.htm#decoding_audio">key</a> for which the value is obtained
+        *      @exception      E_SUCCESS                   The method is successful.
+        *      @exception      E_OBJ_NOT_FOUND         The specified @c key is not found.
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        *      @remarks        The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool IsPropertySupported(MediaPropertyType key) const;
+
+       /**
+       * Gets a list of the supported codecs.
+       *
+       * @since                2.0
+       *
+       * @return     A list of the codecs supported by the %AudioDecoder class, @n
+       *             else @c null if an exception occurs
+       * @exception  E_SUCCESS             The method is successful.
+       * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+       * @remarks    The specific error code can be accessed using the GetLastResult() method.
+       * @remarks    The return value must be deleted by the caller.
+       */
+       static Tizen::Base::Collection::IListT<CodecType>* GetSupportedCodecListN(void);
+
+private:
+       /**
+       *       The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       *
+       *       @since          2.0
+       *
+       */
+       AudioDecoder(const AudioDecoder& rhs);
+       /**
+       *       The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       *
+       *       @since          2.0
+       *
+       */
+       AudioDecoder& operator =(const AudioDecoder& rhs);
+
+       friend class _AudioDecoderImpl;
+       class _AudioDecoderImpl* __pImpl;
+};
+
+}} // Tizen::Media
+
+#endif // _FMEDIA_AUDIODECODER_H_
diff --git a/inc/FMediaAudioEncoder.h b/inc/FMediaAudioEncoder.h
new file mode 100644 (file)
index 0000000..6f8b494
--- /dev/null
@@ -0,0 +1,218 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FMediaAudioEncoder.h
+ * @brief      This is the header file for the %AudioEncoder class.
+ *
+ * This header file contains the declarations of the %Tizen::Media::AudioEncoder class.
+ */
+
+#ifndef _FMEDIA_AUDIO_ENCODER_H_
+#define _FMEDIA_AUDIO_ENCODER_H_
+
+#include <FBase.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class AudioEncoder
+ * @brief This class encodes raw audio data into compressed audio stream.
+ *
+ * @since              2.0
+ *
+ * The %AudioEncoder class encodes raw audio data into compressed audio stream.
+ * It supports the audio encoding formats such as CODE_AAC and CODEC_AMR_NB. @n
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_audio.htm">Encoding and Decoding Audio</a>. @n
+ *
+ * The following example demonstrates how to use the %AudioEncoder class in Advanced Audio Coding (AAC) encoding.
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FIo.h>
+ * #include <FApp.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Io;
+ * using namespace Tizen::Media;
+ *
+ * #define DST_BUF_SIZE   (1024*8)
+ *
+ * result
+ * AudioEncoderSample(void)
+ * {
+ *      AudioEncoder enc;
+ *      result r;
+ *      ByteBuffer srcBuf, dstBuf;
+ *      File srcFile;
+ *      FileAttributes attr;
+ *      int sampleRate = 44100;
+ *      AudioChannelType channelType = AUDIO_CHANNEL_TYPE_STEREO;
+ *      int bitRate = 128000; // 128Kbps
+ *      HashMap option;
+ *      String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.wav";
+ *
+ *      option.Construct();
+ *      option.Add(*(new Integer(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE)), *(new Integer(channelType)));
+ *      option.Add(*(new Integer(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE)), *(new Integer(sampleRate)));
+ *      option.Add(*(new Integer(MEDIA_PROPERTY_AUDIO_BIT_RATE)), *(new Integer(bitRate)));
+ *
+ *      // Loads src file into buffer
+ *      File::GetAttributes(filePath, attr);
+ *      srcBuf.Construct(attr.GetFileSize());
+ *      srcFile.Construct(filePath, L"rb");
+ *      srcFile.Read(srcBuf);
+ *      srcBuf.Flip();  // Sets the position of source buffer to zero
+ *
+ *      // Adds code that skips WAV header in srcBuf
+ *
+ *      dstBuf.Construct(DST_BUF_SIZE);
+ *
+ *      enc.Construct(CODEC_AAC, &option);
+ *
+ *      while (srcBuf.GetRemaining() > 0)
+ *      {
+ *              r = enc.Encode(srcBuf, dstBuf);
+ *              if (IsFailed(r))
+ *              {
+ *                      break;
+ *              }
+ *              // Adds code handling encoded data
+ *
+ *              dstBuf.Clear();
+ *      }
+ *
+ *      return r;
+ * }
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ AudioEncoder
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        *      The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        *      @since          2.0
+        *
+        *      @remarks        After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        *      @see            Construct()
+        */
+       AudioEncoder(void);
+
+       /**
+        *      This destructor overrides Tizen::Base::Object::~Object().
+        *
+        *      @since          2.0
+        */
+       virtual ~AudioEncoder(void);
+
+       /**
+        *      Initializes this instance of %AudioEncoder with the specified parameters.
+        *
+        *      @since          2.0
+        *
+        *      @return         An error code
+        *      @param[in]      type                            The codec type
+        *      @param[in]      pOption                         The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_audio.htm#encoding_audio">optional parameters</a>
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_UNSUPPORTED_CODEC The specified encoder is not supported.
+        *      @exception      E_OUT_OF_RANGE          A specified input parameter has a value that is out of range.
+        *      @exception      E_OUT_OF_MEMORY         The memory is insufficient. 
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        *      @remarks        The key type of the specified option is Tizen::Base::Integer, and the value type varies depending on the key type.
+        */
+       result Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption = null);
+
+
+public:
+       /**
+        *      Encodes the audio data from the source buffer and stores the encoded data into the destination buffer. @n
+        *      The %AudioEncoder class reads the audio data from the source buffer
+        *  and it writes the encoded audio data into the destination buffer.
+        *  The position of the source buffer is moved to the end of the consumed data and the position of the destination buffer is moved to the end of the written data.
+        *      If there is no space in the destination buffer, the encoder returns @c E_INVALID_ARG.
+        *
+        *      @since          2.0
+        *
+        *      @return  An error code
+        *      @param[in]      srcBuf                                  The source buffer that stores the uncompressed audio data
+        *      @param[out]     dstBuf                                  The destination buffer that stores the encoded audio data
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_ARG                   The specified source or destination buffer is invalid.
+        *      @exception      E_OUT_OF_MEMORY                 The specified destination buffer is not sufficient to store the decoded data.
+        *      @exception  E_SYSTEM                            A system error has occurred.
+        */
+       result Encode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf);
+
+       /**
+        *      Resets the internal state of the audio encoder to process a new audio stream.
+        *
+        *      @since          2.0
+        *
+        *      @return         An error code
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        */
+       result Reset(void);
+
+       /**
+       * Gets a list of the supported codecs.
+       *
+       * @since                2.0
+       *
+       * @return     A list of the codecs supported by the %AudioEncoder class, @n
+       *             else @c null if an exception occurs
+       * @exception  E_SUCCESS             The method is successful.
+       * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+       * @remarks    The specific error code can be accessed using the GetLastResult() method.
+       * @remarks    The return value must be deleted by the caller.
+       */
+       static Tizen::Base::Collection::IListT<CodecType>* GetSupportedCodecListN(void);
+
+private:
+       /**
+        *      The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        *      @since          2.0
+        *
+        */
+       AudioEncoder(const AudioEncoder& enc);
+
+       /**
+        *      The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        *      @since          2.0
+        *
+        */
+       AudioEncoder& operator =(const AudioEncoder& enc);
+
+       friend class _AudioEncoderImpl;
+       class _AudioEncoderImpl* __pImpl;
+};
+
+}} // Tizen::Media
+
+
+#endif
diff --git a/inc/FMediaAudioEqualizer.h b/inc/FMediaAudioEqualizer.h
new file mode 100644 (file)
index 0000000..05033d0
--- /dev/null
@@ -0,0 +1,362 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMediaAudioEqualizer.h
+ * @brief  This is the header file for the %AudioEqualizer class.
+ * This header file contains the declarations of the %AudioEqualizer class.
+ */
+
+#ifndef _FMEDIA_AUDIO_EQUALIZER_H_
+#define _FMEDIA_AUDIO_EQUALIZER_H_
+
+#include <FBaseObject.h>
+#include <FMediaPlayer.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @if VISPARTNER
+ * @class AudioEqualizer
+ * This class is used to apply audio equalizer settings
+ *
+ * @since              2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * @visibility         partner
+ *
+ * @remarks            The functionality includes querying and setting the levels of the different frequency bands.
+ *
+ * The following example demonstrates how to use the %AudioEqualizer class.
+ *
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Media;
+ *
+ * class EqualizerSample
+ *     : public Tizen::Media::IPlayerEventListener
+  * {
+ * public:
+ *     result Initialize(void);
+ *     result Play(void);
+ *     result Equalize(void);
+ *     void Stop(void);
+ *
+ * protected:
+ *     // IPlayerEventListener
+ *     virtual void OnPlayerOpened(result r) {}
+ *     virtual void OnPlayerEndOfClip(void) {}
+ *     virtual void OnPlayerBuffering(int percent) {}
+ *     virtual void OnPlayerErrorOccurred(PlayerErrorReason r) {}
+ *     virtual void OnPlayerInterrupted(void) {}
+ *     virtual void OnPlayerReleased(void) {}
+ *     virtual void OnPlayerSeekCompleted(result r) {}
+ *     virtual void OnPlayerAudioFocusChanged (void) {}
+ *
+ *
+ * private:
+ *     Player __player;
+ *     AudioEqualizer __audioEqualizer;
+ * };
+ *
+ * result
+ * EqualizerSample::Initialize(void)
+ * {
+ *     result r = E_SUCCESS;
+ *     String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp3";
+ *
+ *     r = __player.Construct(*this);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *        __audioEqualizer.Construct(__player)
+ *
+ *     r = __player.OpenFile(filePath, false);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *     return r;
+ * }
+ *
+ *
+ * result
+ * EqualizerSample::Play(void)
+ * {
+  * result r = E_SUCCESS;
+  * r = __player.Play();
+  * return r;
+ * }
+ *
+ * result
+ * EqualizerSample::Equalize(void)
+ * {
+ *       result r = E_SUCCESS;
+ *    int count;
+ *    int level;
+ *    int minValue;
+ *    int maxValue;
+ *
+ *       count = __audioEqualizer.GetBandCount();
+ *
+ *       for (int index = 0; index < count; index++)
+ *       {
+ *         r = __audioEqualizer.GetBandLevelRange(index, minValue, maxValue);
+ *      if (IsFailed(r))
+ *      {
+ *             return r;
+ *      }
+ *     level = (minValue + maxValue) / 2;
+ *             r = __audioEqualizer.SetBandLevel(index, level);
+ *      if (IsFailed(r))
+ *             {
+ *             return r;
+ *             }
+ *       }
+ *       return r;
+ * }
+ *
+ *
+ * void
+ * EqualizerSample::Stop(void)
+ * {
+ *     __audioEqualizer.ResetAllToDefault();
+ *     __player.Stop();
+ *     __player.Close();
+ * }
+ *
+ * @endcode
+ *
+ * @endif
+ */
+
+class _OSP_EXPORT_ AudioEqualizer
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       * @if VISPARTNER
+       * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+       *
+       * @since                2.0
+       *
+       * @visibility           partner
+       *
+       * @remarks      After creating an instance of this class, the Construct() method must be called explicitly to
+       *               initialize this instance.
+       * @see          Construct()
+       * @endif
+       */
+       AudioEqualizer(void);
+       
+       /**
+       * @if VISPARTNER
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since                2.0
+       *
+       * @visibility           partner
+       * @endif
+       */
+       virtual ~AudioEqualizer(void);
+
+       /**
+       * @if VISPARTNER
+       * Initializes this instance of %AudioEqualizer with the given %Player.
+       *
+       * @since                2.0
+       *
+       * @visibility           partner
+       *
+       * @return               An error code
+       * @param[in]    player                                                                          The player instance that the equalizer will be applied.
+       * @exception    E_SUCCESS                                                                       The method is successful.
+       * @exception    E_OUT_OF_MEMORY                                 The memory is insufficient.
+       * @exception    E_INVALID_ARG                                                   The specified input parameter is invalid.
+       * @exception    E_UNSUPPORTED_OPERATION         This device does not support the audio equalizer feature.
+       * @remarks If player is deleted, then this instance cannot be used properly.
+       * @endif
+       */
+       result Construct(Player& player);
+
+       /**
+       * @if VISPARTNER
+       * Gets the count of bands that equalizer supports.
+       *
+       * @since                2.0
+       *
+       * @visibility     partner
+       *
+       * @return               The count of bands, @n
+                                               else @c -1 if it fails.
+       * @exception    E_SUCCESS                                                               The method is successful.
+       * @exception    E_INVALID_OPERATION                                     The associated audio instance is no longer valid.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.
+       * @endif
+       */
+       int GetBandCount(void) const;
+
+       /**
+       * @if VISPARTNER
+       * Gets the level range of the frequency band
+       *
+       * @since                2.0
+       *
+       * @visibility           partner
+       *
+       * @return                       An error code
+       * @param[in]            index                                           Index of the frequency band. @n
+                                                                                                       Index starts from 0.
+       * @param[out]   minValue                                Minimum level of the frequency band specified via index
+       * @param[out]   maxValue                                Maximum level of the frequency band specified via index
+       * @exception            E_SUCCESS                                       The method is successful
+       * @exception            E_INVALID_ARG                           The specified input parameter is invalid
+       * @exception            E_INVALID_OPERATION             The associated audio instance is no longer valid.
+       * @see GetBandCount()
+       * @endif
+       */
+       result GetBandLevelRange(int index, int& minValue, int& maxValue) const;
+
+       /**
+       * @if VISPARTNER
+       * Sets the level of the frequency band specified by index
+       *
+       * @since                2.0
+       *
+       * @visibility           partner
+       *
+       * @return                       An error code
+       * @param[in]            index                                                   Index of the frequency band. @n
+                                                                                                       Index starts from 0.
+       * @param[in]            level                                                   The level to which the frequency band should be set to
+       * @exception            E_SUCCESS                                       The method is successful.
+    * @exception               E_OUT_OF_RANGE          The level value does not lie within minimum and maximum range of frequency band.
+       * @exception            E_INVALID_ARG                           The specified input parameter is invalid
+       * @exception            E_INVALID_OPERATION             The associated audio instance is no longer valid.
+       * @see GetBandCount()
+       * @endif
+       */
+       result SetBandLevel(int index, int level);
+
+       /**
+       * @if VISPARTNER
+       * Sets the level of all the frequency bands
+       *
+       * @since                2.0
+       *
+       * @visibility           partner
+       *
+       * @return                       An error code
+       * @param[in]            pLevels                                         The pointer of the level array which has settings of all the frequency bands
+       * @exception            E_SUCCESS                                       The method is successful
+    * @exception               E_OUT_OF_RANGE          The level values do not lie within minimum and maximum range of frequency bands
+    * @exception       E_INVALID_ARG                           The specified input parameter is invalid. List is either empty or does not have level settings for all frequeny bands.
+       * @exception            E_INVALID_OPERATION             The associated audio instance is no longer valid.
+    * @endif
+       */
+       result SetAllBandsLevel(const Tizen::Base::Collection::IListT<int>* pLevels);
+
+       /**
+       * @if VISPARTNER
+       * Gets the level of frequency band specified via index
+       *
+       * @since                2.0
+       *
+       * @visibility           partner
+       *
+       * @return               An error code
+       * @param[in]            index                                   Index of the frequency band. @n
+                                                                                                       Index starts from 0.
+       * @param[out]   level                                           Level of the frequency band specified via index
+       * @exception            E_SUCCESS                                       The method is successful
+       * @exception            E_INVALID_ARG                   The specified input parameter is invalid
+       * @exception            E_INVALID_OPERATION             The associated audio instance is no longer valid.
+       * @endif
+       */
+       result GetBandLevel(int index, int& level) const;
+
+       /**
+       * @if VISPARTNER
+       * Gets the center frequency of the frequency band specified by index
+       *
+       * @since                2.0
+       *
+       * @visibility           partner
+       *
+       * @return                       An error code
+       * @param[in]            index                                   Index of the frequency band. @n
+                                                                                               Index starts from 0.
+       * @param[out]   frequency                               Center frequency in Hz of the frequency band specified by index
+       * @exception            E_SUCCESS                               The method is successful
+       * @exception            E_INVALID_ARG                   The specified input parameter is invalid
+       * @exception            E_INVALID_OPERATION             The associated audio instance is no longer valid.
+       * @endif
+       */
+       result GetBandCenterFrequency(int index, int& frequency) const;
+       
+       /**
+       * @if VISPARTNER
+       * Clears the equalizer effect and resets all bands to the default values
+       *
+       * @since                2.0
+       *
+       * @visibility                   partner
+       *
+       * @return                       An error code
+       * @exception            E_SUCCESS                                       The method is successful
+       * @exception            E_INVALID_OPERATION     The associated audio instance is no longer valid.
+       * @endif
+       */
+       result ResetAllToDefault(void);
+
+private:
+       /**
+        * @if VISPARTNER
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        *
+        * @visibility          private
+        * @endif
+        */
+       AudioEqualizer(const AudioEqualizer& rhs);
+       
+       /**
+        * @if VISPARTNER
+        * The implementation of this copy assignment  operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        *
+        * @visibility          private
+        * @endif
+        */
+       AudioEqualizer& operator =(const AudioEqualizer& rhs);
+       
+       class _AudioEqualizerImpl* __pAudioEqualizerImpl;
+};
+
+}} // Tizen::Media
+
+#endif 
+
diff --git a/inc/FMediaAudioIn.h b/inc/FMediaAudioIn.h
new file mode 100644 (file)
index 0000000..9301f3f
--- /dev/null
@@ -0,0 +1,424 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaAudioIn.h
+ * @brief                      This is the header file for the %AudioIn class.
+ *
+ * This header file contains the declarations of the %AudioIn class.
+ */
+
+#ifndef _FMEDIA_AUDIO_IN_H_
+#define _FMEDIA_AUDIO_IN_H_
+
+#include <FMediaAudioTypes.h>
+#include <FMediaIAudioInEventListener.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @class      AudioIn
+ * @brief              This class records directly from an audio device.
+ *
+ * @since              2.0
+ *
+ * The %AudioIn class records directly from an audio device by providing methods for capturing PCM data from an audio input device.
+ * An application can capture audio data with the help of an event listener after preparing the %AudioIn class
+ * with proper channel count, sample type, and sampling rate.
+ * To minimize the overhead of the %AudioIn class,
+ * it is recommended that you use optimal channel type, sample type, and sampling rate.
+ * These can be retrieved with GetOptimizedChannelType(), GetOptimizedSampleType()
+ * and GetOptimizedSampleRate().
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/recording_pcm_audio.htm">Recording PCM Audio</a>.
+ *
+ * The following example demonstrates how to use the %AudioIn class.
+ *
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FIo.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Io;
+ * using namespace Tizen::Media;
+ *
+ * #define MAX_BUFFER_COUNT      3
+ *
+ * class AudioInSample
+ *      : public Tizen::Media::IAudioInEventListener
+ * {
+ * public:
+ *      result Start(void);
+ *      void Stop(void);
+ *
+ * protected:
+ *      virtual void OnAudioInBufferIsFilled( Tizen::Base::ByteBuffer* pData);
+ *      virtual void OnAudioInErrorOccurred(result r) {}
+ *      virtual void OnAudioInInterrupted(void) {}
+ *      virtual void OnAudioInReleased(void) {}
+ *      virtual void OnAudioInAudioFocusChanged(void) {}
+ *
+ * private:
+ *      AudioIn __audioIn;
+ *      ByteBuffer __buffer[MAX_BUFFER_COUNT];
+ * };
+ *
+ * result
+ * AudioInSample::Start(void)
+ * {
+ *      result r;
+ *      int minBufferSize;
+ *      AudioInputDevice inputDevice = AUDIO_INPUT_DEVICE_MIC;
+ *      AudioSampleType sampleType = AUDIO_TYPE_PCM_U8;
+ *      AudioChannelType channelType = AUDIO_CHANNEL_TYPE_STEREO;
+ *      int sampleRate = 8000;
+ *
+ *      // Constructs an AudioIn instance
+ *      r = __audioIn.Construct(*this);
+ *      if (IsFailed(r))
+ *      {
+ *              return r;
+ *      }
+ *
+ *      // Prepares the AudioIn instance
+ *      r = __audioIn.Prepare(inputDevice, sampleType, channelType, sampleRate);
+ *      if (IsFailed(r))
+ *      {
+ *              return r;
+ *      }
+ *
+ *      minBufferSize = __audioIn.GetMinBufferSize();
+ *
+ *      for (int i = 0; i < MAX_BUFFER_COUNT; i++)
+ *      {
+ *              // Prepares buffers to store PCM data
+ *              r = __buffer[i].Construct(minBufferSize);
+ *              if (IsFailed(r))
+ *              {
+ *                      return r;
+ *              }
+ *              // Adds buffer to the __audioIn
+ *              __audioIn.AddBuffer(&__buffer[i]);
+ *              if (IsFailed(r))
+ *              {
+ *                      return r;
+ *              }
+ *      }
+ *
+ *      // Starts capturing
+ *      r = __audioIn.Start();
+ *      if (IsFailed(r))
+ *      {
+ *              return r;
+ *      }
+ *
+ *      return E_SUCCESS;
+ * }
+ *
+ * void
+ * AudioInSample::Stop(void)
+ * {
+ *      // Stops and unprepares the __audioIn
+ *      __audioIn.Stop();
+ *      __audioIn.Unprepare();
+ * }
+ *
+ * void
+ * AudioInSample::OnAudioInBufferIsFilled( Tizen::Base::ByteBuffer* pData)
+ * {
+ *      // Consumes filled data here
+ *
+ *      // Clears the buffer
+ *      pData->Clear();
+ *
+ *      // Adds the byte buffer to the __audioIn to fill data again
+ *      __audioIn.AddBuffer(pData);
+ * }
+ *
+ *
+ * @endcode
+ *
+ */
+
+class _OSP_EXPORT_ AudioIn
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        *      The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        *  @since              2.0
+        *
+        *      @remarks        After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        *      @see                    Construct()
+        */
+       AudioIn(void);
+
+       /**
+        *      This destructor overrides Tizen::Base::Object::~Object().
+        *      All allocated resources are deallocated with this method. @n
+        *      This method must be called in the same thread as the Construct() method.
+        *
+        *  @since              2.0
+        *
+        *      @see            Construct()
+        */
+       virtual ~AudioIn(void);
+
+       /**
+       *       Initializes this instance of %AudioIn with the specified IAudioInEventListener. @n
+       *       This method creates an instance of %AudioIn in the subsystem.
+       *
+       *   @since              2.0
+       *
+       *       @return         An error code
+       *       @param[in]      listener                                        An instance of IAudioInEventListener
+       *       @exception      E_SUCCESS                                       The method is successful.
+       *       @exception      E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       *       @exception      E_OUT_OF_MEMORY         The memory is insufficient. 
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @remarks Only one instance of %AudioIn is operational at a given time.
+       */
+       result Construct(IAudioInEventListener& listener);
+
+       /**
+       * @if OSPDEPREC
+       *       Prepares the specified audio input device with the application-defined settings. @n
+       *   When the caller finishes using the audio input device, the resources must be released by calling the Unprepare() method.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated because AudioInputDevice is no longer used in %AudioIn class. @n
+       *  Instead of using this method, use Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate).
+       *
+       *   @since              2.0
+       *
+       *       @return         An error code
+       *       @param[in]      audioInputDevice                                                An audio input device
+       *       @param[in]      audioSampleType                                         The type of audio sample
+       *       @param[in]      audioChannelType                                                The audio channel type
+       *       @param[in]      audioSampleRate                                         The audio sample rate in hertz (Hz)
+       *       @exception      E_SUCCESS                                                               The method is successful.
+       *       @exception      E_INVALID_STATE                                         This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                                A system error has occurred.
+       *       @exception      E_INVALID_ARG                                                   A specified input parameter is invalid.
+       *       @exception      E_UNSUPPORTED_FORMAT                    The specified audio sample type is not supported.
+       *       @see            Unprepare()
+       * @endif
+       */
+       result Prepare(AudioInputDevice audioInputDevice, AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate);
+
+       /**
+       *       Prepares the specified audio input device with the application-defined settings. @n
+       *   When the caller finishes using the audio input device, the resources must be released by calling the Unprepare() method.
+       *
+       *   @since              2.0
+       *
+       *       @return         An error code
+       *       @param[in]      audioSampleType                                         The type of audio sample
+       *       @param[in]      audioChannelType                                                The audio channel type
+       *       @param[in]      audioSampleRate                                         The audio sample rate in hertz (Hz)
+       *       @exception      E_SUCCESS                                                                       The method is successful.
+       *  @exception  E_DEVICE_FAILED                                          The device failed with unknown reason.
+       *       @exception      E_INVALID_ARG                                                   A specified input parameter is invalid.
+       *       @exception      E_UNSUPPORTED_FORMAT                    The specified audio sample type is not supported.
+       *       @see            Unprepare()
+       */
+       result Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate);
+
+       /**
+       *       Stops the usage of the input device and releases the allocated resources during the execution of the Prepare() method. @n
+       *   Resources allocated during Prepare() are released.
+       *
+       *   @since              2.0
+       *
+       *       @return         An error code
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_INVALID_STATE         This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @see            Prepare()
+       */
+       result Unprepare(void);
+
+       /**
+       *       Adds an input buffer to the specified audio input device. @n
+       *       When the buffer is filled, the %AudioIn class returns the buffer to the caller
+       *       by invoking IAudioInEventListener::OnAudioInBufferIsFilled().
+       *
+       *   @since              2.0
+       *
+       *       @return                 An error code
+       *       @param[in]      pByteBuffer                                                             A pointer to the buffer
+       *       @exception      E_SUCCESS                                                                       The method is successful.
+       *       @exception      E_INVALID_ARG                                                   The input parameter is invalid.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                                                A system error has occurred.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @remarks        The data size of @c pByteBuffer must be the same as every call of this method.
+       *       @see            Start(), IAudioInEventListener::OnAudioInBufferIsFilled()
+       */
+       result AddBuffer(const Tizen::Base::ByteBuffer* pByteBuffer);
+
+       /**
+       *       Starts reading the audio data from an audio input device and fills the data into the buffer.
+       *
+       *   @since              2.0
+       *
+       *       @return                 An error code
+       *       @exception      E_SUCCESS                                                       The method is successful.
+       *       @exception      E_INVALID_STATE                 This instance is in an invalid state for this method.
+       *       @exception      E_DEVICE_BUSY                                   The device cannot be approached because of other operations.
+       *       @exception      E_SYSTEM                                                                A system error has occurred.
+       *       @remarks        Several buffers must be added to the queue with AddBuffer() before calling this method.
+       *       @see            Stop(), IAudioInEventListener::OnAudioInBufferIsFilled()
+       */
+       result Start(void);
+
+       /**
+       *       Stops using the audio input device. @n
+       *       All pending and current buffers that are filled with audio data
+       *   at the time of calling this method, are returned to the listener.
+       *       Use Start() to start capturing audio input data again.
+       *
+       *   @since              2.0
+       *
+       *       @return                 An error code
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_INVALID_STATE         This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @see            Start(), IAudioInEventListener::OnAudioInBufferIsFilled()
+       */
+       result Stop(void);
+
+       /**
+       *       Resets using the audio input device without returning buffers to the caller. @n
+       *       All pending and current buffers are released immediately without any notifications.
+       *       The state is changed to AUDIOIN_STATE_PREPARED.
+       *
+       *   @since              2.0
+       *
+       *       @return                 An error code
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_INVALID_STATE         This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       */
+       result Reset(void);
+
+       /**
+       *       Gets the current state of this instance.
+       *
+       *   @since              2.0
+       *
+       *       @return                 The state of this instance
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @remarks        The specific error code can be accessed using the GetLastResult() method.
+       */
+       AudioInState GetState(void) const;
+
+       /**
+       *       Gets the maximum size of the buffer that can be used with AddBuffer(). @n
+       *       This maximum value is set by Prepare() and reset to @c 0 by Unprepare().
+       *
+       *   @since              2.0
+       *
+       *       @return                 The maximum size of the buffer in bytes, @n
+       *                               else @c -1 if an error occurs
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_INVALID_STATE         This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @remarks        The return value is available after calling the Prepare() method.
+       *       @remarks        The specific error code can be accessed using the GetLastResult() method.
+       */
+       int GetMaxBufferSize(void) const;
+
+       /**
+       *       Gets the minimum size of the buffer that can be used with AddBuffer(). @n
+       *       This minimum value is set by Prepare() and reset to @c 0 by Unprepare().
+       *
+       *   @since              2.0
+       *
+       *       @return                 The minimum size of the buffer in bytes,        @n
+       *                               else @c -1 if an error occurs
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_INVALID_STATE         This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @remarks        The return value is available after calling the Prepare() method.
+       *       @remarks        The specific error code can be accessed using the GetLastResult() method.
+       */
+       int GetMinBufferSize(void) const;
+
+       /**
+       *       Gets the optimized sample type of the audio input device.
+       *
+       *   @since              2.0
+       *
+       *       @return                 The audio encoding type
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @remarks        The specific error code can be accessed using the GetLastResult() method.
+       */
+       AudioSampleType GetOptimizedSampleType(void) const;
+
+       /**
+       *       Gets the optimized channel type of the audio input device.
+       *
+       *   @since              2.0
+       *
+       *       @return         The audio channel type
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @remarks        The specific error code can be accessed using the GetLastResult() method.
+       */
+       AudioChannelType GetOptimizedChannelType(void) const;
+
+       /**
+       *       Gets the optimized sample rate of the audio input device.
+       *
+       *   @since              2.0
+       *
+       *       @return         The sample rate in hertz (Hz)
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       *       @remarks        The specific error code can be accessed using the GetLastResult() method.
+       */
+       int GetOptimizedSampleRate(void) const;
+
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        *      @since          2.0
+        */
+       AudioIn(const AudioIn& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        *       @since         2.0
+        */
+       AudioIn& operator =(const AudioIn& rhs);
+
+       friend class _AudioInImpl;
+       class _AudioInImpl* __pAudioInImpl;
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaAudioManagerTypes.h b/inc/FMediaAudioManagerTypes.h
new file mode 100644 (file)
index 0000000..f57adc1
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                        FMediaAudioManagerTypes.h
+* @brief               This is the header file for the types of audio manager classes.
+*
+* This header files contains all the common things required for audio manager classes and associated classes
+*
+*/
+#ifndef _FMEDIA_AUDIO_MANAGER_TYPES_H_
+#define _FMEDIA_AUDIO_MANAGER_TYPES_H_
+
+namespace Tizen { namespace Media
+{
+/**
+ * @if VISPARTNER
+ * @enum InputAudioDevice
+ *
+ * Defines the input audio devices.
+ *
+ * @since              2.0
+ * @visibility                 partner
+ * @endif
+ */
+enum InputAudioDevice
+{
+       INPUT_AUDIO_DEVICE_NONE,                                                        /**< No input audio device */
+       INPUT_AUDIO_DEVICE_MIC,                                                         /**< The microphone */
+       INPUT_AUDIO_DEVICE_WIRED_ACCESSORY,     /**< The wired accessory such as headset*/
+       INPUT_AUDIO_DEVICE_BT_SCO,                                      /**< The bluetooth(SCO) */
+};
+
+
+/**
+ * @if VISPARTNER
+ * @enum OutputAudioDevice
+ *
+ * Defines the output audio devices
+ *
+ * @since              2.0
+ * @visibility                 partner
+ * @endif
+ */
+enum OutputAudioDevice
+{
+       OUTPUT_AUDIO_DEVICE_NONE,                                                       /**< No output audio device */
+       OUTPUT_AUDIO_DEVICE_SPEAKER,                                            /**< The speaker */
+       OUTPUT_AUDIO_DEVICE_RECEIVER,                                   /**< The receiver */
+       OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY,    /**< The wired accessory such as earjack, headphone or headset*/
+       OUTPUT_AUDIO_DEVICE_BT_SCO,                                             /**< The bluetooth(SCO) */
+       OUTPUT_AUDIO_DEVICE_BT_A2DP,                                            /**< The bluetooth(A2DP) */
+};
+
+/**
+ * @if VISPARTNER
+ * @enum AudioSessionMode
+ *
+ * Defines the audio session mode.
+ *
+ * @since              2.0
+ * @visibility                 partner
+ * @endif
+ */
+enum AudioSessionMode
+{
+       AUDIO_SESSION_MODE_SHARED,                              /**< Shared session mode that mutiple applications can use an audio device simultaneously */
+       AUDIO_SESSION_MODE_EXCLUSIVE,           /**< Exclusive session mode that only one application can use an audio device at a time */
+       AUDIO_SESSION_MODE_EMERGENCY,   /**< Emergency session mode that only one application can use all available audio devices at a time*/
+};
+
+/**
+ * @enum AudioStreamType
+ *
+ * Defines the audio stream types.
+ *
+ * @since              2.0
+ */
+enum AudioStreamType
+{
+       AUDIO_STREAM_TYPE_NO_SOUND,                     /**< System is not playing any sound */
+       AUDIO_STREAM_TYPE_SYSTEM,                                       /**< System audio */
+       AUDIO_STREAM_TYPE_NOTIFICATION,                 /**< Notification audio */
+       AUDIO_STREAM_TYPE_ALARM,                                        /**< Alarm type audio */
+       AUDIO_STREAM_TYPE_RINGTONE,                             /**< Ringtone type audio */
+       AUDIO_STREAM_TYPE_MEDIA,                                                /**< Media type audio */
+       AUDIO_STREAM_TYPE_CALL                                          /**< Call type audio */
+};
+
+/**
+ * @if VISPARTNER
+ * @enum VoipAudioSessionMode
+ *
+ * Defines enums of VoIP call session mode.
+ *
+ * @since              2.0
+ * @visibility                 partner
+ * @endif
+ */
+enum VoipAudioSessionMode
+{
+ VOIP_AUDIO_SESSION_MODE_NONE,    /**< VoIP audio session mode is none */
+ VOIP_AUDIO_SESSION_MODE_VOICE,    /**< VoIP audio session mode is voice */
+ VOIP_AUDIO_SESSION_MODE_RINGTONE,  /**< VoIP audio session mode is ringtone */
+ VOIP_AUDIO_SESSION_MODE_MEDIA    /**< VoIP audio session mode is media  */
+};
+
+}}     //Tizen::Media
+#endif
diff --git a/inc/FMediaAudioOut.h b/inc/FMediaAudioOut.h
new file mode 100644 (file)
index 0000000..555f61b
--- /dev/null
@@ -0,0 +1,441 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaAudioOut.h
+ * @brief                      This is the header file for the %AudioOut class.
+ *
+ * This header file contains the declarations of the %AudioOut class.
+ */
+
+#ifndef _FMEDIA_AUDIO_OUT_H_
+#define _FMEDIA_AUDIO_OUT_H_
+
+#include <FBaseByteBuffer.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaIAudioOutEventListener.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class              AudioOut
+ * @brief              This class plays raw audio data.
+ *
+ * @since              2.0
+ *
+ * @remarks
+ * The maximum number of %AudioOut instances is limited by Media::MediaCapability class. This number is a system wide count so that the application must not be able to construct more instances than the maximum number permitted.
+ *
+ * The %AudioOut class plays raw audio data and provides methods for:
+ * - Playing PCM data in various audio sample types
+ * - Controlling volume
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/playing_pcm_audio.htm">Playing PCM Audio</a>.
+ *
+ * The following example demonstrates how to use the %AudioOut class.
+ *
+ *
+ * @code
+ * #include <FBase.h>
+ * #include <FIo.h>
+ * #include <FApp.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Io;
+ * using namespace Tizen::Media;
+ *
+ * #define MAX_BUFFER_COUNT    3
+ *
+ * class AudioOutSample
+ *      : public Tizen::Media::IAudioOutEventListener
+ * {
+ * public:
+ *      result Start(void);
+ *      void Stop(void);
+ *
+ * protected:
+ *      virtual void OnAudioOutBufferEndReached(Tizen::Media::AudioOut& src);
+ *      virtual void OnAudioOutErrorOccurred(Tizen::Media::AudioOut& src, result r) {}
+ *      virtual void OnAudioOutInterrupted(Tizen::Media::AudioOut& src) {}
+ *      virtual void OnAudioOutReleased(Tizen::Media::AudioOut& src) {}
+ *      virtual void OnAudioOutAudioFocusChanged(Tizen::Media::AudioOut& src) {}
+ *
+ * private:
+ *      AudioOut __audioOut;
+ *      File __file;
+ *      ByteBuffer __buffer[MAX_BUFFER_COUNT];
+ *      int __bufIndex;
+ * };
+ *
+ * result
+ * AudioOutSample::Start(void)
+ * {
+ *      FileAttributes attr;
+ *      String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.pcm";
+ *      result r;
+ *      int minBufferSize;
+ *
+ *      // Opens the input file
+ *      __file.Construct(filePath, L"rb");
+ *
+ *      // Constructs the AudioOut instance with a listener
+ *      r = __audioOut.Construct(*this);
+ *      if (IsFailed(r))
+ *      {
+ *              return r;
+ *      }
+ *
+ *      // Prepares the AudioOut instance
+ *      // Considers the input data as signed 16-bit, stereo, 44100 Hz PCM data
+ *      __audioOut.Prepare(AUDIO_TYPE_PCM_S16_LE, AUDIO_CHANNEL_TYPE_STEREO, 44100);
+ *      minBufferSize = __audioOut.GetMinBufferSize();
+ *
+ *      // Constructs the pcm buffer and enqueue the buffer to the __audioOut
+ *      for (int i = 0; i < MAX_BUFFER_COUNT; i++)
+ *      {
+ *              __buffer[i].Construct(minBufferSize);
+ *              __file.Read(__buffer[i]);
+ *              __audioOut.WriteBuffer(__buffer[i]);
+ *      }
+ *      __bufIndex = 0;
+ *
+ *      // Starts playing
+ *      r = __audioOut.Start();
+ *      if (IsFailed(r))
+ *      {
+ *              return r;
+ *      }
+ *
+ *      return E_SUCCESS;
+ * }
+ *
+ * void
+ * AudioOutSample::Stop(void)
+ * {
+ *      __audioOut.Stop();
+ *      __audioOut.Unprepare();
+ * }
+ *
+ * void
+ * AudioOutSample::OnAudioOutBufferEndReached(Tizen::Media::AudioOut& src)
+ * {
+ *      result r = E_SUCCESS;
+ *
+ *      r = __file.Read(__buffer[__bufIndex % MAX_BUFFER_COUNT]);
+ *      if (IsFailed(r))
+ *      {
+ *              // Handles end of file event
+ *
+ *              return;
+ *      }
+ *
+ *      src.WriteBuffer(__buffer[__bufIndex % MAX_BUFFER_COUNT]);
+ *      __bufIndex++;
+ * }
+ *
+ *
+ * @endcode
+ */
+
+class _OSP_EXPORT_ AudioOut
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        * @since               2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       AudioOut(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        * All allocated resources are released by this method.
+        * This method must be called in the same thread as the Construct() method.
+        *
+        * @since               2.0
+        *
+        * @see                 Construct()
+        */
+       virtual ~AudioOut(void);
+
+public:
+       /**
+       * Initializes this instance of %AudioOut with the specified listener.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    listener                                                                                        An instance of IAudioOutEventListener
+       * @exception    E_SUCCESS                                                                               The method is successful.
+       * @exception    E_SYSTEM                                                                                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient. 
+       * @exception    E_RESOURCE_UNAVAILABLE          The AudioOut's resources are unavailable.
+       */
+       result Construct(IAudioOutEventListener& listener);
+
+       /**
+       * Prepares an audio output device with the defined settings.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    audioSampleType                                 The type of the audio sample
+       * @param[in]    audioChannelType                                        The type of the audio channel
+       * @param[in]    audioSampleRate                                 The audio sample rate in hertz (Hz)
+       * @exception    E_SUCCESS                                                                       The method is successful.
+       * @exception    E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                                                A system error has occurred.
+       * @exception    E_INVALID_ARG                                                   A specified input parameter is invalid.
+       * @exception    E_UNSUPPORTED_FORMAT            The specified audio sample type is not supported.
+       * @see                  Unprepare()
+       */
+       result Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate);
+
+       /**
+       * Prepares an audio output device with the defined settings with the audio stream type.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    audioStreamType                                 The type of the audio stream
+       * @param[in]    audioSampleType                                 The type of the audio sample
+       * @param[in]    audioChannelType                                        The type of the audio channel
+       * @param[in]    audioSampleRate                                 The audio sample rate in hertz (Hz)
+       * @exception    E_SUCCESS                                                               The method is successful.
+       * @exception    E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       * @exception   E_DEVICE_FAILED                          The device failed with unknown reason.
+       * @exception    E_INVALID_ARG                                           A specified input parameter is invalid.
+       * @exception    E_UNSUPPORTED_FORMAT            The specified audio sample type is not supported.
+       * @see                  Unprepare()
+       */
+       result Prepare(AudioStreamType audioStreamType, AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate);
+
+       /**
+       * Closes the audio output device.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @see                  Prepare()
+       */
+       result Unprepare(void);
+
+       /**
+       * Writes into the data buffer containing the audio data to be played to this audio output device. @n
+       * When the end of the buffer is reached, the application gets the notification through %IAudioOutEventListener.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    userData                                                        A pointer of the buffer containing the PCM data block
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_OVERFLOW                                              The specified input instance has overflowed.
+       * @see                  Start(), IAudioOutEventListener::OnAudioOutBufferEndReached()
+       */
+       result WriteBuffer(const Tizen::Base::ByteBuffer& userData);
+
+       /**
+       * Starts the specified audio output device.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @see                  Stop()
+       */
+       result Start(void);
+
+       /**
+       * Stops or pauses the playing of the audio output device. @n
+       * The current position of the playback is stored internally and the playback will restart from this position
+       * when Start() is called again.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              Use Start() to resume the playback from the current playback position.
+       * @see                  Start(), IAudioOutEventListener::OnAudioOutBufferEndReached()
+       */
+       result Stop(void);
+
+       /**
+       * Resets the audio output device. @n
+       * All pending and current data buffers in the queue are removed immediately without any notification. The
+       * state is changed to AUDIOOUT_STATE_PREPARED.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       */
+       result Reset(void);
+
+       /**
+       * Gets the state of the current audio output device.
+       *
+       * @since                2.0
+       *
+       * @return               The state of current audio output
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       AudioOutState GetState(void) const;
+
+       /**
+       * Gets the maximum size of buffer that can be used with WriteBuffer(). @n
+       * This maximum value is set by Prepare() and reset to @c 0 by Unprepare().
+       *
+       * @since                2.0
+       *
+       * @return               The maximum size of buffer, @n
+       *                               else @c -1 if an error occurs
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              The return value is available after calling the Prepare() method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       int GetMaxBufferSize(void) const;
+
+       /**
+       * Gets the minimum size of buffer that can be used with WriteBuffer(). @n
+       * This minimum value is set by Prepare() and reset to @c 0 by Unprepare().
+       *
+       * @since                2.0
+       *
+       * @return               The minimum size of buffer, @n
+       *                               else @c -1 if an error occurs
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              The return value is available after calling the Prepare() method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       int GetMinBufferSize(void) const;
+
+       /**
+       * Gets the optimized sample type of the audio output device.
+       *
+       * @since                2.0
+       *
+       * @return               The audio encoding type
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       AudioSampleType GetOptimizedSampleType(void) const;
+
+       /**
+       * Gets the optimized channel type of the audio output device.
+       *
+       * @since                2.0
+       *
+       * @return               The audio channel type
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       AudioChannelType GetOptimizedChannelType(void) const;
+
+       /**
+       * Gets the optimized sample rate of the audio output device.
+       *
+       * @since                2.0
+       *
+       * @return               The sample rate in hertz (Hz)
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       int GetOptimizedSampleRate(void) const;
+
+       /**
+       * Sets the volume level of the audio output device.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    volume                          The new value for volume @n
+       *                                                                       The range of this parameter is from @c 0 to @c 100 and it is proportional to the current media sound volume level in setting.
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_OUT_OF_RANGE                  The specified volume is out of range.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @remarks              This method must be called after Prepare().
+       * @see                  GetVolume()
+       */
+       result SetVolume(int volume);
+
+       /**
+       * Gets the current volume level of this audio output.
+       *
+       * @since                2.0
+       *
+       * @return               The current volume level, @n
+       *                               else @c -1 if an error occurs @n
+       *                               This return value ranges from @c 0 to @c 100.
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @remarks              This method must be called after calling the Prepare() method.
+       * @see                  SetVolume()
+       */
+       int GetVolume(void) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        */
+       AudioOut(const AudioOut& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        */
+       AudioOut& operator =(const AudioOut& rhs);
+
+       friend class _AudioOutImpl;
+       class _AudioOutImpl* __pAudioOutImpl;
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaAudioRecorder.h b/inc/FMediaAudioRecorder.h
new file mode 100755 (executable)
index 0000000..1c2128f
--- /dev/null
@@ -0,0 +1,548 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMediaAudioRecorder.h
+ * @brief               This is the header file for the %AudioRecorder class.
+ *
+ * This header file contains the declarations of the %AudioRecorder class.
+ */
+
+#ifndef _FMEDIA_AUDIO_RECORDER_H_
+#define _FMEDIA_AUDIO_RECORDER_H_
+
+#include <FMediaAudioRecorderTypes.h>
+#include <FMediaIAudioRecorderEventListener.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+class _AudioRecorderImpl;
+
+/**
+ * @class      AudioRecorder
+ * @brief      This class records the audio data into a file.
+ *
+ * @since              2.0
+ *
+ * The %AudioRecorder class records the audio data from an input device source to the storage device. The
+ * selection of the input device source depends upon the current device status. For example, if a headset device is
+ * connected, it is selected as an input source. The audio recording format, the maximum recording time, and the
+ * maximum recording size can be set using the methods available in this class.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/recording_audio.htm">Recording Audio</a>.
+ *
+ * The following example demonstrates how to use the %AudioRecorder class.
+ *
+ *
+ * @code
+ * #include <FBase.h>
+ * #include <FIo.h>
+ * #include <FApp.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Io;
+ * using namespace Tizen::Media;
+ *
+ * class AudioRecorderSample
+ *     : public IAudioRecorderEventListener
+ * {
+ * public:
+ *     result Start(void);
+ *     void Stop(void);
+ *
+ * protected:
+ *     virtual void OnAudioRecorderStopped(result r) {}
+ *     virtual void OnAudioRecorderCanceled(result r) {}
+ *     virtual void OnAudioRecorderPaused(result r) {}
+ *     virtual void OnAudioRecorderStarted(result r) {}
+ *     virtual void OnAudioRecorderEndReached(RecordingEndCondition endCondition) {}
+ *     virtual void OnAudioRecorderClosed(result r) {}
+ *     virtual void OnAudioRecorderErrorOccurred(RecorderErrorReason r) {}
+ *
+ * private:
+ *     AudioRecorder __recorder;
+ * };
+ *
+ * result
+ * AudioRecorderSample::Start(void)
+ * {
+ *     result r;
+ *     String destFilePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.amr";
+ *
+ *     r = __recorder.Construct(*this);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     r = __recorder.CreateAudioFile(destFilePath, true);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     r = __recorder.Record();
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     return E_SUCCESS;
+ * }
+ *
+ * void
+ * AudioRecorderSample::Stop(void)
+ * {
+ *     __recorder.Stop();
+ *     __recorder.Close();
+ * }
+ *
+ * @endcode
+ *
+ */
+
+class _OSP_EXPORT_ AudioRecorder
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks             The object is not fully constructed after this constructor is called.
+        * For full construction, the Construct() method must be called right after calling this constructor.
+        */
+       AudioRecorder(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are released by this method. This method must be called in the same thread in
+        * which the Construct() method is called. This polymorphic destructor should be overridden if required.
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since               2.0
+        *
+        */
+       virtual ~AudioRecorder(void);
+
+
+public:
+       /**
+       * Initializes this instance of %AudioRecorder with the specified listener.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    listener                        An instance of IAudioRecorderEventListener
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY     The memory is insufficient.
+       * @exception    E_UNSUPPORTED_OPERATION This audio recorder usage is not supported.
+       * @exception    E_DEVICE_BUSY           The recorder is under use by other application or already used in this application.
+       */
+       result Construct(IAudioRecorderEventListener& listener);
+
+       /**
+       * Creates an audio file for the recording.
+       *
+       * @if OSPCOMPAT
+       * @brief <i> [Compatibility] </i>
+       * @endif
+       * @since                2.0
+       * @if OSPCOMPAT
+       * @compatibility        This method has compatibility issues with OSP compatible applications. @n
+       *                                       For more information, see @ref CompIoPathPage "here".
+       * @endif
+       *
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @param[in]    destMediaPath                   The file destination to write @n
+       *                                                                               The available paths start with prefixes retrieved from the functions such as: @n
+       *                                                                               Tizen::App::App::GetInstance()->GetAppRootPath() @n
+       *                                                                               Tizen::System::Environment::GetMediaPath() @n
+       *                                                                               Tizen::System::Environment::GetExternalStoragePath()
+       * @param[in]    overwrite                   Set to @c true to overwrite a file if it already exists, @n
+       *                                                                               else @c false
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_RESOURCE_UNAVAILABLE  The required path is unavailable.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_FILE_ALREADY_EXIST    The specified file already exists.
+       * @exception    E_STORAGE_FULL                  The storage is full.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The application can register newly created files into the Contents database using Tizen::Content::ContentManager::CreateContent().
+       * @see Close()
+       */
+       result CreateAudioFile(const Tizen::Base::String& destMediaPath, bool overwrite);
+
+       /**
+       * Closes a file.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks      This method is synchronous.
+       * @see                  CreateAudioFile()
+       */
+       result Close(void);
+
+       /**
+       * Records an audio file.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return           An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The recorder is under use by other application.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  Stop()
+        * @see         Pause()
+       */
+       result Record(void);
+
+       /**
+       * Stops a recording.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  Record()
+        * @see         Pause()
+       */
+       result Stop(void);
+
+       /**
+       * Pauses a recording. @n
+       * To resume a recording after this method is called, the Record() method must be called.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @see         Stop()
+       */
+       result Pause(void);
+
+       /**
+       * Cancels a recording operation without saving the data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return           An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks      If this method is called, the state is changed to ::RECORDER_STATE_STOPPING. @n
+       *                       After IAudioRecorderEventListener::OnAudioRecorderCanceled() is called, the state is changed
+       *                       to @cRECORDER_STATE_STOPPED.
+       * @see          Record()
+        * @see     Stop()
+       */
+       result Cancel(void);
+
+       /**
+       * Gets the state of an audio recorder.
+       *
+       * @since                2.0
+       *
+       * @return           The current state of an audio recorder
+        * @see             Close()
+        * @see         Record()
+        * @see         Stop()
+        * @see         Pause()
+       */
+       RecorderState GetState(void) const;
+
+       /**
+       * Gets the current recording time.
+       *
+       * @since                2.0
+       *
+       * @return           The value indicating the current recording time in milliseconds, @n
+       *                               else @c -1 if the recording has not started as yet
+       */
+       long GetRecordingTime(void) const;
+
+       /**
+       * Gets the current recording size.
+       *
+       * @since                2.0
+       *
+       * @return               The value indicating the current recording size in bytes, @n
+       *                               else @c -1 if the recording has not started as yet
+       */
+       long GetRecordingSize(void) const;
+
+       /**
+       * Sets the recording time limit for a file in milliseconds.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @param[in]    msTime          The maximum recording time in milliseconds @n
+       *                                                       The time must be greater than @c 0.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                  The specified time is out of range.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The default time is @c 60 seconds.
+       * @see                  GetMaxRecordingTime()
+       */
+       result SetMaxRecordingTime(long msTime);
+
+       /**
+       * Gets the recording time limit of a file in milliseconds.
+       *
+       * @since                2.0
+       *
+       * @return               A @c long value indicating the maximum recording time in milliseconds
+       * @see                  SetMaxRecordingTime()
+       */
+       long GetMaxRecordingTime(void) const;
+
+       /**
+       * @if OSPDEPREC
+       * Sets the audio format of an audio recorder. @n
+       * Initially, the default format is set using the internal configuration.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. Instead of this method, use the SetFormat(CodecType audioCodec, MediaContainerType container) method
+       *                               that sets the audio codec and container together.
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @param[in]    format          The audio format to set @n
+       *                                                       ::AUDIORECORDING_FORMAT_DEFAULT sets the system's default recording format.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  GetFormat()
+       * @endif
+       */
+       result SetFormat(AudioRecordingFormat format);
+
+       /**
+       * @if OSPDEPREC
+       * Gets the audio recording format of an audio recorder.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. Instead of this method, use the GetFormat(CodecType& audioCodec,
+       * MediaContainerType& container) const method that gets the audio codec and container together.
+       * @since                2.0
+       *
+       * @return               The audio recording format, @n
+       *               else default format if SetFormat() is not called before calling this method
+       * @see                  SetFormat()
+       * @endif
+       */
+       AudioRecordingFormat GetFormat(void) const;
+
+       /**
+       * Sets the audio codec and the container of an audio recorder. @n
+       * Initially, the default codec and the container format are set using the internal configuration.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @param[in]    audioCodec                              The audio codec to set
+       * @param[in]    container                               The media container to set
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified container format is not supported.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              If the specified container does not support the specified codec, @c E_UNSUPPORTED_FORMAT may be returned.
+       * @see                  GetFormat( CodecType& audioCodec, MediaContainerType& container ) const
+       */
+       result SetFormat(CodecType audioCodec, MediaContainerType container);
+
+       /**
+       * Gets the audio codec and container of an audio recorder.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[out]   audioCodec                      The retrieved audio codec
+       * @param[out]   container                       The retrieved container
+       * @exception    E_SUCCESS                       The method is successful.
+       * @remarks              If SetFormat(CodecType audioCodec, MediaContainerType container) is not called before calling
+       *                               this method, the default codec and container are retrieved. @n
+       *                               This method always returns E_SUCCESS.
+       * @see                  SetFormat( CodecType audioCodec, MediaContainerType container )
+       */
+       result GetFormat(CodecType& audioCodec, MediaContainerType& container) const;
+
+       /**
+       * Gets a list of the supported audio codecs. @n
+       * Each list's item has a ::CodecType value.
+       *
+       * @since                2.0
+       *
+       * @return       A list of supported audio codecs, @n
+       *                               else @c null if no codec is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *               The return value must be released by the caller.
+       * @see                  SetFormat(CodecType audioCodec, MediaContainerType container)
+        * @see         GetFormat(CodecType& audioCodec, MediaContainerType& container) const
+       */
+       Tizen::Base::Collection::IListT <CodecType>* GetSupportedCodecListN(void) const;
+
+       /**
+       * Gets a list of the supported containers. @n
+       * Each list's item has a ::MediaContainerType value.
+       *
+       * @since                2.0
+       *
+       * @return       A list of supported container list, @n
+       *                               else @c null if no container is supported or if an exception occurs
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *               The return value must be released by the caller.
+       * @see                  SetFormat(CodecType audioCodec, MediaContainerType container)
+        * @see         GetFormat(CodecType& audioCodec, MediaContainerType& container) const
+       */
+       Tizen::Base::Collection::IListT <MediaContainerType>* GetSupportedContainerListN(void) const;
+
+       /**
+       * Sets the audio recording quality of the audio recorder.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @param[in]    quality                         The audio recording quality of the audio recorder @n
+       *                                                                       The default value is ::RECORDING_QUALITY_MEDIUM.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c quality is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @see                  GetQuality()
+       */
+       result SetQuality(RecordingQuality quality);
+
+       /**
+       * Gets the audio recording quality of the audio recorder.
+       *
+       * @since                2.0
+       *
+       * @return               The current audio recording quality of the audio recorder
+       * @see                  SetQuality()
+       */
+       RecordingQuality GetQuality(void) const;
+
+       /**
+       * Sets the mute state of an audio recorder.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/audiorecorder
+       *
+       * @return               An error code
+       * @param[in]    mute                The mute state @n
+       *                                                                       By default, the mute state is disabled.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The audio recording continues even though the audio recorder is in the mute state.
+       * @see                  IsMuted()
+       */
+       result SetMute(bool mute);
+
+       /**
+       * Checks whether the mute state is enabled for an audio recorder.
+       *
+       * @since                2.0
+       *
+       * @return               @c true if the audio recorder is not recording any sound, @n
+       *                               else @c false
+       * @see                  SetMute()
+       */
+       bool IsMuted(void) const;
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        * @see                 Construct()
+        */
+       AudioRecorder(const AudioRecorder&);
+       /**
+        * This is the copy assignment operator for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        */
+       AudioRecorder& operator =(const AudioRecorder& audioRecorder);
+
+       friend class _AudioRecorderImpl;
+       _AudioRecorderImpl* __pImpl;
+
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaAudioRecorderTypes.h b/inc/FMediaAudioRecorderTypes.h
new file mode 100755 (executable)
index 0000000..9252e14
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaAudioRecorderTypes.h
+ * @brief                      This is the header file for the %AudioRecordingFormat enumeration.
+ *
+ * This header file contains the descriptions for the %AudioRecordingFormat enumeration.
+ */
+
+#ifndef _FMEDIA_AUDIO_RECORDER_TYPES_H_
+#define _FMEDIA_AUDIO_RECORDER_TYPES_H_
+
+#include <FMediaRecorderTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+// The default audio recording time - 60 seconds
+#define DEFAULT_AUDIORECORDING_TIME (60 * 1000)
+
+// The default audio recording size - 300 kb
+#define DEFAULT_AUDIORECORDING_SIZE (300 * 1024)
+
+/**
+ * @if OSPDEPREC
+ * @enum AudioRecordingFormat
+ *
+ * Defines the formats for audio recording.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This enum is deprecated because new methods do not use it. @n
+ * Instead of using this enum, use ::MediaContainerType.
+ *
+ * @since              2.0
+ *
+ * @see                AudioRecorder::SetFormat(), AudioRecorder::GetFormat()
+ * @endif
+ */
+enum AudioRecordingFormat
+{
+       AUDIORECORDING_FORMAT_DEFAULT,              /**< @if OSPDEPREC The default format @endif */
+       AUDIORECORDING_FORMAT_AMR,                  /**< @if OSPDEPREC The AMR format  @endif */
+       AUDIORECORDING_FORMAT_WAVE,                 /**< @if OSPDEPREC The WAVE format @endif */
+};
+
+}}//Tizen::Media
+
+#endif
diff --git a/inc/FMediaAudioRouteInfo.h b/inc/FMediaAudioRouteInfo.h
new file mode 100644 (file)
index 0000000..2b1e93c
--- /dev/null
@@ -0,0 +1,191 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                        FMediaAudioRouteInfo.h
+* @brief               This is the header file for the common types of audio route information.
+*
+* This header files contains all the commons things required for audio route information and associated classes
+*
+*/
+#ifndef _FMEDIA_AUDIO_ROUTE_INFO_H_
+#define _FMEDIA_AUDIO_ROUTE_INFO_H_
+
+#include <FMediaAudioManagerTypes.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @if VISPARTNER
+ *     @class AudioRouteInfo
+ * @brief      This class contains audio route information
+ *
+ *     @since          2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * @visibility                 partner
+ *
+ *     @remarks  Audio routing can be done using this class instances as input/output audio devices
+ * @endif
+ */
+class _OSP_EXPORT_ AudioRouteInfo
+       :public Tizen::Base::Object
+{
+public:
+       /**
+       * @if VISPARTNER
+       *       Initializes this instance of %AudioRouteInfo with the specified audio devices.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *
+       *       @param[in]                      in                                                                              The input audio device
+       *       @param[in]                      out                                                                     The output audio device
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_OUT_OF_MEMORY         Not enough memory to perform the operation
+       *
+       *       @endif
+       */
+       AudioRouteInfo(InputAudioDevice in, OutputAudioDevice out);
+
+       /**
+       * @if VISPARTNER
+       *       This destructor overrides Tizen::Base::Object::~Object().
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @endif
+       */
+       virtual ~AudioRouteInfo(void);
+
+       /**
+       * @if VISPARTNER
+       *       Sets the input audio device
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *
+       *       @param[in]                      in                                                                              The input audio device
+       *       @endif
+       */
+       void SetInputAudioDevice(InputAudioDevice in);
+
+       /**
+       * @if VISPARTNER
+       *       Sets the output audio device
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *
+       *       @param[in]                      out                                                                     The output audio device
+       *       @endif
+       */
+       void SetOutputAudioDevice(OutputAudioDevice out);
+
+       /**
+       * @if VISPARTNER
+       *       Gets the input audio device
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *
+       *       @return                         Input audio device
+       *       @endif
+       */
+       InputAudioDevice GetInputAudioDevice(void) const;
+
+       /**
+       * @if VISPARTNER
+       *       Gets the output audio device
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *
+       *       @return                         Output audio device
+       *       @endif
+       */
+       OutputAudioDevice GetOutputAudioDevice(void) const;
+
+       /**
+       * @if VISPARTNER
+       * Copying of objects using this copy constructor is allowed.
+       *
+       * @since                2.0
+       *
+       * @visibility                           partner
+       *
+       * @return               The copy of this instance
+       * @param[in]    rhs     An instance of %AudioRouteInfo
+       * @endif
+       */
+       AudioRouteInfo(const AudioRouteInfo& rhs);
+
+       /**
+       * @if VISPARTNER
+       *       Copying of objects using this copy assignment operator is allowed.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *
+       *       @return                         The instance of AudioRouteInfo
+       *       @param[in]                      rhs                                                                     AudioRouteInfo instance
+       *       @endif
+       */
+       AudioRouteInfo& operator =(const AudioRouteInfo& rhs);
+
+       /**
+       * @if VISPARTNER
+       *       Compares the specified instance of %AudioRouteInfo with the calling instance.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *
+       *       @return                         @c true if the object is the same,@n
+                                                                       else @c false
+       *       @param[in]                      obj                                                                     The object
+       *       @endif
+       */
+       virtual bool Equals(const Object& obj) const;
+
+       /**
+       * @if VISPARTNER
+       *       Gets the hash code for %AudioRouteInfo instance
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *
+       *       @return                         Hash code
+       *       @endif
+       */
+       virtual int GetHashCode(void) const;
+
+private:
+       class _AudioRouteInfoImpl* __pAudioRouteInfoImpl;
+};
+
+}}     //Tizen::Media
+#endif
diff --git a/inc/FMediaAudioRouteManager.h b/inc/FMediaAudioRouteManager.h
new file mode 100755 (executable)
index 0000000..5269b05
--- /dev/null
@@ -0,0 +1,358 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaAudioRouteManager.h
+ * @brief              This is the header file for the %AudioRouteManager class.
+ *
+ * This header file contains the declarations of the %AudioRouteManager class.
+ */
+
+#ifndef _FMEDIA_AUDIO_ROUTE_MANAGER_H_
+#define _FMEDIA_AUDIO_ROUTE_MANAGER_H_
+
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaIAudioRouteEventListener.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @if VISPARTNER
+ *     @class AudioRouteManager
+ * @brief      This class is used to manage audio routing.
+ *
+ *     @since          2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ *     @remarks   Only one instance of the class works at a time.
+ *
+ * The following example demonstrates how to use the %AudioEqualizer class.
+ *
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Media;
+ *
+ * class RouteManagerSample
+ *     : public Tizen::Media::IPlayerEventListener
+ *     ,       public Tizen::Media::IAudioRouteEventListener
+  * {
+ * public:
+ *     result Initialize(void);
+ *     result Play(void);
+ *     result Route(void);
+ *     void Stop(void);
+ *
+ * protected:
+ *     // IPlayerEventListener
+ *     virtual void OnPlayerOpened(result r) {}
+ *     virtual void OnPlayerEndOfClip(void) {}
+ *     virtual void OnPlayerBuffering(int percent) {}
+ *     virtual void OnPlayerErrorOccurred(PlayerErrorReason r) {}
+ *     virtual void OnPlayerInterrupted(void) {}
+ *     virtual void OnPlayerReleased(void) {}
+ *     virtual void OnPlayerSeekCompleted(result r) {}
+ *     virtual void OnPlayerAudioFocusChanged (void) {}
+ *
+ *     virtual void OnActiveAudioRouteChanged(const Tizen::Media::AudioRouteInfo& route)       {}
+ *     virtual void OnAudioRouteAdded(const Tizen::Media::AudioRouteInfo& route) {}
+ *     virtual void OnAudioRouteRemoved(const Tizen::Media::AudioRouteInfo& route) {}
+ *
+ *
+ * private:
+ *     Player __player;
+ *     AudioRouteManager *__pAudioRouteManager;
+ * };
+ *
+ * result
+ * RouteManagerSample::Initialize(void)
+ * {
+ *     result r = E_SUCCESS;
+ *     String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp3";
+ *
+ *     r = __player.Construct(*this);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *                __pAudioRouteManager = AudioRouteManager::GetInstance();
+ *              if (!__pAudioRouteManger)
+ *        {
+ *                             return E_OUT_OF_MEMORY;
+ *             }
+ *
+ *     r = __player.OpenFile(filePath, false);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *     return r;
+ * }
+ *
+ *
+ * result
+ * RouteManagerSample::Play(void)
+ * {
+  * result r = E_SUCCESS;
+  * r = __player.Play();
+  * return r;
+ * }
+ *
+ * result
+ * RouteManagerSample::Route(void)
+ * {
+ *       result r = E_SUCCESS;
+ *   IList *pAudioDeviceList = null;
+ *   int count;
+ *
+ *     pAudioDeviceList = __pAudioRouteManager->GetAvailableaudioRouteListN();
+ *     count = pAudioDeviceList->GetCount();
+ *     if (count)
+ *     {
+ *     AudioRouteInfo *audioDevice = (AudioRouteInfo *) pAudioDeviceList->GetAt(0);
+ *     r = __pAudioRouteManager->SetActiveAudioRoute(*audioDevice);
+ *      if (IsFailed(r))
+ *                     {
+ *             return r;
+ *                     }
+ *             }
+ *             pAudioDeviceList->RemoveAll();
+ *             pAudioDeviceList = null;
+ *
+ *       return r;
+ * }
+ *
+ *
+ * void
+ * RouteManagerSample::Stop(void)
+ * {
+ *     __player.Stop();
+ *     __player.Close();
+ * }
+ *
+ * @endcode
+ *
+ * @endif
+ */
+
+class _OSP_EXPORT_ AudioRouteManager
+       :public Tizen::Base::Object
+{
+public:
+       /**
+       *       @if VISPARTNER
+       *       Gets the audio route manager instance pointer
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.route
+       *
+       *       @return                 A pointer to the audio route manager instance, @n
+                                                                       else @c null if it fails
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_OUT_OF_MEMORY                 Not enough memory to perform the operation
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks                The specific error code can be accessed using the GetLastResult() method.
+       *       @endif
+       */
+       static AudioRouteManager* GetInstance(void);
+
+       /**
+       *       @if VISPARTNER
+       *       Sets audio route event listener
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.route
+       *
+       *       @return                                 An error code
+       *       @param[in]                              pListener                                                       The audio route event listener. @n
+                                                                                                                                                               To unset the listener, pass a @c null value to the listener parameter.
+       *       @exception                      E_SUCCESS                                                       The method is successful
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @endif
+       */
+       result SetAudioRouteEventListener(IAudioRouteEventListener* pListener);
+
+       /**
+       *       @if VISPARTNER
+       *       Gets the name of the active bluetooth A2DP device
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.route
+       *
+       *       @return                         The name of active bluetooth A2DP device
+       *       @exception                      E_SUCCESS                                                       The method is successful
+       *       @exception                      E_DEVICE_UNAVAILABLE            A2DP device is not connected or available
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @endif
+       */
+       Tizen::Base::String GetActiveBluetoothA2dpName(void) const;
+
+       /**
+       *       @if VISPARTNER
+       *       Gets the active audio stream type
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.route
+       *
+       *       @return                                 An active audio stream type
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks                                AUDIO_STREAM_TYPE_NO_SOUND is returned when no sound is playing
+       *       @endif
+       */
+       AudioStreamType GetActiveAudioStreamType(void) const;
+
+       /**
+       *       @if VISPARTNER
+       *       Gets available audio routes
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.route
+       *
+       *       @return                                 The list of available audio routes, @n
+                                                                               else @c null if it fails
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_OUT_OF_MEMORY                 No memory to make the list
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remark                                 The item type of returned list is AudioRouteInfo.
+       *       @endif
+       */
+       Tizen::Base::Collection::IList* GetAvailableAudioRouteListN(void) const;
+
+       /**
+       *       @if VISPARTNER
+       *       Checks the specified route availability.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.route
+       *
+       *       @return                                 @c true if the audio route is available,@n
+                                                                       else @c false
+       *       @param[in]                              route                                                                   Audio route
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_INVALID_ARG                                   A specified input parameter is invalid
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @endif
+       */
+       bool IsAudioRouteAvailable(const AudioRouteInfo& route) const;
+
+       /**
+       *       @if VISPARTNER
+       *       Sets the active audio route
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.route
+       *
+       *       @return                                 An error code
+       *       @param[in]                              route                                                           Audio route to set
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_INVALID_ARG                                   A specified input parameter is invalid
+       *       @exception                      E_DEVICE_UNAVAILABLE                    Audio route is not available
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @endif
+       */
+       result SetActiveAudioRoute(const AudioRouteInfo& route);
+
+       /**
+       *       @if VISPARTNER
+       *       Gets the active audio route
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.route
+       *
+       *       @return                                 The active audio route
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks INPUT_AUDIO_DEVICE_NONE and OUTPUT_AUDIO_DEVICE_NONE are set in AudioRouteInfo if fails.
+       *       @endif
+       */
+       AudioRouteInfo GetActiveAudioRoute(void) const;
+
+
+private:
+       /**
+        * @if VISPARTNER
+        * This default constructor is intentionally declared as private to implement the Singleton semantic.
+        *
+        * @since               2.0
+        *
+        * @visibility          partner
+        * @endif
+        */
+       AudioRouteManager(void);
+
+       /**
+       *  @if VISPARTNER
+       *       This destructor is intentionally declared as private to implement the Singleton semantic.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *       @endif
+       */
+       virtual ~AudioRouteManager(void);
+
+       /**
+        * @if VISPARTNER
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        *
+        * @visibility          partner
+        * @endif
+        */
+       AudioRouteManager(const AudioRouteManager& rhs);
+
+       /**
+        * @if VISPARTNER
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        *
+        * @visibility          partner
+        * @endif
+        */
+       AudioRouteManager& operator =(const AudioRouteManager& rhs);
+
+       class _AudioRouteManagerImpl* __pAudioRouteManagerImpl;
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaAudioSessionManager.h b/inc/FMediaAudioSessionManager.h
new file mode 100755 (executable)
index 0000000..45685fd
--- /dev/null
@@ -0,0 +1,185 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaAudioSessionManager.h
+ * @brief              This is the header file for the %AudioSessionManager class.
+ *
+ * This header file contains the declarations of the %AudioSessionManager class.
+ */
+
+#ifndef _FMEDIA_AUDIO_SESSION_MANAGER_H_
+#define _FMEDIA_AUDIO_SESSION_MANAGER_H_
+
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaIAudioSessionEventListener.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @if VISPARTNER
+ *     @class AudioSessionManager
+ * @brief      This class is used to manage application's audio session.
+ * This will handle the audio session policy between applications.
+ * The audio session will be applied when an media-related instance is constructed right after the given session is set.
+ * As the precondition, all media-related instances MUST be destroyed before the audio session mode is set.
+ *
+ *     @since          2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ *     @visibility                     partner
+ *
+ *     @remarks   Only one instance of the class works at a time.
+ * @endif
+ */
+
+class _OSP_EXPORT_ AudioSessionManager
+       :public Tizen::Base::Object
+{
+public:
+       /**
+       *       @if VISPARTNER
+       *       Gets the audio session manager's pointer.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.session
+       *
+       *       @return                 A pointer to the audio session manager, @n
+                                                                       else @c null if it fails
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_OUT_OF_MEMORY                 Not enough memory to perform the operation
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks                The specific error code can be accessed using the GetLastResult() method.
+       *       @endif
+       */
+       static AudioSessionManager* GetInstance(void);
+
+       /**
+       * @if VISPARTNER
+       *       Sets the event listener that receives audio session related events.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.session
+       *
+       *       @return                                 An error code
+       *       @param[in]                              pListener                                                       The event listener @n
+                                                                                                                                                               To unset the listener, pass a @c null value to the listener parameter
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception              E_INVALID_STATE                         The audio session state is not valid.
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks                        All media-related instances MUST be destroyed before the audio session mode is set.@n
+                                                                       if not,  this method returns E_INVALID_STATE.
+       *       @endif
+       */
+       result SetAudioSessionEventListener(IAudioSessionEventListener* pListener);
+
+       /**
+       * @if VISPARTNER
+       *       Sets application's audio session mode.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.session
+       *
+       *       @return                                 An error code
+       *       @param[in]                              sessionMode                                             The audio session mode to set
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_INVALID_ARG                                   A specified input parameter is invalid
+       *       @exception                      E_INVALID_STATE                         The audio session state is not valid.
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks                        All media-related instances MUST be destroyed before the audio session mode is set.@n
+                                                                       if not,  this method returns E_INVALID_STATE.
+       *       @endif
+       */
+       result SetMode(AudioSessionMode sessionMode);
+
+       /**
+       * @if VISPARTNER
+       *       Gets application's audio session mode.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.session
+       *
+       *       @return                         The audio session mode of application
+       *       @exception                      E_SUCCESS                                                       The method is successful
+       *       @exception              E_INVALID_STATE                         The audio session state is not valid.
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks        This method will return the default session mode before the audio session mode is set.
+       *       @endif
+       */
+       AudioSessionMode GetMode(void) const;
+
+private:
+       /**
+       *       @if VISPARTNER
+       *       This default constructor is intentionally declared as private to implement the Singleton semantic.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *       @endif
+       */
+       AudioSessionManager(void);
+
+       /**
+       *  @if VISPARTNER
+       *       This destructor is intentionally declared as private to implement the Singleton semantic.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *       @endif
+       */
+       virtual ~AudioSessionManager(void);
+
+       /**
+        * @if VISPARTNER
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        *
+        * @visibility          partner
+        * @endif
+        */
+       AudioSessionManager(const AudioSessionManager& rhs);
+
+       /**
+        * @if VISPARTNER
+        * The implementation of this copy assignment  operator is intentionally blank and declared as private to prohibit assigning of objects.
+        *
+        * @since               2.0
+        *
+        * @visibility          partner
+        * @endif
+        */
+       AudioSessionManager& operator =(const AudioSessionManager& rhs);
+
+       class _AudioSessionManagerImpl* __pAudioSessionManagerImpl;
+
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaAudioStreamInfo.h b/inc/FMediaAudioStreamInfo.h
new file mode 100644 (file)
index 0000000..42a9c84
--- /dev/null
@@ -0,0 +1,151 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaAudioStreamInfo.h
+ * @brief                      This is the header file for the %AudioStreamInfo class.
+ *
+ * This header file contains the declarations of the %AudioStreamInfo class.
+ */
+
+#ifndef _FMEDIA_AUDIO_STREAM_INFO_H_
+#define _FMEDIA_AUDIO_STREAM_INFO_H_
+
+#include <FBaseObject.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @class       AudioStreamInfo
+ * @brief       This class provides methods to get audio stream information.
+ *
+ * @since              2.0
+ *
+ * The %AudioStreamInfo class provides methods to get audio stream information, such as codec type, bit rate, sample rate, and channel count.
+ *
+ */
+
+class _OSP_EXPORT_ AudioStreamInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since                2.0
+       */
+       virtual ~AudioStreamInfo(void);
+
+public:
+       /**
+       * Gets the encoding type of an audio stream.
+       *
+       * @since                2.0
+       *
+       * @return               The value of the encoding type
+       *
+       */
+       CodecType GetCodecType(void) const;
+
+       /**
+       * Gets the bit rate of an audio.
+       *
+       * @since                2.0
+       *
+       * @return                        The audio bit rate in bits per second (bps)
+       */
+       int GetBitRate(void) const;
+
+       /**
+       * Gets the sampling rate of an audio.
+       *
+       * @since                2.0
+       *
+       * @return                        The audio sampling rate in hertz (Hz)
+       */
+       int GetSampleRate(void) const;
+
+       /**
+       * Gets the audio channel of an audio.
+       *
+       * @since                2.0
+       *
+       * @return                        The audio channel type
+       */
+       AudioChannelType GetChannelType(void) const;
+
+       /**
+       * Copying of objects using this copy constructor is allowed.
+       *
+       * @since                2.0
+       *
+       * @return               The copy of this instance
+       * @param[in] rhs An instance of %AudioStreamInfo
+       */
+       AudioStreamInfo(const AudioStreamInfo & rhs);
+
+       /**
+       * Copying of objects using this copy assignment operator is allowed.
+       *
+       * @since                2.0
+       *
+       * @return The reference of this instance
+       * @param[in] rhs An instance of %AudioStreamInfo
+       */
+       AudioStreamInfo & operator =(const AudioStreamInfo & rhs);
+
+       /**
+       * Compares the specified instance of Tizen::Base::Object with the calling instance of %AudioStreamInfo.
+       *
+       * @since                2.0
+       *
+       * @return   @c true if the value of the specified instance equals the value of the current instance, @n
+       *                       else @c false
+       * @param[in]    rhs      The object to compare with the current instance
+       */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+       * Gets the hash value of the current instance.
+       *
+       * @since                2.0
+       *
+       * @return   The hash value of the current instance
+       */
+       virtual int GetHashCode(void) const;
+
+private:
+       /**
+       * This default constructor is intentionally declared as private so that only the platform can create an instance.
+       *
+       * @param [in]   codecType       The value of encoding type @n
+       * @param [in]   bitrate         The audio bit rate in bits per second (bps) @n
+       * @param [in]   sampleRate      The audio sample rate in hertz (Hz) @n
+       * @param [in]   channel         The audio channel type @n
+       */
+       AudioStreamInfo(CodecType codecType, int bitrate, int sampleRate, AudioChannelType channel);
+
+private:
+       class _AudioStreamInfoImpl *__pAudioStreamInfoImpl;
+       friend class _PlayerImpl;
+};
+
+}}//Tizen::Media
+
+#endif
diff --git a/inc/FMediaAudioTypes.h b/inc/FMediaAudioTypes.h
new file mode 100644 (file)
index 0000000..c577516
--- /dev/null
@@ -0,0 +1,125 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                        FMediaAudioTypes.h
+* @brief               This is the header file for the common types of AudioIn and AudioOut.
+*
+* This header file contains the declarations of the enumerations of the Audio In/Out classes.
+*/
+#ifndef _FMEDIA_AUDIO_TYPES_H_
+#define _FMEDIA_AUDIO_TYPES_H_
+
+namespace Tizen { namespace Media
+{
+
+#define MIN_AUDIOOUT_VOLUME 0
+#define MAX_AUDIOOUT_VOLUME 100
+#define DEFAULT_AUDIOOUT_VOLUME 50
+
+/**
+ * @enum AudioInputDevice
+ *
+ * Defines the audio input device.
+ *
+ * @since              2.0
+ *
+ * @see        AudioIn::Prepare()
+ */
+enum AudioInputDevice
+{
+       AUDIO_INPUT_DEVICE_MIC,     /**< The audio input device is a microphone */
+};
+
+/**
+ * @enum AudioChannelType
+ *
+ * Defines the audio channel type.
+ *
+ * @since              2.0
+ *
+ * @see        AudioIn::Prepare(), AudioOut::Prepare()
+ */
+enum AudioChannelType
+{
+       AUDIO_CHANNEL_TYPE_NONE,    /**< The audio channel type is none */
+       AUDIO_CHANNEL_TYPE_MONO,    /**< The audio channel type is mono */
+       AUDIO_CHANNEL_TYPE_STEREO,  /**< The audio channel type is stereo */
+};
+
+/**
+ * @enum AudioSampleType
+ *
+ * Defines the audio sample type with bit depth.
+ *
+ * @since              2.0
+ *
+ * @see        AudioIn::Prepare(), AudioOut::Prepare()
+ */
+enum AudioSampleType
+{
+       AUDIO_TYPE_NONE,        /**< The audio encoding type is none */
+       AUDIO_TYPE_PCM_U8,      /**< The 8-bit samples are unsigned */
+       AUDIO_TYPE_PCM_S8,      /**< The 8-bit samples are signed */
+       AUDIO_TYPE_PCM_U16_LE,  /**< The 16-bit little-endian samples are unsigned */
+       AUDIO_TYPE_PCM_U16_BE,  /**< The 16-bit big-endian samples are unsigned */
+       AUDIO_TYPE_PCM_S16_LE,  /**< The 16-bit little-endian samples are signed */
+       AUDIO_TYPE_PCM_S16_BE   /**< The 16-bit big-endian samples are signed */
+};
+
+/**
+ * @enum AudioInState
+ *
+ * Defines the audio input state.
+ *
+ * @since              2.0
+ *
+ * @see        AudioIn::GetState()
+ */
+enum AudioInState
+{
+       AUDIOIN_STATE_INITIALIZED,      /**< The device is initialized */
+       AUDIOIN_STATE_PREPARED,         /**< The device is prepared */
+       AUDIOIN_STATE_RECORDING,        /**< The device is recording */
+       AUDIOIN_STATE_STOPPED,          /**< The device is stopped */
+       AUDIOIN_STATE_UNPREPARED,       /**< The device is uninitialized */
+       AUDIOIN_STATE_ERROR,            /**< An error has occurred */
+};
+
+/**
+ * @enum AudioOutState
+ *
+ * Defines the audio output state.
+ *
+ * @since              2.0
+ *
+ * @see        AudioOut::GetState()
+ */
+enum AudioOutState
+{
+       AUDIOOUT_STATE_INITIALIZED,     /**< The device is initialized */
+       AUDIOOUT_STATE_PREPARED,        /**< The device is prepared */
+       AUDIOOUT_STATE_PLAYING,         /**< The device is playing data */
+       AUDIOOUT_STATE_STOPPED,         /**< The device is stopped */
+       AUDIOOUT_STATE_UNPREPARED,      /**< The device is uninitialized */
+       AUDIOOUT_STATE_ERROR,           /**< An error has occurred */
+};
+
+}} // Tizen::Media
+
+
+#endif
diff --git a/inc/FMediaCamera.h b/inc/FMediaCamera.h
new file mode 100755 (executable)
index 0000000..f5f245c
--- /dev/null
@@ -0,0 +1,1425 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaCamera.h
+ * @brief                      This is the header file for the %Camera class.
+ *
+ * This header file contains the declarations of the %Camera class.
+ */
+
+#ifndef _FMEDIA_CAMERA_H_
+#define _FMEDIA_CAMERA_H_
+
+#include <FBase.h>
+#include <FGraphics.h>
+#include <FMediaCameraTypes.h>
+#include <FMediaICameraEventListener.h>
+
+namespace Tizen { namespace Media
+{
+
+class _CameraImpl;
+
+/**
+ * @class      Camera
+ * @brief      This class controls the camera device.
+ *
+ * @since              2.0
+ *
+ *
+ * The %Camera class controls the camera device.
+ * The supported properties are device-dependent. The list of the properties available can be retrieved using the methods of %Camera and MediaCapability classes.
+ * All the other methods, except SetAutoFocus(), StartPreview(), and Capture() work synchronously.
+ * The previewed or captured data are passed through ICameraEventListener. @n
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/capturing_still_images.htm">Capturing Still Images</a>.
+ *
+ * The following example demonstrates how to use the %Camera class.
+ *
+ * @code
+ * #include <FBase.h>
+ * #include <FGraphics.h>
+ * #include <FUi.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Graphics;
+ * using namespace Tizen::Ui;
+ * using namespace Tizen::Ui::Controls;
+ * using namespace Tizen::Media;
+ *
+ * class CameraSample
+ *     : public Tizen::Ui::Controls::Form
+ *     , public Tizen::Media::ICameraEventListener
+ * {
+ * public:
+ *     CameraSample(void);
+ *     result Start(void);
+ *     void Stop(void);
+ *
+ * protected:
+ *     virtual void OnCameraAutoFocused(bool completeCondition) {}
+ *     virtual void OnCameraPreviewed( Tizen::Base::ByteBuffer& previewedData, result r) {}
+ *     virtual void OnCameraCaptured( Tizen::Base::ByteBuffer& capturedData, result r) {}
+ *     virtual void OnCameraErrorOccurred(CameraErrorReason r ) {}
+ *
+ * private:
+ *     Camera __camera;
+ *     OverlayRegion * __pOverlay;
+ * };
+ *
+ * CameraSample::CameraSample(void)
+ * {
+ *     __pOverlay = null;
+ * }
+ *
+ * result
+ * CameraSample::Start(void)
+ * {
+ *     result r = E_SUCCESS;
+ *     Rectangle rect(0, 0, 320, 240);
+ *     bool modified = false;
+ *     bool isValid = false;
+ *     BufferInfo bufferInfo;
+ *
+ *     r = __camera.Construct(*this, CAMERA_PRIMARY);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     r = __camera.PowerOn();
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     isValid = OverlayRegion::EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_LESS_THAN, rect, modified);
+ *     if (isValid != true)
+ *     {
+ *         return GetLastResult();
+ *     }
+ *
+ *     // Gets OverlayRegion from this Form
+ *     __pOverlay = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_PRIMARY_CAMERA);
+ *     if (__pOverlay == null)
+ *     {
+ *         return GetLastResult();
+ *     }
+ *
+ *     __pOverlay->GetBackgroundBufferInfo(bufferInfo);
+ *
+ *     r = __camera.StartPreview(&bufferInfo, true);
+ *     if (IsFailed(r))
+ *     {
+ *         goto CATCH;
+ *     }
+ *
+ *     return E_SUCCESS;
+ * CATCH:
+ *     if (__pOverlay)
+ *     {
+ *         delete __pOverlay;
+ *         __pOverlay = null;
+ *     }
+ *     return r;
+ *  }
+ *
+ * void
+ * CameraSample::Stop(void)
+ * {
+ *     __camera.StopPreview();
+ *     __camera.PowerOff();
+ *     if (__pOverlay)
+ *     {
+ *         delete __pOverlay;
+ *         __pOverlay = null;
+ *     }
+ * }
+ *
+ * @endcode
+ *
+ *
+ */
+class _OSP_EXPORT_ Camera
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The object is not fully constructed after this constructor is called. For full construction,
+        * the Construct() method must be called right after calling this constructor.
+        */
+       Camera(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method must be called in the same thread
+        * where the Construct() method is called.This polymorphic destructor should be overridden if required.
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since               2.0
+        *
+        */
+       virtual ~Camera(void);
+
+       /**
+       * Initializes this instance of %Camera with the specified parameters. @n
+       * The %Construct() method creates an instance of %Camera in the subsystem. Only one instance is created at a given time.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    listener                                An instance of ICameraEventListener
+       * @param[in]    camSel                                  The %Camera to power on
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The camera is under use by other application or already used in this application.
+       * @exception    E_DEVICE_UNAVAILABLE    The camera is unavailable.
+       * @exception    E_UNSUPPORTED_OPERATION The camera usage is not supported.
+       * @exception    E_OUT_OF_MEMORY The memory is insufficient.
+       */
+       result Construct(ICameraEventListener& listener, CameraSelection camSel = CAMERA_PRIMARY);
+
+       /**
+       * Powers the camera on.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                   The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE    The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                 The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The reserved configurations are set in this method.
+       * @see                  PowerOff()
+       */
+       result PowerOn(void);
+
+       /**
+       * Powers the camera off.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                   The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE    The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                 The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  PowerOn()
+       */
+       result PowerOff(void);
+
+       /**
+       * Checks whether the camera is powered on.
+       *
+       * @since                2.0
+       *
+       * @return               @c true if the camera is powered on, @n
+       *                               else @c false
+       * @see                  PowerOn(), PowerOff()
+       */
+       bool IsPoweredOn(void) const;
+
+       /**
+       * Starts displaying the preview image on the camera device. @n
+       * If the value of @c pBufferInfo is @c null, no preview image is displayed. In this case, the application can
+       * draw the preview image with the data passed on by the ICameraEventListener::OnCameraPreviewed() method.
+       *
+       * If the value of @c previewedData is @c true, the previewed image data is passed to the
+       * ICameraEventListener::OnCameraPreviewed() method periodically based on the frame-rate, otherwise the
+       * callback is not invoked. The default value of @c previewedData is @c false.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    pBufferInfo                             The buffer information for the camera preview display
+       * @param[in]    previewedData                   Set to @c true if the previewed data is delivered to the callback method, @n
+       *                                                                               else @c false
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_DEVICE_BUSY                   The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE    The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                 The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The overlay region retrieved by the buffer information must be the topmost window when this method is
+       *                               called.
+       * @remarks              The ICameraEventListener::OnCameraPreviewed() method can be delayed or dropped depending on
+       *                               the system's performance. @n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  StopPreview()
+        * @see         ICameraEventListener::OnCameraPreviewed()
+       */
+       result StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo, bool previewedData = false);
+
+       /**
+       * Stops displaying the preview image on the camera device.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                   The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE    The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                 The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks      For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  StartPreview()
+       */
+       result StopPreview(void);
+
+       /**
+       * Captures the current image data from the camera sensor. @n
+       * After capturing the image, the camera's state changes to ::CAMERA_STATE_CAPTURED. @n
+       * The camera's preview must be restarted by calling the StartPreview() method. @n
+       * In a zero-shutter-lag camera, after capturing the image, the state changes to ::CAMERA_STATE_PREVIEW. @n
+       * The camera does not need to restart the preview in this case. @n
+       * The captured image is passed through ICameraEventListener::OnCameraCaptured().
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support capture feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks      For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @remarks              In a zero-shutter-lag camera, the state changes to ::CAMERA_STATE_PREVIEW after capturing.
+       * @remarks              The zero-shutter-lag capability can be checked using MediaCapability::GetValue(const Tizen::Base::String& key, bool& value) with
+       *                               ::CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, ::CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG keys.
+       * @see                  ICameraEventListener::OnCameraCaptured()
+       */
+       result Capture(void);
+
+       /**
+       * Gets the state of the camera in CameraState.
+       *
+       * @since                2.0
+       *
+       * @return           The current state of the camera
+        * @see         StopPreview()
+        * @see         SetAutoFocus()
+        * @see         Capture()
+       */
+       CameraState GetState(void) const;
+
+       /**
+       * Sets the brightness level of the camera input data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    brightness                                      The brightness level to set @n
+       *                                                                                       The range of this parameter is from @c 0 to @c 9.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified @c brightness is out of range.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support brightness configuration feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The default brightness level is @c 5. @n
+       *                               The device's supported range for the brightness level is from @c 0 to @c 9. @n
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetBrightness()
+       */
+       result SetBrightness(int brightness);
+
+       /**
+       * Gets the brightness level of the camera input data.
+       *
+       * @since                2.0
+       *
+       * @return               The current brightness level @n
+       *                               The returned value ranges from @c 0 to @c 9.
+       * @remarks              The device's supported range for the brightness level is from @c 0 to @c 9.
+       * @see                  SetBrightness()
+       */
+       int GetBrightness(void) const;
+
+       /**
+       * Sets the contrast level of the %Camera input data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return           An error code
+       * @param[in]    contrast                                        The contrast level to set @n
+       *                                                                                       The range of this parameter is from @c 0 to @c 9.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified contrast is out of range.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support contrast configuration feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The default contrast level is @c 5. @n
+       *                               The device's supported range for the contrast level is from @c 0 to @c 9. @n
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetContrast()
+       */
+       result SetContrast(int contrast);
+
+       /**
+       * Gets the contrast level of the camera input data.
+       *
+       * @since                2.0
+       *
+       * @return               The current contrast level @n
+       *                               The returned value ranges from @c 0 to @c 9.
+       * @remarks              The device's supported range for the contrast level is from @c 0 to @c 9.
+       * @see                  SetContrast()
+       */
+       int GetContrast(void) const;
+
+       /**
+       * Zooms in the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support zooming feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method returns E_UNSUPPORTED_OPERATION in the Emulator.
+       *                               If Camera supports only ::CAMERA_ZOOM_TYPE_SMART, the zoom ratio can differ according
+       *                               to the preview, capture, and recording resolutions.
+       *                               The supported zoom types can be obtained by using the
+       *                               MediaCapability::GetValueN(CAMERA_PRIMARY_ZOOM_TYPE) method. @n@n
+       *               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  ZoomOut()
+       * @see          GetZoomLevel()
+       * @see          GetMaxZoomLevel()
+       */
+       result ZoomIn(void);
+
+       /**
+       * Zooms out the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support zooming feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method returns E_UNSUPPORTED_OPERATION in the Emulator.
+       *                               If CameraZoomType supports only ::CAMERA_ZOOM_TYPE_SMART, zoom ratio can differ according to
+       *                               the preview, capture, and recording resolutions.
+       *                               The supported zoom types can be obtained by using the
+       *                               MediaCapability::GetValueN(CAMERA_PRIMARY_ZOOM_TYPE) method. @n@n
+       *               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  ZoomIn()
+       * @see          GetZoomLevel()
+       * @see          GetMaxZoomLevel()
+       */
+       result ZoomOut(void);
+
+       /**
+       * Gets the zoom level of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The current zoom level
+       * @remarks              The zoom level is different for each camera device.
+       * @see                  ZoomIn()
+        * @see             ZoomOut()
+       * @see          GetMaxZoomLevel()
+       */
+       int GetZoomLevel(void) const;
+
+       /**
+       * Gets the maximum zoom level supported by this %Camera.
+       *
+       * @since                2.0
+       *
+       * @return               The maximum zoom level
+       * @remarks              The zoom level is different for each camera device.
+       * @see                  ZoomIn()
+        * @see         ZoomOut()
+        * @see         GetZoomLevel()
+       */
+       int GetMaxZoomLevel(void) const;
+
+       /**
+       * Sets the current resolution of the preview.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    resolution                  The preview resolution @n
+       *                                                                       It must be one of the listed dimensions that are extracted using GetSupportedPreviewResolutionListN().
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The position or size is out of range.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_UNSUPPORTED_OPERATION         The target device does not support preview resolution configuration feature.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method works in the ::CAMERA_STATE_INITIALIZED state. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetPreviewResolution()
+       */
+       result SetPreviewResolution(const Tizen::Graphics::Dimension& resolution);
+
+       /**
+       * Gets the current resolution of the preview.
+       *
+       * @since                2.0
+       *
+       * @return               The current preview resolution
+       * @see                  SetPreviewResolution()
+       */
+       Tizen::Graphics::Dimension GetPreviewResolution(void) const;
+
+       /**
+       * Gets the supported preview resolution list of the %Camera class. @n
+       * Each item in the returned list contains a pointer of Tizen::Graphics::Dimension value.
+       *
+       * @since                2.0
+       *
+       * @return       A list of dimensions that represent the preview resolutions supported by the %Camera class, @n
+       *                               else @c null if no preview resolution is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value and each item in the list must be deleted by the caller.
+       * @see                  SetPreviewResolution()
+        * @see         GetPreviewResolution()
+       */
+       Tizen::Base::Collection::IList* GetSupportedPreviewResolutionListN(void) const;
+
+
+       /**
+       * Sets the capturing resolution of the camera. @n
+       * Initially, the default resolution is set using the internal configuration.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    resolution                                      The display resolution @n
+       *                                                                       The display resolution must be one of the values extracted using GetSupportedCaptureResolutionListN().
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_OUT_OF_RANGE                          The specified resolution is out of range.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support capture resolution configuration feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks                      For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @remarks              In a zero-shutter-lag camera, the default preview format applies this feature correctly. The other preview formats are not guaranteed.
+       * @remarks              The zero-shutter-lag capability can be checked using MediaCapability::GetValue(const Tizen::Base::String& key, bool& value) with
+       *                               ::CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, ::CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG keys.
+       * @see                  GetCaptureResolution()
+       */
+       result SetCaptureResolution(const Tizen::Graphics::Dimension& resolution);
+
+       /**
+       * Gets the resolution for capturing the data of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The current resolution for capturing the data of the camera
+       * @see                  SetCaptureResolution()
+       * @see          GetSupportedCaptureResolutionListN()
+       */
+       Tizen::Graphics::Dimension GetCaptureResolution(void) const;
+
+       /**
+       * Gets a list of the capturing resolutions supported by the %Camera class. @n
+       * Each item of the list has a pointer of the Tizen::Graphics::Dimension value.
+       *
+       * @since                2.0
+       *
+       * @return               A list of the capture resolutions supported by the %Camera class @n
+       *                               else @c null if no capture resolution is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value and each item in the list must be deleted by the caller.
+       * @see                  SetCaptureResolution()
+        * @see         GetCaptureResolution()
+       */
+       Tizen::Base::Collection::IList* GetSupportedCaptureResolutionListN(void) const;
+
+       /**
+       * Sets the effect for the input data of the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    effect                                          The effect for the input data of the camera
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support effect configuration feature.
+       * @exception    E_UNSUPPORTED_TYPE          The specified @c effect is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The default effect is ::CAMERA_EFFECT_NONE.
+       *                               This method returns E_UNSUPPORTED_OPERATION in the Emulator.
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetEffect()
+       */
+       result SetEffect(CameraEffect effect);
+
+       /**
+       * Gets the effect for the input data of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The effect for the input data of the camera
+       * @see                  SetEffect()
+       */
+       CameraEffect GetEffect(void) const;
+
+       /**
+       * @if OSPDEPREC
+       * Sets the camera's flash.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+       * Instead of using this method, use the SetFlashMode() method.
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    flashOn                                         Set to @c true to switch on the flash light, @n
+       *                                                                                       else @c false
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support flash configuration feature.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The flash is switched on when the camera captures a picture. If the value of @c flashOn is
+       *                               set to @c true, this method returns E_UNSUPPORTED_OPERATION in the Emulator. @n
+       *                               SetFlash(true) works same as SetFlashMode(CAMERA_FLASH_MODE_ON) and SetFlash(false) works same as SetFlashMode(CAMERA_FLASH_MODE_OFF). @n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @remarks              In a zero-shutter-lag camera, only the default preview format applies this feature.
+       * @see                  IsFlashOn()
+        * @see         SetFlashMode()
+        * @see         CameraFlashMode
+       *
+       */
+       result SetFlash(bool flashOn)
+       {
+               CameraFlashMode flashMode = CAMERA_FLASH_MODE_ON;
+               if (!flashOn)
+               {
+                       flashMode = CAMERA_FLASH_MODE_OFF;
+               }
+               return SetFlashMode(flashMode);
+       }
+
+       /**
+       * @if OSPDEPREC
+       * Checks whether the camera's flash is switched on.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+       * Instead of using this method, use the GetFlashMode() method.
+       * @since                2.0
+       *
+       * @return               @c true if the flash light is on, @n
+       *                               else @c false
+       * @remarks              This method works same as return (GetFlashMode()!=CAMERA_FLASH_MODE_OFF).
+       * @see                  SetFlash()
+        * @see         GetFlashMode()
+        * @see         CameraFlashMode
+       * @endif
+       */
+       bool IsFlashOn(void) const
+       {
+               return (GetFlashMode() != CAMERA_FLASH_MODE_OFF);
+       }
+
+       /**
+       * Sets the camera's flash mode.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    flashMode                                       flash mode to switch on the flash light.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified flash mode is invalid.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support flash configuration feature.
+       * @exception    E_UNSUPPORTED_TYPE          The specified @c flashMode is not supported.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              Normally the flash splashes before the camera captures a picture. @n
+       *                               ::CAMERA_FLASH_MODE_CONTINUOUS keeps the flash turned on after the method is called until ::CAMERA_FLASH_MODE_OFF is set. @n
+       *                               This method returns E_UNSUPPORTED_OPERATION in the Emulator.
+       * @remarks              In a zero-shutter-lag camera, the default preview format applies this feature correctly. The other preview formats are not guaranteed.
+       * @remarks              The zero-shutter-lag capability can be checked using MediaCapability::GetValue(const Tizen::Base::String& key, bool& value) with
+       *                               ::CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, ::CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG keys.
+       * @see                  GetFlashMode()
+       */
+       result SetFlashMode(CameraFlashMode flashMode);
+
+       /**
+       * Gets the flash mode of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The flash mode of the camera
+       * @remarks              If the %Camera doesn't support the flash mode, this method always returns ::CAMERA_FLASH_MODE_OFF.
+       * @see                  SetFlashMode()
+       */
+       CameraFlashMode GetFlashMode(void) const;
+
+       /**
+       * Sets the exposure level of the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    exposure                                        The camera exposure level @n
+       *                                                                                       The range of this parameter is from @c 0 to @c 9.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified exposure level is out of range.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support exposure configuration feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The default exposure level is @c 5.
+       *                               The supported range for exposure level is from @c 0 to @c 9.
+       *                               This method returns E_UNSUPPORTED_OPERATION in the Emulator.
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetExposure()
+       */
+       result SetExposure(int exposure);
+
+       /**
+       * Gets the exposure level of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               An integer value representing the exposure level of the camera @n
+       *                               The returned value ranges from @c 0 to @c 9.
+       * @remarks              The supported range for exposure level is from @c 0 to @c 9.
+       * @see                  SetExposure()
+       */
+       int GetExposure(void) const;
+
+       /**
+       * Sets the white balance level of the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    whiteBalance                            The camera white balance level
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support white balance configuration feature.
+       * @exception    E_UNSUPPORTED_TYPE          The specified @c whiteBalance is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The default white balance is ::CAMERA_WHITE_BALANCE_AUTO.
+       *                               This method returns E_UNSUPPORTED_OPERATION in the Emulator.
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetWhiteBalance()
+       */
+       result SetWhiteBalance(CameraWhiteBalance whiteBalance);
+
+       /**
+       * Gets the white balance level of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The white balance level of the camera
+       * @see                  SetWhiteBalance()
+       */
+       CameraWhiteBalance GetWhiteBalance(void) const;
+
+       /**
+       * Sets the capturing quality of the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    quality                                         The camera's quality level
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified @c quality is not supported.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION         The target device does not support capturing quality configuration feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The default quality is ::CAMERA_QUALITY_NORMAL.
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetQuality()
+       */
+       result SetQuality(CameraQuality quality);
+
+       /**
+       * Gets the capturing quality of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The %Camera quality level
+       * @see                  SetQuality()
+       */
+       CameraQuality GetQuality(void) const;
+
+       /**
+       * Sets the focus mode of the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    focusMode                               focus mode
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_INVALID_ARG                           The specified focus mode is invalid.
+       * @exception    E_UNSUPPORTED_OPERATION  The target device does not support focus mode configuration feature.
+       * @exception    E_UNSUPPORTED_TYPE                The specified @c focusMode is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks      ::CAMERA_FOCUS_MODE_NONE always throws E_INVALID_ARG.
+       * @see          GetFocusMode()
+       */
+       result SetFocusMode(CameraFocusMode focusMode);
+
+       /**
+       * Gets the focus mode of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The %Camera focus mode
+       * @remarks      If the %Camera does not support the focus mode, this method always returns ::CAMERA_FOCUS_MODE_NONE.
+       * @see          SetFocusMode()
+       */
+       CameraFocusMode GetFocusMode(void) const;
+
+       /**
+       * Sets the auto focus point list.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    pointList                               The auto focus point list which consists of Tizen::Graphics::Point pointers
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_UNSUPPORTED_OPERATION  The target device does not support focus pointing feature.
+       * @exception    E_UNSUPPORTED_TYPE                      This method is not supported for the current focus mode.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks      This method works fine when the current focus mode is @c CAMERA_FOCUS_MODE_NORMAL or @c CAMERA_FOCUS_MODE_MACRO.@n
+       *                       If the input parameter has a empty list, the focus area is changed to the center.
+       * @see          GetAutoFocusPointN()
+       */
+       result SetAutoFocusPoint(const Tizen::Base::Collection::IList& pointList);
+
+       /**
+       * Gets the auto focus point list. @n
+       * Each item of the list has a pointer of the Tizen::Graphics::Point value.
+       *
+       * @since                2.0
+       *
+       * @return               The %Camera auto focus point list @n
+       *               A list of points that represent the auto focus point, @n
+       *                               else @c null if no auto focus point is set or if an exception occurs.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks      The specific error code can be accessed using the GetLastResult() method. @n
+       *                       The return value and each item in the list must be deleted by the caller.
+       * @see          SetAutoFocusPoint()
+       */
+       Tizen::Base::Collection::IList* GetAutoFocusPointN(void) const;
+
+       /**
+       * Sets the auto focus mode of the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    callback                                        Set to @c true to enable auto focus callback, @n
+       *                                                                                       else @c false
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support auto focus feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              If @c callback is set to @c false, the ICameraEventListener::OnCameraAutoFocused() method is not called.
+       *                               This method throws @c E_UNSUPPORTED_OPERATION in the emulator. @n
+       *               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       */
+       result SetAutoFocus(bool callback);
+
+       /**
+       * Sets the capturing format of the camera. @n
+       * Initially, the default format is set using the internal configuration.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    format                                          The camera's capture format @n
+       *                                                                                       It must be one of the pixel formats extracted using GetSupportedCaptureFormatListN().
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_UNSUPPORTED_FORMAT            The specified format is not supported.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support capture format configuration feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method works correctly when PowerOn() is executed.
+       * @see                  GetCaptureFormat()
+       */
+       result SetCaptureFormat(const Tizen::Graphics::PixelFormat format);
+
+       /**
+       * Gets the capturing format of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The capturing format of the camera
+       * @see                  SetCaptureFormat()
+        * @see         GetSupportedCaptureFormatListN()
+       */
+       Tizen::Graphics::PixelFormat GetCaptureFormat(void) const;
+
+       /**
+       * Gets the supported capturing format list for the %Camera class. @n
+       * Each list item has a Tizen::Graphics::PixelFormat value.
+       *
+       * @since                2.0
+       *
+       * @return               A list of the formats supported by the %Camera class, @n
+       *                               else @c null if no capture format is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted.
+       * @see                  SetCaptureFormat()
+        * @see         GetCaptureFormat()
+       */
+       Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* GetSupportedCaptureFormatListN(void) const;
+
+       /**
+       * Sets the preview format of the camera. @n
+       * Initially, the default format is set using the internal configuration.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    format                                          The camera's preview format @n
+       *                                                                                       It must be one of the pixel formats extracted using GetSupportedPreviewFormatListN().
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_UNSUPPORTED_FORMAT            The specified format is not supported.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support preview format configuration feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method works in ::CAMERA_STATE_INITIALIZED state. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetPreviewFormat()
+        * @see         GetSupportedPreviewFormatListN()
+       */
+       result SetPreviewFormat(const Tizen::Graphics::PixelFormat format);
+
+       /**
+       * Gets the preview format of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The preview format of the camera
+       * @see                  SetPreviewFormat()
+        * @see         GetSupportedPreviewFormatListN()
+       */
+       Tizen::Graphics::PixelFormat GetPreviewFormat(void) const;
+
+       /**
+       * Gets the supported preview format list for the %Camera class. @n
+       * Each list item has a Tizen::Graphics::PixelFormat value.
+       *
+       * @since                2.0
+       *
+       * @return               A list of the preview format supported by the %Camera class, @n
+       *                               else @c null if no preview format is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted.
+       * @see                  SetPreviewFormat()
+        * @see         GetPreviewFormat()
+       */
+       Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>* GetSupportedPreviewFormatListN(void) const;
+
+
+       /**
+       * Sets the ISO level of the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    isoLevel                                        The camera's ISO level @n
+       *                                                                                       The default ISO level is set from the internal configuration.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified ISO level is out of range.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION         The target device does not support iso level configuration feature.
+       * @exception    E_UNSUPPORTED_TYPE          The specified @c isoLevel is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              In some devices this method works in the ::CAMERA_STATE_PREVIEW state.
+       *                               This method throws E_UNSUPPORTED_OPERATION in the Emulator. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetIsoLevel()
+       */
+       result SetIsoLevel(CameraIsoLevel isoLevel);
+
+       /**
+       * Gets the ISO level of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The ISO level of the camera
+       * @see                  SetIsoLevel()
+       */
+       CameraIsoLevel GetIsoLevel(void) const;
+
+       /**
+       * Sets the preview frame rate of the camera. @n
+       * Initially, the default frame rate is set using the internal configuration.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    fps                                                     The frame rate per second
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified @c fps is out of range on this device.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION         The target device does not support preview frame rate configuration feature.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method works in ::CAMERA_STATE_INITIALIZED state. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *               state transition caused by this method, see <a href="../org.tizen.native.appprogramming/html/guide/media/launching_camera.htm
+       ">here</a>.
+       * @see                  GetPreviewFrameRate()
+        * @see         GetSupportedPreviewFrameRateListN()
+        * @see         FRAME_RATE_AUTO
+       */
+       result SetPreviewFrameRate(int fps);
+
+       /**
+       * Gets the frame rate of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The frame rate of the camera @n
+       *               If the frame rate is not set using SetPreviewFrameRate(), the system-dependent default frame rate is returned.
+       * @see                  GetSupportedPreviewFrameRateListN()
+       */
+       int GetPreviewFrameRate(void) const;
+
+       /**
+       * Gets the supported preview frame rate list for the %Camera class. @n
+       * Each list item has an integer value.
+       *
+       * @since                2.0
+       *
+       * @return               A list of the preview frame rate supported by the %Camera class, @n
+       *                               else @c null if no frame rate is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted by the caller. @n
+       *                               This method returns fps list that can be supported by all resolutions.
+       * @see                  SetPreviewFrameRate()
+        * @see         GetPreviewFrameRate()
+        * @see         FRAME_RATE_AUTO
+       * @see                  GetSupportedPreviewFrameRateListN(const Tizen::Graphics::Dimension& dim) const
+       */
+       Tizen::Base::Collection::IListT <int>* GetSupportedPreviewFrameRateListN(void) const;
+
+       /**
+       * Gets the supported preview frame rate list of the input resolution of the %Camera class. @n
+       * Each item of the list has an integer value.
+       *
+       * @since                2.0
+       *
+       * @return               A list of the preview frame rate of the input preview resolution, @n
+       *                               else @c null if no frame rate is supported or if an exception occurs
+       * @param[in]    dim                                             The preview resolution of the camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_ARG                   The specified input resolution is invalid.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted by the caller. @n
+       * @see                  SetPreviewFrameRate()
+        * @see         GetPreviewFrameRate()
+       * @see                  GetSupportedPreviewFrameRateListN(void) const
+       */
+       Tizen::Base::Collection::IListT <int>* GetSupportedPreviewFrameRateListN(const Tizen::Graphics::Dimension& dim) const;
+
+       /**
+       * Sets the orientation value in the Exchangeable Image File Format (EXIF) field of the captured data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    orientation                                     The orientation value to set in EXIF
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The input value is out of range.
+       * @exception    E_UNSUPPORTED_OPERATION         The target device does not support exif orientation configuration feature.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              The default value of orientation is @c CAMERA_EXIF_ORIENTATION_TOP_LEFT. @n
+       *                               This method works correctly when PowerOn() is executed. The orientation value set by this method can be obtained using the
+       *                               Tizen::Content::ImageData::GetOrientation() method after writing the captured data to a file.
+       */
+       result SetExifOrientation(CameraExifOrientation orientation);
+
+       /**
+       * Sets the GPS coordinates in the Exchangeable %Image File Format (EXIF) field for the captured data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    latitude                                        The latitude value to set in EXIF @n
+       *                                                                                       The valid range is [-90.0, 90.0].
+       * @param[in]    longitude                                       The longitude value to set in EXIF @n
+       *                                                                                       The valid range is [-180.0, 180.0]
+       * @param[in]    altitude                                        The altitude value to set in EXIF
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The input value is out of range.
+       * @exception    E_UNSUPPORTED_OPERATION         The target device does not support exif gps coordinates configuration feature.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method sets the GPS coordinates and enables entering the coordinates into the Exchangeable Image File Format (EXIF).
+       * @remarks              By default, the GPS coordinates are not entered in JPEG's EXIF.
+       * @remarks              The GPS coordinates that are set using this method are entered in every call to the
+       *                               Capture() method, until DisableExifGpsCoordinates() is called or this instance is destroyed. @n
+       *                               This method works correctly when PowerOn() is executed. @n
+       *                               The values set by this method can result in an error as compared to the values stored in the Exchangeable Image File Format (EXIF) field.
+       */
+       result SetExifGpsCoordinates(double latitude, double longitude, float altitude);
+
+       /**
+       * Disables the insertion of the GPS coordinates in the Exchangeable %Image File Format (EXIF) field for the captured data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The input value is out of range.
+       * @exception    E_UNSUPPORTED_OPERATION         The target device does not support exif gps coordinates configuration feature.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @see          SetExifGpsCoordinates()
+       */
+       result DisableExifGpsCoordinates(void);
+
+       /**
+       * Sets the flip type for the previewed and captured data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    flip                                            The camera flip type
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The input value is out of range.
+       * @exception    E_UNSUPPORTED_OPERATION         The target device does not support flip configuration feature.
+       * @exception    E_UNSUPPORTED_TYPE          The specified @c flip is not supported.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method works in the ::CAMERA_STATE_INITIALIZED state.
+       * @remarks              Finally the last specified type is applied even with the several types applicable.
+       * @remarks              In a zero-shutter-lag camera, the default preview format is not guaranteed to apply this feature correctly.
+       * @remarks              The zero-shutter-lag capability can be checked using MediaCapability::GetValue(const Tizen::Base::String& key, bool& value) with
+       *                               ::CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, ::CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG keys.
+       * @see          GetFlip()
+       */
+       result SetFlip(CameraFlipType flip);
+
+       /**
+       * Gets the flip type for the previewed and captured data.
+       *
+       * @since                2.0
+       *
+       * @return               The camera flip type
+       * @see      SetFlip()
+       */
+       CameraFlipType GetFlip(void) const;
+
+       /**
+       * Sets the rotation for the previewed data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return           An error code
+       * @param[in] rotation                                      The camera rotation
+       * @exception E_SUCCESS                               The method is successful.
+       * @exception E_PRIVILEGE_DENIED         The application does not have the privilege to call this method.
+       * @exception E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception E_INVALID_ARG                    The input value is out of range.
+       * @exception E_UNSUPPORTED_OPERATION            The target device does not support preview rotation configuration feature.
+       * @exception E_UNSUPPORTED_TYPE               The specified @c rotation is not supported.
+       * @exception E_SYSTEM                                A system error has occurred.
+       * @remarks   This method works in the ::CAMERA_STATE_INITIALIZED state.
+       * @remarks   The last specified type is applied even with the several types applicable.
+       * @remarks   This method rotates the preview and recording data but not the captured image. @n
+       *            The captured image's orientation is always following the physical rotation.
+       * @remarks   When the preview is rotated, the preview callback data's width and height can be changed. @n
+       *            Thus the application must recognize these changes when it uses the preview data in ICameraEventListener::OnCameraPreviewed() callback.
+       * @remarks   For the intended view of preview, Tizen::Ui::Controls::OverlayRegion::OVERLAY_REGION_TYPE_NORMAL must be selected when Tizen::Ui::Controls::OverlayRegion is created.
+       * @remarks              In a zero-shutter-lag camera, the default preview format is not guaranteed to apply this feature correctly.
+       * @remarks              The zero-shutter-lag capability can be checked using MediaCapability::GetValue(const Tizen::Base::String& key, bool& value) with
+       *                               ::CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, ::CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG keys.
+       * @see                     GetPreviewRotation()
+       *
+       */
+       result SetPreviewRotation(CameraRotation rotation);
+
+       /**
+       *
+       * Gets the rotation for the previewed data.
+       *
+       * @since                2.0
+       *
+       * @return           The camera rotation
+       * @see              SetPreviewRotation()
+       *
+       */
+       CameraRotation GetPreviewRotation(void) const;
+
+       /**
+       * Sets the metering mode of the camera.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/camera
+       *
+       * @return               An error code
+       * @param[in]    meteringMode                            The metering mode
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_INVALID_ARG                           The specified metering mode is invalid.
+       * @exception    E_UNSUPPORTED_OPERATION  The target device does not support metering mode configuration feature.
+       * @exception    E_UNSUPPORTED_TYPE                The specified @c meteringMode is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks      ::CAMERA_METERING_MODE_NONE always throws E_INVALID_ARG.
+       * @see          GetMeteringMode()
+       */
+       result SetMeteringMode(CameraMeteringMode meteringMode);
+
+       /**
+       * Gets the metering mode of the camera.
+       *
+       * @since                2.0
+       *
+       * @return               The %Camera metering mode
+       * @remarks      If the %Camera does not support the metering mode, this method always returns ::CAMERA_METERING_MODE_NONE.
+       * @see          SetMeteringMode()
+       */
+       CameraMeteringMode GetMeteringMode(void) const;
+
+       /**
+        * This value can be used to set the preview frame rate by using the SetPreviewFrameRate() method. @n
+        * If the preview frame rate is set using this value, the frame rate during the preview is automatically adjusted as per the light condition.
+        *
+        * @since               2.0
+        */
+       static const int FRAME_RATE_AUTO = 0xFFFFFFFF;
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        * @see                 Construct()
+        */
+       Camera(const Camera& rhs);
+
+       /**
+        * This is the copy assignment operator for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        */
+       Camera& operator =(const Camera& rhs);
+
+       friend class _CameraImpl;
+       _CameraImpl* __pImpl;
+
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaCameraTypes.h b/inc/FMediaCameraTypes.h
new file mode 100755 (executable)
index 0000000..9bc7c78
--- /dev/null
@@ -0,0 +1,301 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaCameraTypes.h
+ * @brief                      This is the header file for the enumerations of the Camera class.
+ *
+ * This header file contains the definitions of the enumerations of the Camera class.
+ */
+
+#ifndef _FMEDIA_CAMERA_TYPES_H_
+#define _FMEDIA_CAMERA_TYPES_H_
+
+namespace Tizen { namespace Media
+{
+
+#define MAX_CAMERA_STRING_LENGTH 200
+
+#define MIN_CAMERA_BRIGHTNESS 0
+#define MAX_CAMERA_BRIGHTNESS 9
+#define DEFAULT_CAMERA_BRIGHTNESS 5
+
+#define MIN_CAMERA_CONTRAST 0
+#define MAX_CAMERA_CONTRAST 9
+#define DEFAULT_CAMERA_CONTRAST 5
+
+#define MIN_CAMERA_EXPOSURE 0
+#define MAX_CAMERA_EXPOSURE 9
+#define DEFAULT_CAMERA_EXPOSURE 5
+
+#define DEFAULT_CAMERA_PREVIEW_FPS 15
+
+/**
+ * @enum CameraSelection
+ *
+ * Defines a functional camera.
+ *
+ * @since              2.0
+ *
+ * @see                Camera::PowerOn()
+ */
+enum CameraSelection
+{
+       CAMERA_PRIMARY,          /**< The primary camera */
+       CAMERA_SECONDARY,       /**< The secondary camera */
+};
+
+/**
+ * @enum CameraState
+ *
+ * Defines the state of the camera.
+ *
+ * @since              2.0
+ *
+ * @see                Camera::GetState()
+ */
+enum CameraState
+{
+       CAMERA_STATE_INITIALIZED,       /**< The camera in the initialized state */
+       CAMERA_STATE_PREVIEW,           /**< The camera in the preview state */
+       CAMERA_STATE_AUTO_FOCUSING,     /**< The camera state while auto-focusing */
+       CAMERA_STATE_CAPTURING,         /**< The camera state while capturing */
+       CAMERA_STATE_CAPTURED,          /**< The camera state after capturing */
+       CAMERA_STATE_ERROR              /**< The camera in an error state */
+};
+
+/**
+ * @enum CameraWhiteBalance
+ *
+ * Defines the white balance levels of the camera.
+ *
+ * @since              2.0
+ *
+ * @see                Camera::SetWhiteBalance()
+ * @see     Camera::GetWhiteBalance()
+ */
+enum CameraWhiteBalance
+{
+       CAMERA_WHITE_BALANCE_AUTO,                  /**< The camera's white balance level: Auto */
+       CAMERA_WHITE_BALANCE_SUNNY,                 /**< The camera's white balance level: Sunny */
+       CAMERA_WHITE_BALANCE_CLOUDY,                /**< The camera's white balance level: Cloudy */
+       CAMERA_WHITE_BALANCE_FLUORESCENT,           /**< The camera's white balance level: Fluorescent */
+       CAMERA_WHITE_BALANCE_TUNGSTEN,              /**< The camera's white balance level: Tungsten */
+};
+
+/**
+ * @enum CameraEffect
+ *
+ * Defines the effects of the camera.
+ *
+ * @since              2.0
+ *
+ * @see                Camera::SetEffect()
+ * @see     Camera::GetEffect()
+ */
+enum CameraEffect
+{
+       CAMERA_EFFECT_NONE,                 /**< The camera's effect: None */
+       CAMERA_EFFECT_COLOR,                /**< The camera's effect: Color */
+       CAMERA_EFFECT_BW,                   /**< The camera's effect: Black and White */
+       CAMERA_EFFECT_SEPIA,                /**< The camera's effect: Sepia */
+       CAMERA_EFFECT_SOLARIZE,             /**< The camera's effect: Solarize */
+       CAMERA_EFFECT_NEGATIVE,             /**< The camera's effect: Negative */
+       CAMERA_EFFECT_NIGHT,                /**< The camera's effect: Night */
+};
+
+/**
+ * @enum CameraIsoLevel
+ *
+ * Defines the ISO levels of the camera.
+ *
+ * @since              2.0
+ *
+ * @see                Camera::SetIsoLevel()
+ * @see     Camera::GetIsoLevel()
+ */
+enum CameraIsoLevel
+{
+       CAMERA_ISO_DEFAULT,                 /**< The device dependent default ISO level */
+       CAMERA_ISO_MIN,                     /**< The minimum supported ISO level */
+       CAMERA_ISO_AUTO,                    /**< The auto ISO level */
+       CAMERA_ISO_50,                      /**< The ISO 50 level */
+       CAMERA_ISO_100,                     /**< The ISO 100 level */
+       CAMERA_ISO_200,                     /**< The ISO 200 level */
+       CAMERA_ISO_400,                     /**< The ISO 400 level */
+       CAMERA_ISO_800,                     /**< The ISO 800 level */
+       CAMERA_ISO_1600,                    /**< The ISO 1600 level */
+       CAMERA_ISO_MAX                      /**< The maximum supported ISO level */
+};
+
+/**
+ * @enum CameraQuality
+ *
+ * Defines the capturing quality of the camera.
+ *
+ * @since              2.0
+ *
+ * @remarks The capturing quality of the camera cannot be set to CAMERA_QUALITY_MAX.
+ * @see                Camera::GetQuality()
+ * @see     Camera::SetQuality()
+ */
+enum CameraQuality
+{
+       CAMERA_QUALITY_NORMAL,              /**< The camera's capturing quality: Normal */
+       CAMERA_QUALITY_FINE,                /**< The camera's capturing quality: Fine */
+       CAMERA_QUALITY_SUPER_FINE,          /**< The camera's capturing quality: Super Fine */
+       CAMERA_QUALITY_MAX,                 /**< The camera's capturing quality: Max boundary */
+};
+
+/**
+ * @enum CameraErrorReason
+ *
+ * Defines the reason for the camera error.
+ *
+ * @since              2.0
+ */
+enum CameraErrorReason
+{
+       CAMERA_ERROR_NONE,                  // The undefined error
+       CAMERA_ERROR_OUT_OF_MEMORY,         /**< The insufficient memory error */
+       CAMERA_ERROR_DEVICE_FAILED,         /**< The camera device failed error */
+       CAMERA_ERROR_DEVICE_INTERRUPTED,    /**< The camera device interrupted error  */
+};
+
+
+/**
+ * @enum CameraDirection
+ *
+ * Defines the physical direction of the camera.
+ *
+ * @since              2.0
+ */
+enum CameraDirection
+{
+       CAMERA_DIRECTION_FRONT = 0x01,  /**< The camera's direction: Front */
+       CAMERA_DIRECTION_BACK,          /**< The camera's direction: Backward */
+} ;
+
+/**
+ * @enum CameraRotation
+ *
+ * Defines the physical rotation of the camera in degrees.
+ *
+ * @since              2.0
+ */
+enum CameraRotation
+{
+       CAMERA_ROTATION_NONE = 0x01,    /**< The camera's rotation: None */
+       CAMERA_ROTATION_90,         /**< The camera's rotation: 90 degree rotation */
+       CAMERA_ROTATION_180,            /**< The camera's rotation: 180 degree rotation  */
+       CAMERA_ROTATION_270,            /**< The camera's rotation: 270 degree rotation  */
+};
+
+/**
+ * @enum CameraZoomType
+ *
+ * Defines the zoom types of the camera.
+ *
+ * @since              2.0
+ */
+enum CameraZoomType
+{
+       CAMERA_ZOOM_TYPE_DIGITAL = 0x01,    /**< The camera's zoom type: Digital */
+       CAMERA_ZOOM_TYPE_SMART,             /**< The camera's zoom type: Smart */
+};
+
+/**
+ * @enum CameraExifOrientation
+ *
+ * Defines the camera's EXIF orientation flags.
+ *
+ * @since              2.0
+ */
+enum CameraExifOrientation
+{
+       CAMERA_EXIF_ORIENTATION_TOP_LEFT = 0x01,    /**< The row #0 is top, column #0 is left */
+       CAMERA_EXIF_ORIENTATION_TOP_RIGHT,      /**< The row #0 is top, column #0 is right */
+       CAMERA_EXIF_ORIENTATION_BOTTOM_RIGHT,   /**< The row #0 is bottom, column #0 is right */
+       CAMERA_EXIF_ORIENTATION_BOTTOM_LEFT,    /**< The row #0 is bottom, column #0 is left */
+       CAMERA_EXIF_ORIENTATION_LEFT_TOP,       /**< The row #0 is left, column #0 is top */
+       CAMERA_EXIF_ORIENTATION_RIGHT_TOP,      /**< The row #0 is right, column #0 is top */
+       CAMERA_EXIF_ORIENTATION_RIGHT_BOTTOM,   /**< The row #0 is right, column #0 is bottom */
+       CAMERA_EXIF_ORIENTATION_LEFT_BOTTOM,    /**< The row #0 is left, column #0 is bottom */
+};
+
+/**
+ * @enum CameraFlipType
+ *
+ * Defines the camera's flip types.
+ *
+ * @since              2.0
+ */
+enum CameraFlipType
+{
+       CAMERA_FLIP_NONE,               /**< The camera's flip type: None*/
+       CAMERA_FLIP_HORIZONTAL,     /**< The camera's flip type: Horizontal*/
+       CAMERA_FLIP_VERTICAL,           /**< The camera's flip type: Vertical*/
+};
+
+/**
+ * @enum CameraFocusMode
+ *
+ * Defines the camera focus mode
+ * @since              2.0
+ */
+enum CameraFocusMode
+{
+       CAMERA_FOCUS_MODE_NONE, /**< The camera's  focus mode: None*/
+       CAMERA_FOCUS_MODE_NORMAL,       /**< The camera's  focus mode: Normal*/
+       CAMERA_FOCUS_MODE_MACRO,        /**< The camera's  focus mode: Macro*/
+       CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,      /**< The camera's  focus mode: Continuous auto*/
+       CAMERA_FOCUS_MODE_INFINITE,     /**< The camera's  focus mode: Infinite*/
+};
+
+/**
+ * @enum CameraFlashMode
+ *
+ * Defines the camera flash mode
+ * @since              2.0
+ */
+enum CameraFlashMode
+{
+       CAMERA_FLASH_MODE_OFF,                  /**< Flash off */
+       CAMERA_FLASH_MODE_ON,                   /**< Flash splashes before capturing*/
+       CAMERA_FLASH_MODE_AUTO,                                 /**< Flash splashes depending on intensity of light before capturing */
+       CAMERA_FLASH_MODE_RED_EYE_REDUCTION,            /**< Flash splashes multiple times before capturing for red eye reduction. */
+       CAMERA_FLASH_MODE_CONTINUOUS,                           /**< Flash keeps turned on until turning off */
+};
+
+/**
+* @enum CameraMeteringMode
+*
+* Defines the camera metering mode
+* @since               2.0
+*/
+enum CameraMeteringMode
+{
+       CAMERA_METERING_MODE_NONE,                      /**< No metering mode */
+       CAMERA_METERING_MODE_AVERAGE,           /**< Average metering mode that uses information of entire scene */
+       CAMERA_METERING_MODE_CENTER_WEIGHTED,   /**< Center weighted average metering mode that uses information of central part of the scene */
+       CAMERA_METERING_MODE_SPOT,                      /**< Spot metering mode that uses information of very small area of the scene */
+};
+
+}}// Tizen::Media
+
+
+#endif
diff --git a/inc/FMediaCapability.h b/inc/FMediaCapability.h
new file mode 100755 (executable)
index 0000000..9f0e3cd
--- /dev/null
@@ -0,0 +1,252 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaCapability.h
+ * @brief                      This is the header file for the %MediaCapability class.
+ *
+ * This header file contains the declarations of the %MediaCapability class.
+ */
+
+#ifndef _FMEDIA_CAPABILITY_H_
+#define _FMEDIA_CAPABILITY_H_
+
+#include <FBase.h>
+#include <FMediaCapabilityTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+class _CapabilityImpl;
+
+/**
+ * @class      MediaCapability
+ * @brief      This class provides capability information of the various classes in the Media namespace.
+ *
+ * @since              2.0
+ *
+ *
+ * The %MediaCapability class provides capability information of the various classes in the %Media namespace.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/media_capabilities.htm">Media Capabilities</a>.
+ *
+ * The following example demonstrates how to use the %MediaCapability class.
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FGraphics.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Media;
+ *
+ * result
+ * MediaCapabilitySample(void)
+ * {
+ *      Tizen::Base::Collection::IList *pList = null;
+ *
+ *      pList = MediaCapability::GetValueN(CAMERA_PRIMARY_CAPTURE_FORMAT);
+ *      if (pList == null)
+ *      {
+ *              return GetLastResult();
+ *      }
+ *
+ *      for (int i = 0; i < pList->GetCount(); i++)
+ *      {
+ *              Tizen::Graphics::PixelFormat captureFormat;
+ *              Tizen::Base::Integer *pValue = dynamic_cast<Tizen::Base::Integer*>(pList->GetAt(i));
+ *              if (pValue)
+ *              {
+ *                      captureFormat = (Tizen::Graphics::PixelFormat)pValue->ToInt();
+ *                      AppLog("CaptureFormat[%d] = %d", i, captureFormat);
+ *              }
+ *      }
+ *      pList->RemoveAll(true);
+ *      delete pList;
+ *
+ *      pList = MediaCapability::GetValueN(CAMERA_PRIMARY_PREVIEW_RESOLUTION);
+ *      if (pList == null)
+ *      {
+ *              return GetLastResult();
+ *      }
+ *
+ *      for (int i = 0; i < pList->GetCount(); i++)
+ *      {
+ *              Tizen::Graphics::Dimension *pValue = dynamic_cast<Tizen::Graphics::Dimension*>(pList->GetAt(i));
+ *              if (pValue)
+ *              {
+ *                      AppLog("PreviewResolution[%d] = %d x %d", i, pValue->width, pValue->height);
+ *              }
+ *      }
+ *      pList->RemoveAll(true);
+ *      delete pList;
+ *
+ *      return E_SUCCESS;
+ * }
+ *
+ * @endcode
+ *
+ *
+ *
+ */
+
+class _OSP_EXPORT_ MediaCapability
+{
+
+// Operations
+public:
+       /**
+       *       Gets the capability value.
+       *
+       * @since                2.0
+       *
+       *       @return         An error code on failure, @n
+       *                               else E_SUCCESS
+       *       @param[in]      key                                                             The <a href="../org.tizen.native.appprogramming/html/guide/media/media_capabilities.htm#media_capabilities">key name</a> of the media capability
+       *       @param[out]     value                                                   The retrieved capability information
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_OBJ_NOT_FOUND                          The specified @c key is not found.
+       *       @exception      E_INVALID_ARG                                   A specified input parameter is invalid.
+       *       @exception      E_SYSTEM                                                A system error has occurred.
+       */
+       static result GetValue(const Tizen::Base::String& key, bool& value);
+
+
+       /**
+       *       Gets the capability value.
+       *
+       * @since                2.0
+       *
+       *       @return         An error code on failure, @n
+       *                               else E_SUCCESS
+       *       @param[in]      key                                                             The <a href="../org.tizen.native.appprogramming/html/guide/media/media_capabilities.htm#media_capabilities">key name</a> of the media capability
+       *       @param[out]     value                                                   The retrieved capability information
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_OBJ_NOT_FOUND                          The specified @c key is not found.
+       *       @exception      E_INVALID_ARG                                   A specified input parameter is invalid.
+       *       @exception      E_SYSTEM                                                A system error has occurred.
+       */
+       static result GetValue(const Tizen::Base::String& key, int& value);
+
+       /**
+       *       Gets the capability value.
+       *
+       * @since                2.0
+       *
+       *       @return         An error code on failure, @n
+       *                               else E_SUCCESS
+       *       @param[in]      key                                                             The <a href="../org.tizen.native.appprogramming/html/guide/media/media_capabilities.htm#media_capabilities">key name</a> of the media capability
+       *       @param[out]     value                                                   The retrieved capability information
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_OBJ_NOT_FOUND                          The specified @c key is not found.
+       *       @exception      E_INVALID_ARG                                   A specified input parameter is invalid.
+       *       @exception      E_SYSTEM                                                A system error has occurred.
+       */
+       static result GetValue(const Tizen::Base::String& key, long long& value);
+
+       /**
+       *       Gets the capability value.
+       *
+       * @since                2.0
+       *
+       *       @return                 An error code on failure, @n
+       *                                       else E_SUCCESS
+       *       @param[in]      key                                                             The <a href="../org.tizen.native.appprogramming/html/guide/media/media_capabilities.htm#media_capabilities">key name</a> of the media capability
+       *       @param[out]     value                                                   The retrieved capability information
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_OBJ_NOT_FOUND                          The specified @c key is not found.
+       *       @exception      E_INVALID_ARG                                   A specified input parameter is invalid.
+       *       @exception      E_SYSTEM                                                A system error has occurred.
+       */
+       static result GetValue(const Tizen::Base::String& key, double& value);
+
+       /**
+       *       Gets the capability value.
+       *
+       * @since                2.0
+       *
+       *       @return                 An error code on failure, @n
+       *                                       else E_SUCCESS
+       *       @param[in]      key                                                             The <a href="../org.tizen.native.appprogramming/html/guide/media/media_capabilities.htm#media_capabilities">key name</a> of the media capability
+       *       @param[out]     value                                                   The retrieved capability information
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_OBJ_NOT_FOUND                          The specified @c key is not found.
+       *       @exception      E_INVALID_ARG                                   A specified input parameter is invalid.
+       *       @exception      E_SYSTEM                                                A system error has occurred.
+       */
+       static result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+
+       /**
+       *       Gets the capability value.
+       *
+       * @since                2.0
+       *
+       *       @return         A pointer to Tizen::Base::Collection::IList on success, @n
+       *                               else @c null
+       *       @param[in]      key                                                             The <a href="../org.tizen.native.appprogramming/html/guide/media/media_capabilities.htm#media_capabilities">key name</a> of the media capability
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_OBJ_NOT_FOUND                          The specified @c key is not found.
+       *       @exception      E_INVALID_ARG                                   The specified input parameter is invalid.
+       *       @exception      E_SYSTEM                                                A system error has occurred.
+       *       @remarks        The specific error code can be accessed using the GetLastResult() method.
+       *                       If the type of a key is 'List, type', use GetValueN(). @n
+       *                       For example, 'List, String', 'List, Integer'.
+       */
+       static Tizen::Base::Collection::IList* GetValueN(const Tizen::Base::String& key);
+
+private:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         This default constructor is intentionally declared as private to implement the Singleton semantic.
+        */
+       MediaCapability(void);
+       /**
+        * This is the default destructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         This destructor is intentionally declared as private to implement the Singleton semantic.
+        */
+       ~MediaCapability(void);
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        */
+       MediaCapability(const MediaCapability& src);
+       /**
+        * This is the copy assignment operator for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        */
+       MediaCapability& operator =(const MediaCapability& src);
+
+       friend class _CapabilityImpl;
+       _CapabilityImpl* __pImpl;
+};
+
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaCapabilityTypes.h b/inc/FMediaCapabilityTypes.h
new file mode 100755 (executable)
index 0000000..e5f66ad
--- /dev/null
@@ -0,0 +1,539 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaCapabilityTypes.h
+ * @brief                      This is the header file for the common data of the MediaCapability class.
+ *
+ * This header file contains the declarations of common data of the MediaCapability class.
+ */
+
+#ifndef _FMEDIA_CAPABILITY_TYPES_H_
+#define _FMEDIA_CAPABILITY_TYPES_H_
+
+#include <FBase.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+* The property key to check the list of the supported sample rates of AudioIn.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const AUDIOIN_SAMPLE_RATE;
+
+/**
+* The property key to check the list of the supported sample types of AudioIn.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const AUDIOIN_SAMPLE_TYPE;
+
+/**
+* The property key to check the maximum instance count that AudioOut can construct.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const AUDIOOUT_COUNT_MAX;
+
+/**
+* The property key to check the list of the supported sample rates of AudioOut.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const AUDIOOUT_SAMPLE_RATE;
+
+/**
+* The property key to check the list of the supported sample types of AudioOut.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const AUDIOOUT_SAMPLE_TYPE;
+
+/**
+* The property key to check the list of audio formats that the audio recorder supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const AUDIORECORDER_FORMAT;
+
+/**
+* The property key to check the count of cameras that are supported.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_COUNT;
+
+/**
+* The property key to check the list of capture formats that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_CAPTURE_FORMAT;
+
+/**
+* The property key to check the list of capture resolutions that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_CAPTURE_RESOLUTION;
+
+/**
+* The property key to check the physical direction of the primary camera.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_DIRECTION;
+
+/**
+* The property key to check the list of effects that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_EFFECT;
+
+/**
+* The property key to check the list of ISO levels that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_ISO_LEVEL;
+
+/**
+* The property key to check the list of preview formats that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_PREVIEW_FORMAT;
+
+/**
+* The property key to check the list of preview frame rates that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_PREVIEW_FRAMERATE;
+
+/**
+* The property key to check the list of preview resolutions that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_PREVIEW_RESOLUTION;
+
+/**
+* The property key to check the list of recording resolutions that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_RECORDING_RESOLUTION;
+
+/**
+* The property key to check the physical rotation of the primary camera in the portrait mode.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_ROTATION;
+
+/**
+* The property key to check the ability of the primary camera to support brightness APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_BRIGHTNESS;
+
+/**
+* The property key to check the ability of the primary camera to support capture APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_CAPTURE;
+
+/**
+* The property key to check the ability of the primary camera to support contrast APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_CONTRAST;
+
+/**
+* The property key to check the ability of the primary camera to support exposure APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_EXPOSURE;
+
+/**
+* The property key to check the ability of the primary camera to support flash APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_FLASH;
+
+/**
+* The property key to check the ability of the primary camera to support focus APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_FOCUS;
+
+/**
+* The property key to check the ability of the primary camera to support preview APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_PREVIEW;
+
+/**
+* The property key to check the ability of the primary camera to be used with the video recorder.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_RECORDING;
+
+/**
+* The property key to check the ability of the primary camera to support zoom APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_ZOOM;
+
+/**
+* The property key to check the ability of the primary camera to support zero-shutter-lag feature.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG;
+
+/**
+* The property key to check the list of white balances that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_WHITE_BALANCE;
+
+/**
+* The property key to check the list of zoom types that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_ZOOM_TYPE;
+
+/**
+* The property key to check the list of flip types that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_FLIP;
+
+/**
+* The property key to check the list of preview rotations that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_PREVIEW_ROTATION;
+
+/**
+* The property key to check the list of focus mode that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_FOCUS_MODE;
+
+/**
+* The property key to check the list of flash mode that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_FLASH_MODE;
+
+/**
+* The property key to check the default preview format of the primary camera.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT;
+
+/**
+* The property key to check the list of metering mode that the primary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_METERING_MODE;
+
+/**
+* The property key to check the list of capture formats that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_CAPTURE_FORMAT;
+
+/**
+* The property key to check the list of capture resolutions that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_CAPTURE_RESOLUTION;
+
+/**
+* The property key to check the physical direction of the secondary camera.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_DIRECTION;
+
+/**
+* The property key to check the list of effects that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_EFFECT;
+
+/**
+* The property key to check the list of ISO levels that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_ISO_LEVEL;
+
+/**
+* The property key to check the list of preview formats that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_PREVIEW_FORMAT;
+
+/**
+* The property key to check the list of preview frame rates that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_PREVIEW_FRAMERATE;
+
+/**
+* The property key to check the list of preview resolutions that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_PREVIEW_RESOLUTION;
+
+/**
+* The property key to check the list of recording resolutions that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_RECORDING_RESOLUTION;
+
+/**
+* The property key to check the physical rotation of the secondary camera in the portrait mode.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_ROTATION;
+
+/**
+* The property key to check the ability of the secondary camera to support brightness APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_BRIGHTNESS;
+
+/**
+* The property key to check the ability of the secondary camera to support capture APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_CAPTURE;
+
+/**
+* The property key to check the ability of the secondary camera to support contrast APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_CONTRAST;
+
+/**
+* The property key to check the ability of the secondary camera to support exposure APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_EXPOSURE;
+
+/**
+* The property key to check the ability of the secondary camera to support flash APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_FLASH;
+
+/**
+* The property key to check the ability of the secondary camera to support focus APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_FOCUS;
+
+/**
+* The property key to check the ability of the secondary camera to support preview APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_PREVIEW;
+
+/**
+* The property key to check the ability of the secondary camera to be used with the video recorder.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_RECORDING;
+
+/**
+* The property key to check the ability of the secondary camera to support zoom APIs.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_ZOOM;
+
+/**
+* The property key to check the ability of the secondary camera to support zero-shutter-lag feature.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG;
+
+/**
+* The property key to check the list of white balances that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_WHITE_BALANCE;
+
+/**
+* The property key to check the list of zoom types that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_ZOOM_TYPE;
+
+/**
+* The property key to check the list of flip types that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_FLIP;
+
+/**
+* The property key to check the list of preview rotations that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_PREVIEW_ROTATION;
+
+/**
+* The property key to check the list of focus mode that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_FOCUS_MODE;
+
+/**
+* The property key to check the list of flash mode that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_FLASH_MODE;
+
+/**
+* The property key to check the default preview format of the secondary camera.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT;
+
+/**
+* The property key to check the list of metering mode that the secondary camera supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_METERING_MODE;
+
+/**
+* The property key to check the list of audio codecs that the player supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const PLAYER_AUDIO_CODEC;
+
+/**
+* The property key to check the maximum count of instances that the player can construct.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const PLAYER_COUNT_MAX;
+
+/**
+* The property key to check the list of streaming protocols that the player supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const PLAYER_PROTOCOL;
+
+/**
+* The property key to check the list of video codecs that the player supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const PLAYER_VIDEO_CODEC;
+
+/**
+* The property key to check the maximum height of the video that the player supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const PLAYER_VIDEO_HEIGHT;
+
+/**
+* The property key to check the maximum width of the video that the player supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const PLAYER_VIDEO_WIDTH;
+
+/**
+* The property key to check the list of audio codecs that the video recorder supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_AUDIO_CODEC;
+
+/**
+* The property key to check the list of container formats that the video recorder supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_FORMAT;
+
+/**
+* The property key to check the list of video codecs that the video recorder supports.
+*
+* @since               2.0
+*/
+_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_VIDEO_CODEC;
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaIAudioInEventListener.h b/inc/FMediaIAudioInEventListener.h
new file mode 100644 (file)
index 0000000..e4bf92e
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaIAudioInEventListener.h
+ * @brief                      This is the header file for the %IAudioInEventListener interface.
+ *
+ * This header file contains the declarations of the %IAudioInEventListener interface.
+ */
+
+#ifndef _FMEDIA_IAUDIO_IN_EVENT_LISTENER_H_
+#define _FMEDIA_IAUDIO_IN_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseByteBuffer.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @interface  IAudioInEventListener
+ * @brief                      This interface represents a listener that receives the %AudioIn related events.
+ *
+ * @since              2.0
+ *
+ * The %IAudioInEventListener interface provides various methods that are called during the operations of %AudioIn.
+ * %AudioIn captures audio data from the device in asynchronous mode,
+ * and calls the listener's methods to pass the captured audio data.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/recording_pcm_audio.htm">Recording PCM Audio</a>.
+ *
+ */
+
+class _OSP_EXPORT_ IAudioInEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+       *
+       * @since                2.0
+       */
+       virtual ~IAudioInEventListener(void) {}
+
+       /**
+       *       Called when the device has filled up a buffer with PCM data completely.
+       *
+       * @since                2.0
+       *
+       *       @param[in]  pData       A pointer to the buffer containing the filled data @n
+       *                                                       The data address is same as the address added by AudioIn::AddBuffer().
+       */
+       virtual void OnAudioInBufferIsFilled(Tizen::Base::ByteBuffer* pData) = 0;
+
+       /**
+        *      Called when an input device is interrupted by a task of higher priority than AudioIn.
+        *
+        * @since               2.0
+        */
+       virtual void OnAudioInInterrupted(void) = 0;
+
+       /**
+        *      Called when an interrupted input device is released.
+        *
+        * @since               2.0
+        */
+       virtual void OnAudioInReleased(void) = 0;
+
+       /**
+       *   Called when an audio recording focus is changed to another application.
+       *
+       *  @since               2.0
+       *  @remarks             After the audio focus is being changed, the recording is stopped and the state of this instance is changed to AUDIOIN_STATE_STOPPED.
+       *  @remarks             An application can start recording in the state of AUDIOIN_STATE_STOPPED but the interaction between device and user needs to record again.  Because there is a possibility of a race condition between applications which try to resume without the interaction.
+       *               @remarks                An application cannot start recording again even in the state of AUDIOIN_STATE_STOPPED due to other applications which have a higher priority.
+       */
+
+       virtual void OnAudioInAudioFocusChanged(void) {}
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioInEventListener_Reserved1(void){}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioInEventListener_Reserved2(void){}
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaIAudioOutEventListener.h b/inc/FMediaIAudioOutEventListener.h
new file mode 100644 (file)
index 0000000..4abf2b9
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaIAudioOutEventListener.h
+ * @brief                      This is the header file for the %IAudioOutEventListener interface.
+ *
+ * This header file contains the declarations of the %IAudioOutEventListener interface.
+ */
+
+#ifndef _FMEDIA_IAUDIO_OUT_EVENT_LISTENER_H_
+#define _FMEDIA_IAUDIO_OUT_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Media
+{
+class AudioOut;
+/**
+ * @interface  IAudioOutEventListener
+ * @brief                      This interface represents a listener that receives the AudioOut related events.
+ *
+ * @since              2.0
+ *
+ *  The %IAudioOutEventListener interface represents a listener that receives the AudioOut related events. The %AudioOut class works in asynchronous mode, and when the application plays audio data with the %AudioOut class,
+ *  the caller must implement this interface to receive an event from %AudioOut.
+ *
+ *  For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/playing_pcm_audio.htm">Playing PCM Audio</a>.
+ */
+
+class _OSP_EXPORT_ IAudioOutEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+       *
+       * @since                2.0
+       */
+       virtual ~IAudioOutEventListener(void) {}
+
+       /**
+       *       Called when the device has written a buffer completely.
+       *
+       * @since                2.0
+       *
+       *       @param[in]      src     A pointer to the AudioOut instance that fired the event
+       */
+       virtual void OnAudioOutBufferEndReached(Tizen::Media::AudioOut& src) = 0;
+
+       /**
+        *      Called when the output device is interrupted by a task of higher priority than AudioOut.
+        *
+        * @since               2.0
+        *
+        *      @param[in]      src                                                     A pointer to the AudioOut instance that fired the event
+        */
+       virtual void OnAudioOutInterrupted(Tizen::Media::AudioOut& src) = 0;
+
+       /**
+        *      Called when the interrupted output device is released.
+        *
+        * @since               2.0
+        *
+        *      @param[in]      src                                                     A pointer to the AudioOut instance that fired the event
+        */
+       virtual void OnAudioOutReleased(Tizen::Media::AudioOut& src) = 0;
+
+       /**
+       *   Called when an audio playback focus is changed to another application.
+       *
+       *  @since               2.0
+       *
+       *  @param[in]   src             A pointer to the AudioOut instance that fired the event
+       *  @remarks             After the audio focus is being changed, the playback is stopped and the state of this instance is changed to AUDIOOUT_STATE_STOPPED.
+       *  @remarks             An application can start playback again in the state of AUDIOOUT_STATE_STOPPED but the interaction between device and user needs for starting again. Because there is a possibility of a race condition between applications which try to start without the interaction
+       *               @remarks                An application cannot start playback again even in the state of AUDIOOUT_STATE_STOPPED due to other applications which have a higher priority.
+       */
+       virtual void OnAudioOutAudioFocusChanged(Tizen::Media::AudioOut& src) {}
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioOutEventListener_Reserved1(void){}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioOutEventListener_Reserved2(void){}
+
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaIAudioRecorderEventListener.h b/inc/FMediaIAudioRecorderEventListener.h
new file mode 100755 (executable)
index 0000000..f9e621a
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaIAudioRecorderEventListener.h
+ * @brief                      This is the header file for the %IAudioRecorderEventListener interface.
+ *
+ * This header file contains the declarations of the %IAudioRecorderEventListener interface.
+ */
+
+#ifndef _FMEDIA_IAUDIO_RECORDER_EVENT_LISTENER_H_
+#define _FMEDIA_IAUDIO_RECORDER_EVENT_LISTENER_H_
+
+#include <FBase.h>
+#include <FMediaRecorderTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @interface  IAudioRecorderEventListener
+ * @brief              This interface represents a listener that receives events associated with the AudioRecorder class.
+ *
+ * @since              2.0
+ *
+ * The %IAudioRecorderEventListener interface represents a listener that receives events associated with the AudioRecorder class.
+ * %IAudioRecorderEventListener specifies the methods used to notify the status of the audio recorder.
+ * The audio recorder engine works asynchronously. Therefore, it is important to implement this listener to ensure that the recorder flows correctly.
+ * When an operation of each method is completed, an event is generated and a method of this class is called.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/recording_audio.htm">Recording Audio</a>.
+ */
+class _OSP_EXPORT_ IAudioRecorderEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+       * This is the destructor for this class.
+       *
+       * @since                2.0
+       */
+       virtual ~IAudioRecorderEventListener(void) {}
+
+       /**
+       *       Called when the AudioRecorder::Stop() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]    r       The cause of the error
+       *       @exception        E_SUCCESS     The method is successful.
+       *       @exception        E_SYSTEM      A system error has occurred.
+       */
+       virtual void OnAudioRecorderStopped(result r) = 0;
+
+       /**
+       *       Called when the AudioRecorder::Cancel() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       */
+       virtual void OnAudioRecorderCanceled(result r) = 0;
+
+       /**
+       *       Called when the AudioRecorder::Pause() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       *
+       */
+       virtual void OnAudioRecorderPaused(result r) = 0;
+
+       /**
+       *       Called when the AudioRecorder::Record() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       *
+       */
+       virtual void OnAudioRecorderStarted(result r) = 0;
+
+       /**
+       *       Called when AudioRecorder reaches the end of the pre-defined time.
+       *
+       * @since                2.0
+       *
+       *       @param[in]      endCondition    The end condition of the recording
+       * @see                          AudioRecorder::SetMaxRecordingTime()
+       *
+       */
+       virtual void OnAudioRecorderEndReached(RecordingEndCondition endCondition) = 0;
+
+       /**
+       *       Called when the AudioRecorder::Close() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       *
+       */
+       virtual void OnAudioRecorderClosed(result r) = 0;
+
+       /**
+       *       Called when an error has occurred in AudioRecorder.
+       *
+       * @since                2.0
+       *
+       *       @param[in]      r               An audio recorder error reason of type ::RecorderErrorReason
+       *       @remarks                ::RECORDER_ERROR_OUT_OF_STORAGE occurs when the recording size exceeds the maximum available capacity. @n
+       *                               While recording especially to the external memory like MMC card, ::RECORDER_ERROR_STORAGE_FAILED can occur.
+       *                               @c RECORDER_ERROR_DEVICE_FAILED occurs when the recording device has a problem like damaged shape or hardware malfunction.
+       */
+       virtual void OnAudioRecorderErrorOccurred(RecorderErrorReason r) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioRecorderEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioRecorderEventListener_Reserved2(void) {}
+
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaIAudioRouteEventListener.h b/inc/FMediaIAudioRouteEventListener.h
new file mode 100644 (file)
index 0000000..7d68dc5
--- /dev/null
@@ -0,0 +1,138 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                FMediaIAudioRouteEventListener.h
+* @brief               This is the header file for the IAudioRouteEventListener interface.
+*
+* This header files contains all the commons things required for %IAudioRouteEventListener and associated classes
+*
+*/
+#ifndef _FMEDIA_IAUDIO_ROUTE_EVENT_LISTENER_H_
+#define _FMEDIA_IAUDIO_ROUTE_EVENT_LISTENER_H_
+
+#include <FMediaAudioRouteInfo.h>
+#include "FBaseRtIEventListener.h"
+
+namespace Tizen { namespace Media
+{
+/**
+ * @if VISPARTNER
+ * @interface  IAudioRouteEventListener
+ * @brief This interface provides a listener that receives events associated with the active audio device or available audio devices.
+ *
+ * @since              2.0
+ *
+ * @visibility                 partner
+ *
+ * The %IAudioRouteEventListener interface specifies the methods used to notify the changes in active audio device or in available audio devices.
+ *  There are many audio devices in the device. Thus If the application wants to know the currently active audio device or available audio devices,
+ *  it has to listen to this interface.
+ *
+ * @endif
+ */
+class _OSP_EXPORT_ IAudioRouteEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+       * @if VISPARTNER
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor@n
+       * of this interface is called.
+       *
+       * @since                2.0
+       *
+       *       @visibility                     partner
+       *       @endif
+       */
+       virtual ~IAudioRouteEventListener(void) { }
+
+       /**
+       * @if VISPARTNER
+       *       Called when active audio route changes.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *
+       *       @param[in]                      route                                   %AudioRouteInfo for which currently became active
+       *       @endif
+       */
+       virtual void OnActiveAudioRouteChanged(const AudioRouteInfo& route) = 0;
+
+       /**
+       * @if VISPARTNER
+       *       Called when an available audio route added.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *
+       *       @param[in]                      route                                   %AudioRouteInfo for which routing status changed
+       *       @endif
+       */
+       virtual void OnAudioRouteAdded(const AudioRouteInfo& route) = 0;
+
+       /**
+       * @if VISPARTNER
+       *       Called when an audio route removed.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *
+       *       @param[in]                      route                                   %AudioRouteInfo for which routing status changed
+       *       @endif
+       */
+       virtual void OnAudioRouteRemoved(const AudioRouteInfo& route) = 0;
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioRouteEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioRouteEventListener_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioRouteEventListener_Reserved3(void) {}
+
+};
+}}     //Tizen::Media
+#endif
diff --git a/inc/FMediaIAudioSessionEventListener.h b/inc/FMediaIAudioSessionEventListener.h
new file mode 100644 (file)
index 0000000..948f629
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                        FMediaIAudioSessionEventListener.h
+* @brief               This is the header file for the AudioSessionEventListener interface.
+*
+* This header files contains all the commons things required for IAudioSessionEventListener and associated classes
+*
+*/
+#ifndef _FMEDIA_IAUDIO_SESSION_EVENT_LISTENER_H_
+#define _FMEDIA_IAUDIO_SESSION_EVENT_LISTENER_H_
+
+#include <FMediaAudioManagerTypes.h>
+#include "FBaseRtIEventListener.h"
+
+namespace Tizen { namespace Media
+{
+/**
+ * @if VISPARTNER
+ * @interface  IAudioSessionEventListener
+ * @brief              This interface provides a listener that receives events associated with the audio sessions.
+ *
+ * @since              2.0
+ *
+ * @visibility                 partner
+ *
+ * The %IAudioSessionEventListener interface specifies the methods used to notify when the application
+ *  audio session is interrupted or released.
+ *
+ * @endif
+ */
+class _OSP_EXPORT_ IAudioSessionEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+       * @if VISPARTNER
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor@n
+       * of this interface is called.
+       *
+       * @since                2.0
+       *
+       *       @visibility                     partner
+       *       @endif
+       */
+       virtual ~IAudioSessionEventListener(void) { }
+
+       /**
+       * @if VISPARTNER
+       *       Called when the audio session is interrupted.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *       @endif
+       */
+       virtual void OnAudioSessionInterrupted(void) = 0;
+
+       /**
+       * @if VISPARTNER
+       *       Called when the interrupted session is released.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                     partner
+       *       @endif
+       */
+       virtual void OnAudioSessionInterruptReleased(void) = 0;
+       /**
+       *       Called when an audio recording or playback focus is changed to another application.
+       *
+       *       @since          2.0
+       *       @remarks                After the audio focus is being changed, the playback or recording task is paused or stopped.
+       *       @remarks                An application can play or record again, but the interaction between device and user needs for doing it again. Because there is a possibility of a race condition between applications which try to play without the interaction
+       */
+       virtual void OnAudioSessionAudioFocusChanged(void) {}
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioSessionEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioSessionEventListener_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IAudioSessionEventListener_Reserved3(void) {}
+
+};
+}}     //Tizen::Media
+#endif
diff --git a/inc/FMediaICameraEventListener.h b/inc/FMediaICameraEventListener.h
new file mode 100755 (executable)
index 0000000..bc43a01
--- /dev/null
@@ -0,0 +1,186 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaICameraEventListener.h
+ * @brief                      This is the header file for the %ICameraEventListener interface.
+ *
+ * This header file contains the declarations of the %ICameraEventListener interface.
+ */
+
+#ifndef _FMEDIA_ICAMERA_EVENT_LISTENER_H_
+#define _FMEDIA_ICAMERA_EVENT_LISTENER_H_
+
+#include <FBase.h>
+#include <FMediaCameraTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @interface  ICameraEventListener
+ * @brief              This interface provides a listener that receives events associated with the Camera class.
+ *
+ * @since              2.0
+ *
+ * The %ICameraEventListener interface specifies the methods used to notify the status of the camera and camera events.
+ * The camera engine works asynchronously. Therefore, it is important to implement this listener
+ * to ensure smooth performance of the camera.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/capturing_still_images.htm">Capturing Still Images</a>.
+ */
+class _OSP_EXPORT_ ICameraEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+       * This is the destructor for this class.
+       *
+       * @since                2.0
+       */
+       virtual ~ICameraEventListener(void) {}
+
+       /**
+       * Called when the Camera::SetAutoFocus() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     completeCondition   The condition of auto focus completion @n
+       *                                                                                 Set to @c true if it succeeds, @n
+       *                                                                                 else @c false.
+       */
+       virtual void OnCameraAutoFocused(bool completeCondition) = 0;
+
+       /**
+       * Called when the Camera::StartPreview() method is completed. @n
+       * Notifies to the application periodically, at the speed of the camera's frame rate,
+       * once the %Camera::StartPreview() method is called, so as to receive the preview data.
+       *
+       * @since                2.0
+       *
+       *       @param[in]      previewedData                   The displayed image data in the viewfinder @n
+       *                                                                               The previewed data format is same as the format
+       *                                                                          set by Camera::SetPreviewFormat().
+       * @param[in]    r       The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_INVALID_DATA  The ByteBuffer contains invalid data.
+       *       @remarks        This method is called only if the @c previewedData flag of
+       *                               Camera::StartPreview() is @c true.
+       *       @remarks        This method can be delayed or dropped depending on system performance.
+        *   @see           Camera::GetPreviewFormat()
+       *
+       * The camera rotation can be different according to the physical design.
+       * For keeping the compatibility between targets, the application must check the H/W camera rotation.
+       * Based on this information, the application can rotate the preview data.
+       *
+       * The following example demonstrates how to use the %OnCameraPreviewed() method to rotate the preview data in the portrait mode.
+       *
+       * @code
+       // Rotates the preview data to use it
+       int rotation = (int)CAMERA_ROTATION_NONE;
+       MediaCapability::GetValue(CAMERA_SECONDARY_ROTATION, rotation);
+
+       ByteBuffer rotatedData;
+       rotatedData.Construct(previewedData.GetLimit());
+
+       switch ((CameraRotation) rotation)
+       {
+                       case CAMERA_ROTATION_90:
+                                       ImageUtil::Rotate(previewedData, rotatedData,
+                                                               Dimension(__previewWidth, __previewHeight), IMAGE_ROTATION_90, MEDIA_PIXEL_FORMAT_YUV420P);
+                                       break;
+
+                       case CAMERA_ROTATION_180:
+                                       ImageUtil::Rotate(previewedData, rotatedData,
+                                                               Dimension(__previewWidth, __previewHeight), IMAGE_ROTATION_180, MEDIA_PIXEL_FORMAT_YUV420P);
+                                       break;
+
+                       case CAMERA_ROTATION_270:
+                                       ImageUtil::Rotate(previewedData, rotatedData,
+                                                               Dimension(__previewWidth, __previewHeight), IMAGE_ROTATION_270, MEDIA_PIXEL_FORMAT_YUV420P);
+                                       break;
+
+                       default:
+                                       break;
+       }
+       // Normally Camera::SetFlip(CAMERA_FLIP_VERTICAL) is used when using the front camera.
+       // Remember that the OverlayRegion method rotates the visible region internally corresponding to the form's orientation.
+       // An application does not need to rotate the visible region explicitly.
+       // However, the preview data itself is not rotated. If an application wants to rotate the preview data, the data must be rotated like above.
+       // The width and height changes according to the degree of rotation.
+       * @endcode
+       */
+       virtual void OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r) = 0;
+
+       /**
+       *       Called when the Camera::Capture() method is completed.
+       *
+       * @since                2.0
+       *
+       *       @param[in]       capturedData                   The image data captured by the camera @n
+       *                                                                               The captured data format is the same as the format
+       *                                                                          set by Camera::SetCaptureFormat().
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_INVALID_DATA  The ByteBuffer contains invalid data.
+       *       @see            Camera::Capture()
+        *   @see           Camera::GetCaptureFormat()
+       */
+       virtual void OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r) = 0;
+
+       /**
+       *       Called when an error occurs in Camera.
+       *
+       * @since                2.0
+       *
+       *       @param[in]      r               A camera error @n
+       *                                               This is one of the ::CameraErrorReason values.
+       *       @remarks                        The ::CAMERA_ERROR_DEVICE_FAILED error occurs when the camera device
+       *                                          has a problem, such as damaged shape or hardware malfunction.
+       *                                               The ::CAMERA_ERROR_DEVICE_INTERRUPTED error occurs when the camera
+       *                                          device has been interrupted by other request, such as an incoming
+       *                                          video telephony call.
+       *                                               In this method, the application calls the Camera::PowerOff()
+       *                                        method to reset the camera device.
+       */
+       virtual void OnCameraErrorOccurred(CameraErrorReason r) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void ICameraEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void ICameraEventListener_Reserved2(void) {}
+
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaIPlayerEventListener.h b/inc/FMediaIPlayerEventListener.h
new file mode 100644 (file)
index 0000000..42bae34
--- /dev/null
@@ -0,0 +1,166 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMediaIPlayerEventListener.h
+ * @brief              This is the header file for the %IPlayerEventListener interface.
+ *
+ * This header file contains the declarations of the %IPlayerEventListener interface.
+ */
+
+#ifndef _FMEDIA_IPLAYER_EVENT_LISTENER_H_
+#define _FMEDIA_IPLAYER_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FMediaPlayerTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @interface  IPlayerEventListener
+ * @brief                      This interface provides a listener for media playing events.
+ *
+ * @since              2.0
+ *
+ * The %IPlayerEventListener interface specifies the methods used to notify the status of the media player during the media playing events.
+ * The player engine works asynchronously. Therefore, it is important to implement this listener to ensure that the player flows correctly.
+ * When each operation of the Player is completed, an event is generated, and a method from this class is called.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/playing_audio.htm">Playing Audio</a> and
+ <a href="../org.tizen.native.appprogramming/html/guide/media/playing_video.htm">Playing Video</a>.
+ */
+
+class _OSP_EXPORT_ IPlayerEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+       *
+       * @since                2.0
+       */
+       virtual ~IPlayerEventListener(void) {}
+
+       /**
+       *       Called when an audio/video content is opened asynchronously.
+       *
+       *   @since              2.0
+       *
+       *       @param[in]       r                                                                      The cause of the error
+       *       @exception       E_SUCCESS                                                      The method is successful.
+       *       @exception       E_SYSTEM                                                       A system error has occurred.
+       *       @exception       E_CONNECTION_FAILED                            The network connection has failed.
+       *   @exception   E_UNSUPPORTED_FORMAT                           The specified format is not supported.
+       *   @exception   E_UNSUPPORTED_CODEC                            The specified codec is not supported.
+       *       @exception       E_OUT_OF_MEMORY                                        The memory is insufficient.
+       *       @see            Player::OpenFile(), Player::OpenUrl(), Player::OpenBuffer()
+       */
+       virtual void OnPlayerOpened(result r) = 0;
+
+       /**
+       *       Called when the Player reaches the end of the clip.
+       *
+       * @since                2.0
+       */
+       virtual void OnPlayerEndOfClip(void) = 0;
+
+       /**
+       *       Called when the position of the audio/video content moves asynchronously.
+       *
+       * @since                2.0
+       *
+       *       @param[in] r                              The cause of the error
+       *       @exception       E_SUCCESS              The method is successful.
+       *       @exception       E_SYSTEM               A system error has occurred.
+       *       @see                             Player::SeekTo()
+       */
+
+       virtual void OnPlayerSeekCompleted(result r){};
+
+
+       /**
+       *       Called when the streaming data is being buffered.
+       *
+       * @since                2.0
+       *
+       *       @param[in]      percent         The percentage of buffering is completed
+       *       @see                            Player::OpenUrl()
+       */
+       virtual void OnPlayerBuffering(int percent) = 0;
+
+       /**
+       *       Called when an error has occurs while the Player is working.
+       *
+       * @since                2.0
+       *
+       *       @param[in]      r               A player error reason of type ::PlayerErrorReason
+       *       @remarks                        While playing streaming media, the player might throw an error like ::PLAYER_ERROR_CONNECTION_LOST
+       *                               ::PLAYER_ERROR_STREAMING_TIMEOUT, ::PLAYER_ERROR_TRANSPORT or ::PLAYER_ERROR_SERVER. @n
+       *                               If the content includes invalid data, ::PLAYER_ERROR_INVALID_DATA may occur.
+       *       @see                            PlayerErrorReason
+       */
+       virtual void OnPlayerErrorOccurred(Tizen::Media::PlayerErrorReason r) = 0;
+
+
+       /**
+        *      Called when the Player is being interrupted by a task of higher priority than the Player.
+        *
+        * @since               2.0
+        */
+       virtual void OnPlayerInterrupted(void) = 0;
+
+       /**
+        *      Called when the interrupting Player has been released.
+        *
+        * @since               2.0
+        */
+       virtual void OnPlayerReleased(void) = 0;
+       /**
+       *       Called when an audio playback focus is changed to another application.
+       *
+       *       @since          2.0
+       *       @remarks        After the audio focus is being changed, the playback is paused or stopped and the state of this instance is changed to PLAYER_STATE_PAUSED or PLAYER_STATE_CLOSED.
+       *       @remarks        An application can play again in the state of PLAYER_STATE_PAUSED but the interaction between device and user needs for playback again. Because there is a possibility of a race condition between applications which try to play without the interaction
+       *       @remarks An application can not play again even in the state of PLAYER_STATE_PAUSED due to the application which has a higher priority.
+       */
+       virtual void OnPlayerAudioFocusChanged(void) {}
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IPlayerEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IPlayerEventListener_Reserved2(void) {}
+
+};
+
+}}  // Tizen::Media
+
+#endif
diff --git a/inc/FMediaIPlayerProgressiveDownloadListener.h b/inc/FMediaIPlayerProgressiveDownloadListener.h
new file mode 100644 (file)
index 0000000..979da58
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                                FMediaIPlayerProgressiveDownloadListener.h
+* @brief                       This is the header file for the IPlayerProgressiveDownloadListener interface.
+*
+* This header files contains the common thing required for IPlayerProgressiveDownloadListener.
+*
+*/
+#ifndef _FMEDIA_IPLAYER_PROGRESSIVE_DOWNLOAD_LISTENER_H_
+#define _FMEDIA_IPLAYER_PROGRESSIVE_DOWNLOAD_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Media
+{
+/**
+* @interface   IPlayerProgressiveDownloadListener
+* @brief               This interface provides a listener that receives events associated with the progressive download playback.
+*
+* @since               2.0
+*
+* The %IPlayerProgressiveDownloadListener interface specifies the methods used to notify when the application starts, or completes progressive download.
+*/
+class _OSP_EXPORT_ IPlayerProgressiveDownloadListener
+               : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor@n
+       * of this interface is called.
+       *
+       * @since                2.0
+       */
+       virtual ~IPlayerProgressiveDownloadListener(void) { }
+
+       /**
+       * Called when the progressive download started.
+       *
+       * @since                2.0
+       *
+       * @param[in]    player                                  A pointer to the Player instance that fired the event
+       */
+       virtual void OnPlayerProgressiveDownloadStarted(Player& player) = 0;
+
+       /**
+       * Called when the progressive download is in progress.
+       *
+       * @since                2.0
+       *
+       * @param[in]    player                                  A pointer to the Player instance that fired the event
+       * @param[in]    downloadedSize          The total downloaded size in bytes
+       * @param[in]    totalSize                               The total size in bytes
+       */
+       virtual void OnPlayerProgressiveDownloadInProgress(Player& player, int downloadedSize, int totalSize) = 0;
+
+
+       /**
+       * Called when the progressive download completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]    player                                  A pointer to the Player instance that fired the event
+       * @param[in]    r                                               The result of progressive download.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_STORAGE_FULL                  The storage is full.
+       * @exception    E_INACCESSIBLE_PATH             The file path is invalid to store media data.
+       */
+       virtual void OnPlayerProgressiveDownloadCompleted(Player& player, result r) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IPlayerProgressiveDownloadEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IPlayerProgressiveDownloadEventListener_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related,
+       // and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IPlayerProgressiveDownloadEventListener_Reserved3(void) {}
+
+};
+}}                     //Tizen::Media
+       #endif
diff --git a/inc/FMediaIPlayerVideoEventListener.h b/inc/FMediaIPlayerVideoEventListener.h
new file mode 100644 (file)
index 0000000..d9ab563
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMediaIPlayerVideoEventListener.h
+ * @brief              This is the header file for the %IPlayerVideoEventListener interface.
+ *
+ * This header file contains the declarations of the %IPlayerVideoEventListener interface.
+ */
+
+#ifndef _FMEDIA_IPLAYER_VIDEO_EVENT_LISTENER_H_
+#define _FMEDIA_IPLAYER_VIDEO_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseDataType.h>
+#include <FGrpDimension.h>
+#include <FGrpBitmapCommon.h>
+#include <FMediaPlayerTypes.h>
+
+namespace Tizen { namespace Media
+{
+class Player;
+/**
+ * @interface  IPlayerVideoEventListener
+ * @brief                      This interface provides a listener for the video event.
+ *
+ * @since              2.0
+ *
+ * The %IPlayerVideoEventListener interface specifies the method used to get the decoded video frame.
+ */
+
+class _OSP_EXPORT_ IPlayerVideoEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+       *
+       * @since                2.0
+       */
+       virtual ~IPlayerVideoEventListener(void) {}
+
+       /**
+       *       Called when the video frame is decoded asynchronously.
+       *
+       *   @since              2.0
+       *
+       *       @param[in]       src                            A pointer to the Player instance that fired the event
+       *       @param[in]       bitmapPixelFormat      A pixel format type     of the decoded video frame
+       *       @param[in]       dim                            A dimension of the decoded video frame
+       *       @param[in]       pBuffer                        A pointer to a decoded video frame buffer
+       *       @param[in]       sizeOfBuffer           A size of a buffer
+       *   @param[in]   r                                      The cause of the error
+       *       @exception       E_SUCCESS                                                      The method is successful.
+       *       @exception       E_SYSTEM                                                       A system error has occurred.
+       *       @exception       E_INVALID_DATA                     The video frame has invalid blocks.
+       *       @remarks        The lifecycle of @c pBuffer is valid inside this method.
+       *       @see            Player::Play(), Player::PlayAndPause(), Player::SeekTo()
+       */
+       virtual void OnVideoFrameDecoded(Tizen::Media::Player& src, Tizen::Graphics::BitmapPixelFormat bitmapPixelFormat, const Tizen::Graphics::Dimension& dim, const byte* pBuffer, int sizeOfBuffer, result r) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IPlayerVideoEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IPlayerVideoEventListener_Reserved2(void) {}
+
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaITonePlayerEventListener.h b/inc/FMediaITonePlayerEventListener.h
new file mode 100644 (file)
index 0000000..948b58f
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMediaITonePlayerEventListener.h
+ * @brief              This is the header file for the %ITonePlayerEventListener interface.
+ *
+ * This header file contains the declarations of the %ITonePlayerEventListener interface.
+ */
+
+#ifndef _FMEDIA_ITONE_PLAYER_EVENT_LISTENER_H_
+#define _FMEDIA_ITONE_PLAYER_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FMediaTonePlayer.h>
+
+namespace Tizen { namespace Media
+{
+class TonePlayer;
+/**
+ * @interface  ITonePlayerEventListener
+ * @brief              This interface provides a listener for the tone player events.
+ *
+ * @since              2.0
+ *
+ * The %ITonePlayerEventListener interface specifies the methods used to notify the status of the tone player.
+ */
+
+class _OSP_EXPORT_ ITonePlayerEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+       *
+       * @since                2.0
+       */
+       virtual ~ITonePlayerEventListener(void) {}
+
+       /**
+       *       Called when the tone player reaches to the end of the tone or the end of the list of tones.
+       *
+       *     @since            2.0
+       *
+       *       @param[in]      src             An instance of TonePlayer that fires the event
+       *
+       */
+       virtual void OnTonePlayerEndOfTone(Tizen::Media::TonePlayer& src) = 0;
+
+       /**
+       *       Called when the tone player is interrupted by a task of higher priority than the tone player.
+       *
+       *     @since            2.0
+       *
+       *       @param[in]      src             An instance of TonePlayer that fires the event
+       *
+       */
+       virtual void OnTonePlayerInterrupted(Tizen::Media::TonePlayer& src) = 0;
+
+       /**
+       *       Called when the interrupted tone player is released.
+       *
+       *     @since            2.0
+       *
+       *       @param[in]      src             An instance of TonePlayer that fires the event
+       *
+       */
+       virtual void OnTonePlayerReleased(Tizen::Media::TonePlayer& src) = 0;
+
+       /**
+       *       Called to notify an application that an error has occurred while the tone is played.
+       *
+       *   @since              2.0
+       *
+       *       @param[in]      src                                                                     An instance of TonePlayer that fires the event
+       *       @param[in]      r                                                                       A cause of the error
+       *       @exception      E_SYSTEM                                                        A system error has occurred.
+       */
+       virtual void OnTonePlayerErrorOccurred(Tizen::Media::TonePlayer& src, result r) = 0;
+
+       /**
+       *       Called when an audio playback focus is changed to another application.
+       *
+       *       @since          2.0
+       *
+       *       @param[in]              src             A pointer to the TonePlayer instance that fired the event
+       *       @remarks                After the audio focus is being changed, the playback is paused and the state of this instance is changed to TONE_PLAYER_STATE_PAUSED.
+       *       @remarks                An application can play again in the state of TONE_PLAYER_STATE_PAUSED but the interaction between device and user needs for playback again. Because there is a possibility of a race condition between applications which try to play without the interaction
+       *       @remarks                An application cannot start playback again even in the state of TONE_PLAYER_STATE_PAUSED due to other applications which have a higher priority.
+       */
+       virtual void OnTonePlayerAudioFocusChanged(Tizen::Media::TonePlayer& src) {}
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void ITonePlayerEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void ITonePlayerEventListener_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void ITonePlayerEventListener_Reserved3(void) {}
+
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaIVideoRecorderEventListener.h b/inc/FMediaIVideoRecorderEventListener.h
new file mode 100755 (executable)
index 0000000..c27552e
--- /dev/null
@@ -0,0 +1,162 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaIVideoRecorderEventListener.h
+ * @brief                      This is the header file for the %IVideoRecorderEventListener interface.
+ *
+ * This header file contains the declarations of the %IVideoRecorderEventListener interface.
+ */
+
+#ifndef _FMEDIA_IVIDEO_RECORDER_EVENT_LISTENER_H_
+#define _FMEDIA_IVIDEO_RECORDER_EVENT_LISTENER_H_
+
+#include <FBase.h>
+#include <FMediaRecorderTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @interface  IVideoRecorderEventListener
+ * @brief                      This interface represents a listener that receives events associated with the VideoRecorder class.
+ * @since              2.0
+ *
+ * The %IVideoRecorderEventListener interface specifies the methods used to notify the status of the video recorder.
+ * The video recorder engine works asynchronously. Therefore, it is important to implement this listener to ensure that the recorder flows correctly.
+ * When an operation of each method is completed, an event is generated and a method of this interface is called.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/recording_video.htm">Recording Video</a>.
+ */
+class _OSP_EXPORT_ IVideoRecorderEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+       * This is the destructor for this class.
+       *
+       * @since                2.0
+       */
+       virtual ~IVideoRecorderEventListener(void) {}
+
+       /**
+       *       Called when the VideoRecorder::Stop() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       *
+       */
+       virtual void OnVideoRecorderStopped(result r) = 0;
+
+       /**
+       *       Called when the VideoRecorder::Cancel() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]   r        The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       */
+       virtual void OnVideoRecorderCanceled(result r) = 0;
+
+       /**
+       *       Called when the VideoRecorder::Pause() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       *
+       */
+       virtual void OnVideoRecorderPaused(result r) = 0;
+
+       /**
+       *       Called when the VideoRecorder::Record() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       *
+       */
+       virtual void OnVideoRecorderStarted(result r) = 0;
+
+       /**
+        *      Called when VideoRecorder reaches the end of the pre-defined time.
+        *
+        * @since               2.0
+        *
+        * @param[in]   endCondition    The end condition of the recording
+        * @see                         VideoRecorder::SetMaxRecordingTime()
+        *
+        */
+       virtual void OnVideoRecorderEndReached(RecordingEndCondition endCondition) = 0;
+
+       /**
+       *       Called when the VideoRecorder::Close() method is completed.
+       *
+       * @since                2.0
+       *
+       * @param[in]     r      The cause of the error
+       *       @exception       E_SUCCESS      The method is successful.
+       *       @exception       E_SYSTEM       A system error has occurred.
+       *
+       */
+       virtual void OnVideoRecorderClosed(result r) = 0;
+
+       /**
+       *       Called when an error occurred in VideoRecorder.
+       *
+       * @since                2.0
+       *
+       *       @param[in]      r               A video recorder error reason of type ::RecorderErrorReason
+       *       @remarks                        ::RECORDER_ERROR_OUT_OF_STORAGE occurs when the recording size exceeds the maximum available capacity. @n
+       *                                                       While recording to an external memory like MMC card, ::RECORDER_ERROR_STORAGE_FAILED can occur. @n
+       *                                                       @c RECORDER_ERROR_DEVICE_FAILED occurs when the recording device has a problem like damaged shape or h/w failure.
+       */
+       virtual void OnVideoRecorderErrorOccurred(RecorderErrorReason r) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IVideoRecorderEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since               2.0
+       //
+       virtual void IVideoRecorderEventListener_Reserved2(void) {}
+
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaMediaStreamInfo.h b/inc/FMediaMediaStreamInfo.h
new file mode 100644 (file)
index 0000000..9e01bc2
--- /dev/null
@@ -0,0 +1,299 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaMediaStreamInfo.h
+ * @brief                      This is the header file for the %MediaStreamInfo class.
+ *
+ * This header file contains the declarations of the %MediaStreamInfo class.
+ */
+
+#ifndef _FMEDIA_MEDIA_STREAM_INFO_H_
+#define _FMEDIA_MEDIA_STREAM_INFO_H_
+
+#include <FBaseObject.h>
+#include <FBaseColIList.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FMediaAudioStreamInfo.h>
+#include <FMediaVideoStreamInfo.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @class       MediaStreamInfo
+ * @brief       This class provides methods to get media stream information.
+ *
+ * @since              2.0
+ *
+ * The %MediaStreamInfo class provides methods to get media stream information, including:
+ * - Content metadata, such as the title, artist, album title, genre, year, and album art.
+ * - Audio and video stream information.
+ *
+ * This class supports multiple stream content that consists of several audio or video tracks.
+ * This class provides a list of AudioStreamInfo and VideoStreamInfo that has the stream information of each audio or video track.
+ *
+ * For more detailed information, see %AudioStreamInfo and %VideoStreamInfo classes.
+ *
+ * The following example demonstrates how to use the %MediaStreamInfo class.
+ * @code
+ * #include <FBase.h>
+ * #include <FApp.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Media;
+ *
+ * class MediaStreamInfoSample
+ *      : public Tizen::Media::IPlayerEventListener
+ * {
+ * public:
+ *      result Test(void);
+ *
+ * protected:
+ *      virtual void OnPlayerOpened(result r) {}
+ *      virtual void OnPlayerEndOfClip(void) {}
+ *      virtual void OnPlayerBuffering(int percent) {}
+ *      virtual void OnPlayerErrorOccurred(PlayerErrorReason r) {}
+ *      virtual void OnPlayerInterrupted() {}
+ *      virtual void OnPlayerReleased() {}
+ *      virtual void OnPlayerSeekCompleted(result r) {}
+ *  virtual void OnPlayerAudioFocusChanged (void) {}
+ *
+ * private:
+ *      Player __player;
+ * };
+ *
+ * result
+ * MediaStreamInfoSample::Test(void)
+ * {
+ *      MediaStreamInfo*  pStreamInfo = null;
+ *      const IList* pInfoList = null;
+ *      const AudioStreamInfo* pInfo = null;
+ *      String path = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.aac";
+ *
+ *      __player.Construct(*this);
+ *      __player.OpenFile(path);
+ *      __player.Play();
+ *
+ *      // Checks the Player's state
+ *      if (__player.GetState() != PLAYER_STATE_PLAYING)
+ *      {
+ *              return E_INVALID_STATE;
+ *      }
+ *
+ *      // Gets the stream information from Player
+ *      pStreamInfo = __player.GetCurrentMediaStreamInfoN();
+ *      if (pStreamInfo == null)
+ *      {
+ *              return GetLastResult();
+ *      }
+ *
+ *      pInfoList = pStreamInfo->GetAudioStreamInfoList();
+ *      if (pInfoList == null)
+ *      {
+ *              goto CATCH;
+ *      }
+ *
+ *      pInfo = (const AudioStreamInfo*)pInfoList->GetAt(0);
+ *      if (pInfo == null)
+ *      {
+ *              goto CATCH;
+ *      }
+ *
+ *      AppLog("AudioStreamInfo: codec:0x%x, bitRate:%d, channel:%d, sampleRate:%d",
+ *                     pInfo->GetCodecType(), pInfo->GetBitRate(),
+ *                     pInfo->GetChannelType(), pInfo->GetSampleRate());
+ *
+ *      __player.Stop();
+ *      __player.Close();
+ *      return E_SUCCESS;
+ *
+ * CATCH:
+ *      delete pStreamInfo;
+ *      return E_SUCCESS;
+ * }
+ *
+ * @endcode
+ */
+class _OSP_EXPORT_ MediaStreamInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       *       This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since                2.0
+       */
+       virtual ~MediaStreamInfo(void);
+
+public:
+       /**
+       *       Gets the title.
+       *
+       *       @since          2.0
+       *
+       *       @return           The value of the title, @n
+       *                                 else an empty string if the content has no title
+       */
+       Tizen::Base::String GetTitle(void) const;
+
+       /**
+       *       Gets the name of the artist from the content.
+       *
+       *       @since          2.0
+       *
+       *       @return                                  The artist, @n
+       *                                                        else an empty string if the content has no artist name
+       */
+       Tizen::Base::String GetArtist(void) const;
+
+       /**
+       *       Gets the album title.
+       *
+       *       @since          2.0
+       *
+       *       @return           The title of the album, @n
+       *                                 else an empty string if the content has no album
+       */
+       Tizen::Base::String GetAlbumTitle(void) const;
+
+       /**
+       *       Gets the genre.
+       *
+       *       @since          2.0
+       *
+       *       @return           The genre, @n
+       *                                 else an empty string if the content has no genre
+       */
+       Tizen::Base::String GetGenre(void) const;
+
+       /**
+       *       Gets the year.
+       *
+       *       @since          2.0
+       *
+       *       @return         The year, @n
+       *                               else @c 0 if the content has no year
+       */
+       int GetYear(void) const;
+
+       /**
+       *       Gets the album art.
+       *
+       *       @since          2.0
+       *
+       *       @return         The album art in the content, @n
+       *                               else @c null if the content has no album art
+       */
+       Tizen::Base::ByteBuffer* GetAlbumArtN(void) const;
+
+       /**
+       *       Gets a list of the audio stream information.
+       *
+       *   @since              2.0
+       *
+       *       @return                                                                 A pointer to the list containing the audio stream information @n
+       *                                                                                       The value belongs to the AudioStreamInfo class.
+       *       @exception        E_SUCCESS                             The method is successful.
+       *       @exception        E_INVALID_DATA                        The stream cannot be parsed successfully.
+       *       @exception        E_SYSTEM                               A system error has occurred.
+       *       @remarks                                The specific error code can be accessed using the GetLastResult() method.
+       */
+       const Tizen::Base::Collection::IList* GetAudioStreamInfoList(void) const;
+
+       /**
+       *       Gets a list of the video stream information.
+       *
+       *   @since              2.0
+       *
+       *       @return          A pointer to a list containing the video stream information @n
+       *                                                               The value belongs to the VideoStreamInfo class.
+       *       @exception        E_SUCCESS                             The method is successful.
+       *       @exception        E_INVALID_DATA                        The stream cannot be parsed successfully.
+       *       @exception        E_SYSTEM                               A system error has occurred.
+       *       @remarks                                The specific error code can be accessed using the GetLastResult() method.
+       */
+       const Tizen::Base::Collection::IList* GetVideoStreamInfoList(void) const;
+
+       /**
+       * Copying of objects using this copy constructor is allowed.
+       *
+       * @since                2.0
+       *
+       * @return               The copy of this instance
+       * @param[in]    rhs     An instance of %MediaStreamInfo
+       */
+       MediaStreamInfo(const MediaStreamInfo & rhs);
+
+       /**
+       * Copying of objects using this copy assignment operator is allowed.
+       *
+       * @since                2.0
+       *
+       * @return The reference of this instance
+       * @param[in] rhs An instance of %MediaStreamInfo
+       */
+       MediaStreamInfo & operator =(const MediaStreamInfo & rhs);
+
+       /**
+       * Compares the specified instance of Tizen::Base::Object with the calling instance of %MediaStreamInfo.
+       *
+       * @since                2.0
+       *
+       * @return        @c true if the value of the specified instance equals the value of the current instance, @n
+       *                         else @c false
+       * @param[in]  rhs   The object to compare with the current instance
+       */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+       * Gets the hash value of the current instance.
+       *
+       * @since                2.0
+       *
+       * @return                                                 The hash value of the current instance
+       */
+       virtual int GetHashCode(void) const;
+
+private:
+       /**
+       *       This default constructor is intentionally declared as private so that only the platform can create an instance.
+       *
+       *       @param[in]              title                                   The value of the title @n
+       *       @param[in]              artist                                  The value of the artist @n
+       *       @param[in]              albumTitle                              The value of the title of the album @n
+       *       @param[in]              genre                                   The value of the genre @n
+       *       @param[in]              year                                    The value of the year @n
+       *       @param[in]              albumArt                                The value of the album art @n
+       *       @param[in]              pAudioStream                    A pointer to an audio stream list @n
+       *       @param[in]              pVideoStream                    A pointer to a video stream list @n
+       *       @param[in]              titleException                  An exception generated due to the title of audio or video @n
+       *       @param[in]              audioStreamException    The exception generated during audio streaming @n
+       *       @param[in]              videoStreamException    The exception generated during video streaming @n
+       */
+       MediaStreamInfo(const Tizen::Base::String& title, const Tizen::Base::String& artist, const Tizen::Base::String& albumTitle, const Tizen::Base::String& genre, int year, Tizen::Base::ByteBuffer* pAlbumArt, Tizen::Base::Collection::IList* pAudioStream, Tizen::Base::Collection::IList* pVideoStream, result audioStreamException, result videoStreamException);
+
+private:
+       class _MediaStreamInfoImpl *__pMediaStreamInfoImpl;
+       friend class _PlayerImpl;
+};
+
+}}//Tizen::Media
+
+#endif
diff --git a/inc/FMediaOpenal.h b/inc/FMediaOpenal.h
new file mode 100644 (file)
index 0000000..9c49225
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMediaOpenal.h
+ * @brief              This is the header file for the %Openal namespace.
+ *
+ * This header file contains the declarations of the %Openal namespace.
+ *
+ */
+#ifndef _FMEDIA_OPENAL_H_
+#define _FMEDIA_OPENAL_H_
+
+/**
+ * @if OSPDEPREC
+ * @namespace  Tizen::Media::Openal
+ * @brief              <i> [Deprecated]  </i>This namespace contains interfaces for %OpenAL.
+ * @deprecated   This namespace is deprecated because libopenal/libalut open source libraries are supported directly on Tizen.
+ * @since              2.0
+ *
+ * @remarks            @b Header @b %file: @b \#include @b <FMediaOpenal.h> or @b \#include @b <AL/al.h>, @b <AL/alc.h>, @b <AL/alex.h> and @b <AL/alut.h> @n
+ *                       @b Library: @b openal and @b alut
+ * @remarks    The capture functions are not supported.
+ *
+ *
+ * The %OpenAL namespace provides %OpenAL (Version 1.1) methods and utilities.
+ * %OpenAL is a cross platform three-dimensional audio method. It can also be referred as a software interface to audio hardware.
+ * The primary purpose of %OpenAL is to allow an application to position audio sources in three dimensional spaces around a listener, producing reasonable spatialization of the sources for the audio system.
+ * %OpenAL is appropriate for many audio applications, but is specifically designed for gaming audio.
+ * The %OpenAL namespace provides %OpenAL Utility Toolkit (ALUT) features.
+ *
+ * For more information, see the <a href="http://connect.creativelabs.com/openal/default.aspx"  target="_blank">Creative Labs Web site</a>.
+ * @endif
+ */
+namespace Tizen { namespace Media
+{
+namespace Openal
+{
+
+#include <AL/al.h>
+#include <AL/alc.h>
+#include <AL/alext.h>
+#include <AL/alut.h>
+
+}}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaPlayer.h b/inc/FMediaPlayer.h
new file mode 100644 (file)
index 0000000..16428d9
--- /dev/null
@@ -0,0 +1,797 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaPlayer.h
+ * @brief                      This is the header file for the %Player class.
+ *
+ * This header file contains the declarations of the %Player class.
+ */
+
+#ifndef _FMEDIA_PLAYER_H_
+#define _FMEDIA_PLAYER_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseUtilUri.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseObject.h>
+#include <FBaseColIMap.h>
+#include <FGrpBufferInfo.h>
+#include <FGrpVideoTexture.h>
+#include <FMediaPlayerTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaMediaStreamInfo.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaIPlayerEventListener.h>
+#include <FMediaIPlayerVideoEventListener.h>
+#include <FMediaIPlayerProgressiveDownloadListener.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class      Player
+ * @brief      This class provides methods to play audio and video.
+ *
+ * @since              2.0
+ *
+ * The %Player class provides methods to play audio and video, including:
+ * - Playing the audio or video content stored in the local storage (internal and external memory).
+ * - Playing the audio or video content stream from the content server over RTSP or HTTP.
+ * - Operating general controls for the audio or video content, such as play, pause, resume, and stop.
+ * - Moving the audio or video content on the basis of time.
+ * - Controlling the volume of the audio or video content.
+ * - Looping the audio or video content.
+ * - Getting the duration of an audio or the video content.
+ * - Playing back multiple audio streams.
+ *
+ * The maximum count of the %Player instance is limited by Media::MediaCapability class.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/playing_audio.htm">Playing Audio</a> and <a href="../org.tizen.native.appprogramming/html/guide/media/playing_video.htm">Playing Video</a>.
+ *
+ * The following example demonstrates how to use the %Player class to play an audio or video file.
+ *
+ * @code
+ * #include <FBase.h>
+ * #include <FGraphics.h>
+ * #include <FUi.h>
+ * #include <FApp.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Graphics;
+ * using namespace Tizen::Ui;
+ * using namespace Tizen::Ui::Controls;
+ * using namespace Tizen::Media;
+ *
+ * class PlayerSample
+ *     : public Tizen::Ui::Controls::Form
+ *     , public Tizen::Media::IPlayerEventListener
+ *     , public Tizen::Media::IPlayerVideoEventListener
+ * {
+ * public:
+ *     result StartVideo(void);
+ *     result StartAudio(void);
+ *     result StartVideoWithVideoEventListener(void);
+ *     void Stop(void);
+ *
+ * protected:
+ *     // IPlayerEventListener
+ *     virtual void OnPlayerOpened(result r) {}
+ *     virtual void OnPlayerEndOfClip(void) {}
+ *     virtual void OnPlayerBuffering(int percent) {}
+ *     virtual void OnPlayerErrorOccurred(PlayerErrorReason r) {}
+ *     virtual void OnPlayerInterrupted(void) {}
+ *     virtual void OnPlayerReleased(void) {}
+ *     virtual void OnPlayerSeekCompleted(result r) {}
+ *     virtual void OnPlayerAudioFocusChanged (void) {}
+ *
+ *     // IPlayerVideoEventListener
+ *     virtual void OnVideoFrameDecoded(Player &src, BitmapPixelFormat bitmapPixelFormat, const Dimension &dim,
+ *                                      const byte *pBuffer, int sizeOfBuffer, result r);
+ *
+ * private:
+ *     Player __player;
+ *     OverlayRegion *__pOverlay;
+ * };
+ *
+ * PlayerSample::PlayerSample(void)
+ * {
+ *     __pOverlay = null;
+ * }
+ *
+ * result
+ * PlayerSample::StartVideo(void)
+ * {
+ *     result r = E_SUCCESS;
+ *     Rectangle rect(0, 0, 320, 240);
+ *     BufferInfo bufferInfo;
+ *     String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp4";
+ *
+ *     // Gets OverlayRegion from this Form
+ *     __pOverlay = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_NORMAL);
+ *     if (__pOverlay == null)
+ *     {
+ *         return GetLastResult();
+ *     }
+ *
+ *     __pOverlay->GetBackgroundBufferInfo(bufferInfo);
+ *
+ *     r = __player.Construct(*this, &bufferInfo);
+ *     if (IsFailed(r))
+ *     {
+ *         goto CATCH;
+ *     }
+ *
+ *     // Opens file synchronously
+ *     r = __player.OpenFile(filePath, false);
+ *     if (IsFailed(r))
+ *     {
+ *         goto CATCH;
+ *     }
+ *
+ *     __player.SetLooping(true);
+ *     __player.SetVolume(80);
+ *
+ *     r = __player.Play();
+ *     if (IsFailed(r))
+ *     {
+ *         goto CATCH;
+ *     }
+ *
+ *     return E_SUCCESS;
+ *
+ * CATCH:
+ *     delete __pOverlay;
+ *     __pOverlay = null;
+ *     return r;
+ * }
+ *
+ * result
+ * PlayerSample::StartAudio(void)
+ * {
+ *     result r = E_SUCCESS;
+ *     String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp3";
+ *
+ *     r = __player.Construct(*this);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     // Opens file synchronously
+ *     r = __player.OpenFile(filePath, false);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     __player.SetVolume(80);
+ *
+ *     r = __player.Play();
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     return E_SUCCESS;
+ * }
+ *
+ * void
+ * PlayerSample::Stop(void)
+ * {
+ *     __player.Stop();
+ *     __player.Close();
+ *     if (__pOverlay)
+ *     {
+ *         delete __pOverlay;
+ *         __pOverlay = null;
+ *     }
+ * }
+ *
+ *
+ * result
+ * PlayerSample::StartVideoWithVideoEventListener(void)
+ * {
+ *     result r = E_SUCCESS;
+ *     Rectangle rect(0, 0, 320, 240);
+ *     String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp4";
+ *
+ *     r = __player.Construct(*this, *this);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     r = __player.OpenFile(filePath);
+ *     if (IsFailed(r))
+ *     {
+ *         return r;
+ *     }
+ *
+ *     // Gets OverlayRegion from this Form
+ *     __pOverlay = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_NORMAL);
+ *     if (__pOverlay == null)
+ *     {
+ *         return GetLastResult();
+ *     }
+ *
+ *     r = __player.Play();
+ *     if (IsFailed(r))
+ *     {
+ *         goto CATCH;
+ *     }
+ *
+ *     return E_SUCCESS;
+ *
+ * CATCH:
+ *     if (__pOverlay)
+ *     {
+ *         delete __pOverlay;
+ *         __pOverlay = null;
+ *     }
+ *     return r;
+ *  }
+ *
+ * void
+ * PlayerSample::OnVideoFrameDecoded(Player &src, BitmapPixelFormat bitmapPixelFormat, const Dimension &dim,
+ *                                   const byte *pBuffer, int sizeOfBuffer, result r)
+ * {
+ *     ByteBuffer buf;
+ *     OverlayRegionBufferPixelFormat overlayPixelFormat;
+ *
+ *     if (IsFailed(r))
+ *     {
+ *         return;
+ *     }
+ *
+ *     if (__pOverlay == null)
+ *     {
+ *         return;
+ *     }
+ *
+ *     if (bitmapPixelFormat == BITMAP_PIXEL_FORMAT_ARGB8888)
+ *     {
+ *         overlayPixelFormat = OVERLAY_REGION_BUFFER_PIXEL_FORMAT_ARGB8888;
+ *     }
+ *     else if (bitmapPixelFormat == BITMAP_PIXEL_FORMAT_RGB565)
+ *     {
+ *         overlayPixelFormat = OVERLAY_REGION_BUFFER_PIXEL_FORMAT_RGB565;
+ *     }
+ *     else // Unsupported pixel format
+ *     {
+ *         return;
+ *     }
+ *
+ *     buf.Construct(pBuffer, 0, sizeOfBuffer, sizeOfBuffer);
+ *     __pOverlay->SetInputBuffer(buf, dim, overlayPixelFormat);
+ * }
+ *
+ * @endcode
+ *
+ */
+
+class _OSP_EXPORT_ Player
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+       *
+       * @since                2.0
+       *
+       * @remarks      After creating an instance of this class, the Construct() method must be called explicitly to
+       *           initialize this instance.
+       * @see          Construct()
+       */
+       Player(void);
+
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       * This method deallocates the resources. This method must be called in the same thread as the Construct()
+       * method.
+       *
+       * @since                2.0
+       *
+       * @see          Construct()
+       */
+       virtual ~Player(void);
+
+public:
+       /**
+       * Initializes this instance of %Player with the specified parameters.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    listener                                        An instance of IPlayerEventListener
+       * @param[in]    pBufferInfo                                     The buffer information to display the video  @n
+       *                                                                                       This information is essential to play a video but not required for an audio content.
+       * @exception    E_SUCCESS                                                                               The method is successful.
+       * @exception    E_SYSTEM                                                                                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                                 The memory is insufficient. 
+       * @exception    E_RESOURCE_UNAVAILABLE          The player's resources are unavailable.
+       * @remarks      Multiple instances of %Player can be constructed.
+       */
+       result Construct(IPlayerEventListener& listener, const Tizen::Graphics::BufferInfo* pBufferInfo = null);
+
+       /**
+       * Opens an audio or video file to be played. @n
+       * This method works synchronously, but when the second parameter, @c isAsync is set to @c true, this method works asynchronously.
+       * Note that a method that works asynchronously must implement a listener.
+       *
+       * @if OSPCOMPAT
+       * @brief <i> [Compatibility] </i>
+       * @endif
+       * @since                2.0
+       * @if OSPCOMPAT
+       * @compatibility        This method has compatibility issues with OSP compatible applications. @n
+       *                                       For more information, see @ref CompIoPathPage "here".
+       * @endif
+       *
+       * @return                       An error code
+       * @param[in]            mediaLocalPath                  The local file path of the media source
+       * @param[in]            isAsync                                 Set to @c true for the asynchronous mode, @n
+       *                                                                                       else @c false for the synchronous mode
+       * @exception            E_SUCCESS                                                       The method is successful.
+       * @exception            E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception            E_SYSTEM                                                                A system error has occurred.
+       * @exception            E_FILE_NOT_FOUND                        The specified file cannot be found or accessed.
+       * @exception   E_INVALID_DATA           The specified file contains invalid data.
+       * @exception            E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @see                          Close()
+       */
+       result OpenFile(const Tizen::Base::String& mediaLocalPath, bool isAsync = false);
+
+       /**
+       * Opens an audio or video streaming content to play through the specified URL. @n
+       * This method works synchronously, but when the second parameter @c isAsync is set to @c true,
+       * this method works asynchronously. Note that a method that works asynchronously must implement a listener.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    mediaUri                                The URL of the media source
+       * @param[in]    isAsync                                 Set to @c true for the asynchronous mode, @n
+       *                                                                               else @c false for the synchronous mode
+       * @exception    E_SUCCESS                                                                       The method is successful.
+       * @exception    E_INVALID_STATE       This instance is in an invalid state for this method.
+       * @exception    E_CONNECTION_FAILED                     The network connection has failed.
+       * @exception    E_UNSUPPORTED_PROTOCOL  The protocol is not supported.
+       * @exception    E_SYSTEM                                                                                A system error has occurred.
+       * @remarks      This method is not thread-safe when @c isAsync is @c false.
+       * @remarks      Input URL should be encoded if there are non-alphanumeric characters in URL.
+       * @see                  Close()
+       */
+       result OpenUrl(const Tizen::Base::Utility::Uri& mediaUri, bool isAsync = false);
+
+       /**
+       * Opens an audio or video content to play on the memory. @n
+       * This method works synchronously, but when the second parameter @c isAsync is set to @c true, this method works asynchronously.
+       * Note that a method that works asynchronously must implement a listener.
+       *
+       * @since                2.0
+       *
+       * @return                       An error code
+       * @param[in]            mediaBuffer                             A pointer to the media source in the external memory
+       * @param[in]            isAsync                                 Set to @c true for asynchronous mode, @n
+       *                                                                                       else @c false for synchronous mode
+       * @exception            E_SUCCESS                                                               The method is successful.
+       * @exception            E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception            E_SYSTEM                                                                        A system error has occurred.
+       * @exception            E_OBJ_NOT_FOUND                         The specified media buffer cannot be found.
+       * @exception   E_INVALID_DATA              The specified buffer contains invalid data.
+       * @exception            E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @see                          Close()
+       */
+       result OpenBuffer(const Tizen::Base::ByteBuffer& mediaBuffer, bool isAsync = false);
+
+       /**
+       * Closes the audio or video content. @n
+       * This method works synchronously.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                                A system error has occurred.
+       * @see                  OpenFile(), OpenBuffer(), OpenUrl()
+       */
+       result Close(void);
+
+       /**
+       * Plays the audio or video content. @n
+       * The playback starts from the current position. In case of the ::PLAYER_STATE_ENDOFCLIP player state, the audio or video content
+       * is played again.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                                               The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                                           The device cannot be approached because of other applications which have a higher priority.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
+       * @exception    E_SYSTEM                                                                        A system error has occurred. @n
+       *                                                                       If playback has been paused, it resumes from the last position. @n
+       *                                                                       E_SYSTEM is returned when unsupported format or codec media data are received during streaming. @n
+       *                                    E_SYSTEM is returned when the unsupport resolution is set for rendering .
+       * @remarks              When this method is called after the %Player instance is created with the Construct() method that accepts the IPlayVideoEventListener
+       * interface as a parameter, it delivers every video frame of a video content continuously until the state is changed to PLAYER_STATE_ENDOFCLIP,
+       * or the Stop() or Pause() method is called .
+       * @see                  Stop(), Pause(), IPlayerVideoEventListener
+       */
+       result Play(void);
+
+       /**
+       * Stops the playback of the audio or video content. This method works synchronously.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                                A system error has occurred.
+       * @remarks              In the Real Time Streaming Protocol (RTSP), this method stops the media stream and requests the termination of the network session.
+       * @see                  Play(), Pause()
+       */
+       result Stop(void);
+
+       /**
+       * Pauses the playback of the audio or video content. @n
+       * To resume the playback, the Play() method must be called. This method works synchronously.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                                A system error has occurred.
+       * @see                  Play(), Stop()
+       */
+       result Pause(void);
+
+       /**
+       * Gets the state of an audio or video player.
+       *
+       * @since                2.0
+       *
+       * @return               The current state of the player
+       * @see                  Close(), Play(), Stop(), Pause(), PlayerState
+       */
+       PlayerState GetState(void) const;
+
+       /**
+       * Gets the time for the current playback position of the audio or video content. @n
+       * Accuracy of the retrieved time is determined by the subsystem (for example, the time slice of the OS scheduler,
+       * time resolution of the audio or video codec, or implementation of the audio or video player).
+       * Note that it must not be assumed that this method can reach the exact position mentioned by GetDuration().
+       *
+       * @since                2.0
+       *
+       * @return               The current position of the player in milliseconds
+       * @exception    E_SUCCESS                                                       The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SeekTo()
+       */
+       long GetPosition(void) const;
+
+       /**
+       * Seeks the current playback position of the audio or video content to the specified time. @n
+       * This method works asynchronously. @n
+       * Note that a method that works asynchronously must implement a listener. @n
+       * This method only works for the PLAYER_STATE_PLAYING, PLAYER_STATE_PAUSED and PLAYER_STATE_OPENED(local file/buffer playback only) states of the player. @n
+       * This method changes the playback position as well as the time value. @n
+       * In video, it may not change position accurately.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    msTime                          The time in milliseconds to move to the current playback position @n
+       *                                                                       @c 0 indicates the starting position.
+       * @exception    E_SUCCESS                                                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method. @n
+       *                                                       While playing live streaming, this operation returns E_INVALID_STATE. @n
+       *                                                               This method returns E_INVALID_STATE, if this method is called again before
+       *                                                                       IPlayerEventListener::OnPlayerSeekCompleted() is called.
+       * @exception    E_OUT_OF_RANGE                          The specified time is out of range.
+       * @exception    E_INVALID_DATA          The media data is inappropriate for seeking.
+       * @exception    E_SYSTEM                                                                A system error has occurred.
+       * @remarks              For video, this method delivers one video frame on the specified position through the video
+       *                               event. Before calling this method, the %Player instance must be created with the Construct()
+       *                               method has a parameter of the IPlayVideoEventListener interface .
+       * @see                  GetPosition(),  IPlayerVideoEventListener
+       */
+       result SeekTo(long msTime);
+
+       /**
+       * Gets the total running time of the media source.
+       *
+       * @since                2.0
+       *
+       * @return                       The running time of the media source in milliseconds
+       * @exception            E_SUCCESS                                               The method is successful.
+       * @exception            E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               While playing live streaming, this operation returns @c 0.
+       * @remarks           This method is valid in the playing and paused state of this instance.
+       * @see                  GetPosition()
+       */
+       long GetDuration(void) const;
+
+       /**
+       * Sets the specified value for the volume of an audio or video player.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    volume                  The new value of volume @n
+       *                                                               The range of this parameter is @c 0 to @c 100 and it is proportional to the current media sound volume level in setting.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_OUT_OF_RANGE          The specified volume is out of range.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @see                  GetVolume(), IsMuted(), SetMute()
+       */
+       result SetVolume(int volume);
+
+       /**
+       * Gets the current volume of an audio or video player.
+       *
+       * @since                2.0
+       *
+       * @return               The current volume level @n
+       *                               The range of this return value is @c 0 to @c 100.
+       * @see                  SetVolume(), IsMuted(), SetMute()
+       */
+       int GetVolume(void) const;
+
+       /**
+       * Sets the mute status of an audio or video player.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    mute                            Set to @c true to mute the audio or video player, @n
+       *                                                                       else @c false
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @see          GetVolume(), SetVolume(), IsMuted()
+       */
+       result SetMute(bool mute);
+
+       /**
+       * Checks the mute status of an audio or video player.
+       *
+       * @since                2.0
+       *
+       * @return               @c true if the audio or video player is muted, @n
+       *                               else @c false
+       * @see          GetVolume(), SetVolume(), SetMute()
+       */
+       bool IsMuted(void) const;
+
+       /**
+       * Sets an audio or video player to be in a loop. @n
+       * Set the looping to @c true to continuously play the audio or video content.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    looping             Set to @c true to play the audio or video content in a loop, @n
+       *                                                                       else @c false
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @remarks              In streaming, this method throws E_INVALID_STATE for the cost of network.
+       * @see          IsLooping()
+       */
+       result SetLooping(bool looping);
+
+       /**
+       * Checks whether the audio or video player is in a loop.
+       *
+       * @since                2.0
+       *
+       * @return               @c true if the audio or video player is in a loop, @n
+       *                               else @c false
+       * @see          SetLooping()
+       */
+       bool IsLooping(void) const;
+
+       /**
+       * Gets the current media stream information.
+       *
+       * @since                2.0
+       *
+       * @return       A pointer to the MediaStreamInfo instance containing metadata for the current media stream
+       * @exception    E_SUCCESS                                                               The method is successful.
+       * @exception    E_INVALID_STATE     This instance is in an invalid state for this method.
+       * @exception    E_INVALID_CONTENT   The content is inappropriate to compose media stream information.
+       * @exception    E_SYSTEM            A system error has occurred.
+       * @remarks       This method returns a stream information of the media, which is currently being played.
+       *               The specific error code can be accessed using the GetLastResult() method.
+       *               This method must be called after Play() to get the correct data.
+       * @see          MediaStreamInfo
+       */
+       MediaStreamInfo* GetCurrentMediaStreamInfoN(void) const;
+
+       /**
+       * Sets the rendering buffer for the video playback.
+       *
+       * @since                2.0
+       *
+       * @return       An error code
+       * @param[in]    bufferInfo                      The buffer information to display the video
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_SYSTEM                                                        A system error has occurred. @n
+       *                                   E_SYSTEM is returned when the unsupport resolution is set for rendering .
+       * @remarks      This method works for the PLAYER_STATE_OPENED, PLAYER_STATE_ENDOFCLIP, PLAYER_STATE_STOPPED, PLAYER_STATE_PAUSED, and PLAYER_STATE_PLAYING states of the player.
+       * @remarks              This method throws E_INVALID_STATE after the player instance is constructed with IPlayerVideoEventListener.
+       */
+       result SetRenderingBuffer(const Tizen::Graphics::BufferInfo& bufferInfo);
+
+       /**
+       * Initializes this instance of %Player with the specified parameters.
+       *
+       * @since                2.0
+       *
+       * @return       An error code
+       * @param[in]    listener                    An IPlayerEventListener instance
+       * @param[in]    videoListener               An IPlayerVideoEventListener instance
+       * @exception    E_SUCCESS                   The method is successful.
+       * @exception    E_SYSTEM                    A system error has occurred.
+       * @exception    E_RESOURCE_UNAVAILABLE      The player's resources are unavailable.
+       * @exception    E_OUT_OF_MEMORY             The memory is insufficient. 
+       * @remarks      This method constructs the %Player instance to render the video content into the buffer of the video event listener.
+       * @see          IPlayerVideoEventListener
+       */
+       result Construct(IPlayerEventListener& listener, IPlayerVideoEventListener& videoListener);
+
+       /**
+       * Captures the video frame. @n
+       * This method delivers one video frame of a video content by using the IPlayVideoEventListener interface only once in the %Player instance. @n
+       * This method works only for the PLAYER_STATE_OPENED state of the %Player instance, and the state of the %Player instance is changed to PLAYER_STATE_PAUSED from PLAYER_STATE_OPENED after calling this method.
+       *
+       * @since                2.0
+       *
+       * @return       An error code
+       * @exception    E_SUCCESS                                                                       The method is successful.
+       * @exception    E_INVALID_STATE                                 This instance is in an invalid state for this method. @n
+       *                                                                               This method throws E_INVALID_STATE if the %Player instance is
+       *                                                                               constructed without IPlayerVideoEventListener.
+       * @exception    E_INVALID_OPERATION             This method is invalid for the current media content.
+       * @exception    E_SYSTEM                                                                        A system error has occurred.
+       * @remarks      In the Real Time Streaming Protocol (RTSP), this method does not work properly.
+       * @see          IPlayerVideoEventListener
+       */
+       result CaptureVideo(void);
+
+       /**
+       * Sets audio stream type
+       *
+       * @since                2.0
+       *
+       * @return                 An error code
+       * @param[in]    type                                            An audio stream type
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       */
+       result SetAudioStreamType(AudioStreamType type);
+
+       /**
+       * Opens an audio or video streaming content to play through the specified URL with the HTTP header.@n
+       * This method works asynchronously, thus application can call further APIs of %Player after IPlayerEventListener::OnPlayerOpened() is called.
+       *
+       * @since                2.0
+       *
+       * @return                                                               An error code
+       * @param[in]    url                                             The URL of the media source
+       * @param[in]    pHeader                                 The list of field and value pairs that will be added in HTTP request header. @n
+       The types of field and value are described in the Programming Guide. If @c null, then default values will be set
+       *
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_PROTOCOL  The protocol is not supported.
+       * @exception    E_INVALID_ARG                   The specified input parameter is invalid.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks      See Programming Guide for the detail information of supported HTTP header fields.
+       * @remarks      Input URL should be encoded if there are non-alphanumeric characters in URL.
+       * @see                  Close()
+       */
+       result OpenUrlAsync(const Tizen::Base::String& url, const Tizen::Base::Collection::IMap* pHeader = null);
+
+       /**
+       * Opens an audio or video streaming content to play through the specified HTTP URL with the HTTP header for the progressive download playback. @n
+       * This method works asynchronously, thus application can call further APIs of %Player after IPlayerEventListener::OnPlayerOpened() is called.
+       * The content information of the media source should be located at the beginning of the file for the progressive download playback. Otherwise, it does not guarantee to play and download media stream properly.
+       *
+       * @since                2.0
+       *
+       * @return                                                               An error code
+       * @param[in]    url                                             The URL of the media source
+       * @param[in]    filePath                                The file path on local file system that the downloaded content will be saved.
+       * @param[in]    listener                                The download listener
+       * @param[in]    pHeader                                 The list of field and value pairs that will be added in HTTP request header. @n
+       The types of field and value are described in the Programming Guide.
+                                                                                       If @c null, then default values will be set..
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_PROTOCOL  The protocol is not supported.
+       * @exception    E_INVALID_ARG                   The specified input parameter is invalid.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks      Download will start when Play() is called.
+       * @remarks      If the specified file name already exists, then the old file will be overwritten with the new one.
+       * @remarks      See Programming Guide for the detail information of supported HTTP header fields.
+       * @remarks      Input URL should be encoded if there are non-alphanumeric characters in URL.
+       * @see                  Close(), Play()
+       */
+       result OpenUrlAsync(const Tizen::Base::String& url, const Tizen::Base::String& filePath, IPlayerProgressiveDownloadListener& listener, const Tizen::Base::Collection::IMap* pHeader = null);
+
+
+       /**
+       * Sets the interval of calling the progress event
+       *
+       * @since                2.0
+       *
+       * @param[in]    percent                                 The progress period interval as a percentage value.
+       * @remark               If the server does not provide the information about the content size, progress event will occur randomly.
+       * @remarks              If the percentage value is not set, @c 10 will be set as a default value.
+       * @see                  OnPlayerProgressiveDownloadInProgress(), IPlayerProgressiveDownloadListener
+       */
+       void SetProgressiveDownloadIntervalByPercent(int percent);
+
+       /**
+       * Initializes this instance of %Player with the specified parameters.
+       *
+       * @since                2.0
+       *
+       * @return        An error code
+       * @param[in]   listener                        An IPlayerEventListener instance
+       * @param[in]   videoTexture                  An VideoTexture instance
+       * @exception    E_SUCCESS                The method is successful.
+       * @exception    E_INVALID_ARG      A specified input parameter is invalid.
+       * @exception    E_RESOURCE_UNAVAILABLE  The player's resources are unavailable.
+       * @remarks      This method constructs the %Player instance to render the video content into the video texture area.
+       */
+       result Construct(IPlayerEventListener& listener, Tizen::Graphics::Opengl::VideoTexture& videoTexture);
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        *  @since              2.0
+        */
+       Player(const Player& rhs);
+
+       /**
+        *The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        */
+       Player& operator =(const Player& rhs);
+
+       friend class _PlayerImpl;
+       class _PlayerImpl* __pPlayerImpl;
+};
+
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaPlayerTypes.h b/inc/FMediaPlayerTypes.h
new file mode 100644 (file)
index 0000000..2fad143
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaPlayerTypes.h
+ * @brief                      This is the header file for the Player class.
+ *
+ * This header file contains the declarations of the enumerations of the Player class.
+ */
+
+#ifndef _FMEDIA_PLAYER_TYPES_H_
+#define _FMEDIA_PLAYER_TYPES_H_
+
+namespace Tizen { namespace Media
+{
+
+#define MIN_PLAYER_VOLUME 0
+#define MAX_PLAYER_VOLUME 100
+#define DEFAULT_PLAYER_VOLUME 50
+
+/**
+ * @enum PlayerState
+ *
+ * Defines the state of the player.
+ *
+ * @since              2.0
+ *
+ * @see                Tizen::Media::Player::GetState()
+ */
+enum PlayerState
+{
+       PLAYER_STATE_INITIALIZED,       /**< The player is initialized */
+       PLAYER_STATE_OPENING,           /**< The player opening behavior is processed */
+       PLAYER_STATE_OPENED,            /**< The source is opened */
+       PLAYER_STATE_ENDOFCLIP,         /**< The player has reached to the end of the clip */
+       PLAYER_STATE_STOPPED,           /**< The player has stopped and has no current play-time, but the media content is still opened and initialized */
+       PLAYER_STATE_PAUSED,            /**< The player playback is paused */
+       PLAYER_STATE_PLAYING,           /**< The player is playing the media content */
+       PLAYER_STATE_CLOSED,            /**< The source is closed */
+       PLAYER_STATE_ERROR,             /**< An error has occurred */
+
+};
+
+/**
+ * @enum PlayerErrorReason
+ *
+ * Defines the player error reason.
+ *
+ * @since              2.0
+ */
+enum PlayerErrorReason
+{
+       PLAYER_ERROR_NONE,                      // Not defined
+       PLAYER_ERROR_INVALID_DATA,              /**< The data is invalid */
+       PLAYER_ERROR_CONNECTION_LOST,           /**< The connection is lost */
+       PLAYER_ERROR_STREAMING_TIMEOUT,         /**< The streaming has timed out */
+       PLAYER_ERROR_TRANSPORT,                 /**< The transport has failed */
+       PLAYER_ERROR_SERVER,                    /**< The server has failed */
+       PLAYER_ERROR_OUT_OF_MEMORY,             /**< The memory is insufficient*/
+       PLAYER_ERROR_DEVICE_FAILED,             /**< The player device has failed */
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaRecorderTypes.h b/inc/FMediaRecorderTypes.h
new file mode 100755 (executable)
index 0000000..af84cfe
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaRecorderTypes.h
+ * @brief                      This is the header file for the enumerations of the AudioRecorder and VideoRecorder classes.
+ *
+ * This header file contains the definitions of the enumerations of the AudioRecorder and VideoRecorder classes.
+ */
+
+#ifndef _FMEDIA_RECORDER_TYPES_H_
+#define _FMEDIA_RECORDER_TYPES_H_
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @enum RecorderState
+ *
+ * Defines the state of the recorder.
+ *
+ * @since              2.0
+ *
+ * @see                AudioRecorder::GetState()
+ * @see                VideoRecorder::GetState()
+ */
+enum RecorderState
+{
+       RECORDER_STATE_INITIALIZED,      /**< The recorder is initialized */
+       RECORDER_STATE_OPENED,            /**< The file to write into is opened */
+       RECORDER_STATE_ENDOF_FILE,        /**< The recorder has reached the end of size or time */
+       RECORDER_STATE_STOPPING,                /**< The recorder stops recording */
+       RECORDER_STATE_STOPPED,          /**< The recorder is stopped and has no current record-time @n
+                                                                                However, the media content is opened and initialized. */
+       RECORDER_STATE_PAUSING,          /**< The recorder is paused at a specific position */
+       RECORDER_STATE_PAUSED,            /**< The recorder is paused */
+       RECORDER_STATE_STARTING,                /**< The recording operation is starting */
+       RECORDER_STATE_RECORDING,          /**< The recording state of the recorder */
+       RECORDER_STATE_CLOSING,          /**< The recorder process is closing */
+       RECORDER_STATE_CLOSED,            /**< The file is closed */
+       RECORDER_STATE_ERROR,              /**< An error has occurred in the recorder */
+};
+
+/**
+ * @enum RecordingQuality
+ *
+ * Defines the quality of the recorder.
+ *
+ * @since              2.0
+ *
+ * @see        AudioRecorder::SetQuality()
+ * @see        AudioRecorder::GetQuality()
+ * @see        VideoRecorder::SetQuality()
+ * @see        VideoRecorder::GetQuality()
+
+ */
+enum RecordingQuality
+{
+       RECORDING_QUALITY_LOW,                            /**< The low quality */
+       RECORDING_QUALITY_MEDIUM,                          /**< The medium quality */
+       RECORDING_QUALITY_HIGH,                          /**< The high quality */
+};
+
+/**
+ * @enum RecordingEndCondition
+ *
+ * Defines the record ending by reaching the limit.
+ *
+ * @since              2.0
+ *
+ * @see        AudioRecorder::SetMaxRecordingTime()
+ * @see        VideoRecorder::SetMaxRecordingTime()
+ *
+ */
+enum RecordingEndCondition
+{
+       RECORDING_ENDOF_MAX_SIZE,                  /**< The end of file size */
+       RECORDING_ENDOF_MAX_TIME,                  /**< The end of time */
+};
+
+/**
+ * @enum RecorderErrorReason
+ *
+ * Defines the error reasons of the recorder.
+ *
+ * @since              2.0
+ */
+enum RecorderErrorReason
+{
+       RECORDER_ERROR_NONE,                                            // Undefined error
+       RECORDER_ERROR_OUT_OF_STORAGE,            /**< The storage is insufficient */
+       RECORDER_ERROR_STORAGE_FAILED,            /**< The device storage access has failed */
+       RECORDER_ERROR_DEVICE_FAILED,              /**< The recording device has failed */
+};
+
+/**
+ * @enum RecordingRotation
+ *
+ * Defines the recording rotation of the recorder.
+ *
+ * @since              2.0
+ */
+enum RecordingRotation
+{
+       RECORDING_ROTATION_NONE,                /**< The recording rotation: None */
+       RECORDING_ROTATION_90,                  /**< The recording rotation: 90 degree rotation */
+       RECORDING_ROTATION_180,                 /**< The recording rotation: 180 degree rotation */
+       RECORDING_ROTATION_270,                 /**< The recording rotation: 270 degree rotation */
+};
+
+}}
+
+#endif
diff --git a/inc/FMediaTone.h b/inc/FMediaTone.h
new file mode 100644 (file)
index 0000000..23b7a6b
--- /dev/null
@@ -0,0 +1,219 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaTone.h
+ * @brief                      This is the header file for the %Tone class.
+ *
+ * This header file contains the declarations of the %Tone class.
+ */
+
+#ifndef _FMEDIA_TONE_H_
+#define _FMEDIA_TONE_H_
+
+#include <FBaseObject.h>
+#include <FMediaToneTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class              Tone
+ * @brief              This class generates a tone.
+ *
+ * @since              2.0
+ *
+ * @remarks
+ * The instance of the %Tone class can be played using TonePlayer.
+ *
+ * The %Tone class generates a tone and provides methods for:
+ * - Generating a single tone.
+ * - Generating dual tones with two different values of frequencies.
+ * - Generating a silent tone for a specified period of interval.
+ *
+ */
+class _OSP_EXPORT_ Tone
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       *       The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+       *
+       *   @since              2.0
+       *
+       *       @remarks        After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize this instance.
+       *       @see            Construct()
+       */
+       Tone(void);
+
+       /**
+       *       This destructor overrides Tizen::Base::Object::~Object().
+       *       The resources are deallocated by this method.
+       *       This method must be called in the same thread as the Construct() method.
+       *
+       *   @since              2.0
+       *
+       *       @see            Construct()
+       */
+       virtual ~Tone(void);
+
+public:
+       /**
+       * @if OSPDEPREC
+       *       Initializes this instance of %Tone with the values of the specified tone.
+       *
+       *     @brief    <i> [Deprecated] </i>
+       *     @deprecated     This method is deprecated because this method is not used as 2-phase constructor.
+       *     @since            2.0
+       *
+       *       @return         An error code
+       *       @param[in]      firstFrequency                                  The first frequency of the dual tone in hertz (Hz) @n
+       *                                               The range of this parameter is @c 0 Hz ~ @c 15000 Hz.
+       *       @param[in]      secondFrequency                                 The second frequency of the dual tone in hertz (Hz) @n
+       *                                               The range of this parameter is @c 0 Hz ~ @c 15000 Hz.
+       *       @param[in]      duration                                                The duration of the tone in milliseconds @n
+       *                                               The value of this parameter must be greater than @c 0.
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_OUT_OF_RANGE                                  A specified input parameter is out of range.
+       *       @remarks If both the input frequencies are @c 0 Hz, the tone is set as a silent tone.
+       * @endif
+       */
+       result Construct(int firstFrequency, int secondFrequency, long duration);
+
+
+       /**
+       * @if OSPDEPREC
+       *       Initializes this instance of %Tone with the values of the specified DTMF preset tone.
+       *
+       *     @brief    <i> [Deprecated] </i>
+       *       @deprecated     This method is deprecated because this method is not used as 2-phase constructor.
+       *     @since            2.0
+       *
+       *       @return         An error code
+       *       @param[in]      preset                                                  The preset of the DTMF tone
+       *       @param[in]      duration                                                The duration of the tone in milliseconds @n
+       *                                               The value of this parameter must be greater than @c 0.
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @exception      E_OUT_OF_RANGE                                  A specified input parameter is out of range.
+       * @endif
+       */
+       result Construct(DtmfPreset preset, long duration);
+
+
+       /**
+       *       Gets the current frequency.
+       *
+       *   @since              2.0
+       *
+       *       @return         An error code
+       *       @param[out]     firstFrequency                                  The first frequency of the dual tone in hertz (Hz)
+       *       @param[out]     secondFrequency                                 The second frequency of the dual tone in hertz (Hz)
+       *       @exception      E_SUCCESS                                               The method is successful.
+       *       @remarks The specified input parameters of this method are @c -1 when an exception occurs.
+       */
+       result GetFrequency(int& firstFrequency, int& secondFrequency) const;
+
+       /**
+       *       Gets the current duration.
+       *
+       *   @since              2.0
+       *
+       *       @return         The duration of the tone
+       *       @remarks This method returns @c 0 before the Construct() method is called.
+       */
+       long GetDuration(void) const;
+
+       /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+        *
+       *   Initializes this instance of %Tone with the values of the specified tone.
+       *
+       *   @since              2.0
+       *
+       *   @param[in]       firstFrequency    The first frequency of the dual tone in hertz (Hz) @n
+       *                                          The range of this parameter is @c 0 Hz ~ @c 15000 Hz.
+       *   @param[in]       secondFrequency   The second frequency of the dual tone in hertz (Hz) @n
+       *                                      The range of this parameter is @c 0 Hz ~ @c 15000 Hz.
+       *   @param[in]       duration          The duration of the tone in milliseconds @n
+       *                                          The value of this parameter must be greater than @c 0.
+       *   @remarks If both the input frequencies are @c 0 Hz, the tone is set as a silent tone.
+       */
+       Tone(int firstFrequency, int secondFrequency, long duration);
+
+       /**
+        * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+       * Initializes this instance of %Tone with the values of the specified DTMF preset tone.
+       *
+       * @since                2.0
+       *
+       * @param[in]       preset              The preset of the DTMF tone
+       * @param[in]       duration            The duration of the tone in milliseconds @n
+       *                                          The value of this parameter must be greater than @c 0.
+       */
+       Tone(DtmfPreset preset, long duration);
+
+       /**
+       * Compares the specified instance of %Tone with the calling instance.
+       *
+       * @since                2.0
+       *
+       * @return             @c true if the values match, @n
+       *                     else @c false
+       * @param[in]    rhs   The other Object to be compared
+       * @see                Object::Equals()
+       */
+       virtual bool Equals(const Object& rhs) const;
+
+       /**
+       * Gets the hash value of the current instance.
+       *
+       * @since                2.0
+       *
+       * @return            The current instance's hash value
+       */
+       virtual int GetHashCode(void) const;
+
+       /**
+       * Copying of objects using this copy constructor is allowed.
+       *
+       * @since                2.0
+       *
+       * @return               The copy of this instance
+       * @param[in]    rhs     An instance of %Tone
+       */
+       Tone(const Tone& rhs);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since               2.0
+        *
+        * @return              The reference of this instance
+        * @param[in]   rhs     An instance of %Tone
+        */
+       Tone& operator =(const Tone& rhs);
+
+private:
+       int __firstFrequency;
+       int __secondFrequency;
+       long __duration;
+       bool __isConstructed;
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaTonePlayer.h b/inc/FMediaTonePlayer.h
new file mode 100644 (file)
index 0000000..364e3ef
--- /dev/null
@@ -0,0 +1,346 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaTonePlayer.h
+ * @brief                      This is the header file for the %TonePlayer class.
+ *
+ * This header file contains the declarations of the %TonePlayer class.
+ */
+
+#ifndef _FMEDIA_TONE_PLAYER_H_
+#define _FMEDIA_TONE_PLAYER_H_
+
+#include <FBaseColIList.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaTone.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaITonePlayerEventListener.h>
+
+namespace Tizen { namespace Media
+{
+class _TonePlayerImpl;
+/**
+ * @class              TonePlayer
+ * @brief              This class plays the tone(s).
+ *
+ * @since              2.0
+ *
+ * @remarks
+ * The maximum number of the %TonePlayer instance is limited by Media::MediaCapability class. This number is a system wide count so that the application should not be able to construct instances more than the maximum number.
+ *
+ * The %TonePlayer class provides methods for:
+ * - Playing the tone(s)
+ * - Controlling a tone player instance
+ *
+ * The following example demonstrates how to use the %TonePlayer class for playing a single tone and a list of tones.
+ *
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Media;
+ *
+ * class TonePlayerSample
+ *      : public ITonePlayerEventListener
+ * {
+ * public:
+ *      result PlayTone(void);
+ *      result PlayToneList(void);
+ *      void Stop(void);
+ *
+ * protected:
+ *   virtual void      OnTonePlayerAudioFocusChanged (Tizen::Media::TonePlayer &src) {}
+ *      virtual void OnTonePlayerEndOfTone(TonePlayer& src) {}
+ *      virtual void OnTonePlayerInterrupted(TonePlayer& src) {}
+ *      virtual void OnTonePlayerReleased(TonePlayer& src) {}
+ *      virtual void OnTonePlayerErrorOccurred(TonePlayer& src, result r) {}
+ *
+ * private:
+ *      TonePlayer __player;
+ *      LinkedList __toneList;
+ * };
+ *
+ * result
+ * TonePlayerSample::PlayTone(void)
+ * {
+ *      result r = E_SUCCESS;
+ *      Tone *pTone = null;
+ *
+ *      pTone = new Tone(DTMF_PRESET_S, 2000);
+ *
+ *      __toneList.Add(*pTone);
+ *
+ *      // Constructs the TonePlayer
+ *      __player.Construct(*this);
+ *
+ *      // Opens TonePlayer with a single tone
+ *      __player.Open(*pTone, 5);
+ *      r = __player.Play();
+ *      if (IsFailed(r))
+ *      {
+ *              goto CATCH;
+ *      }
+ *
+ *      return E_SUCCESS;
+ *
+ * CATCH:
+ *      __toneList.RemoveAll(true);
+ *      return r;
+ * }
+ *
+ * result
+ * TonePlayerSample::PlayToneList(void)
+ * {
+ *      result r = E_SUCCESS;
+ *
+ *      // Adds some tones to the tone list
+ *      __toneList.Add(*(new Tone(DTMF_PRESET_1, 2000)));
+ *      __toneList.Add(*(new Tone(2000, 5000, 3000)));
+ *      __toneList.Add(*(new Tone(DTMF_PRESET_8, 500)));
+ *      __toneList.Add(*(new Tone(0, 0, 1500)));  // Silence
+ *      __toneList.Add(*(new Tone(10000, 14000, 2500)));
+ *
+ *      __player.Construct(*this);
+ *
+ *      // Opens TonePlayer with a tone list
+ *      __player.Open(__toneList, 2);
+ *
+ *      r = __player.Play();
+ *      if (IsFailed(r))
+ *      {
+ *              goto CATCH;
+ *      }
+ *
+ *      return E_SUCCESS;
+ *
+ * CATCH:
+ *      __toneList.RemoveAll(true);
+ *      return r;
+ * }
+ *
+ * void
+ * TonePlayerSample::Stop(void)
+ * {
+ *      __player.Stop();
+ *      __player.Close();
+ *      __toneList.RemoveAll(true);
+ * }
+ *
+ * @endcode
+ */
+
+class _OSP_EXPORT_ TonePlayer
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be
+        *                              called explicitly to initialize this instance
+        * @see                 Construct()
+        */
+       TonePlayer(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All the allocated resources are released by this method. @n
+        * This method must be called in the same thread as the Construct() method.
+        *
+        * @since               2.0
+        *
+        * @see                 Construct()
+        */
+       virtual ~TonePlayer(void);
+
+       /**
+       * Initializes this instance of %TonePlayer with the specified listener.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    listener                                                                                An instance of ITonePlayerEventListener
+       * @exception    E_SUCCESS                                                                       The method is successful.
+       * @exception    E_RESOURCE_UNAVAILABLE  The tone player's resources are unavailable.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient. 
+       * @exception    E_SYSTEM                                                                                A system error has occurred.
+       */
+       result Construct(Tizen::Media::ITonePlayerEventListener& listener);
+
+       /**
+       * Opens the specified list of tones.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    toneList                        A list of Tone instances
+       * @param[in]    repeatCount                     The number of times the list of tones should be played @n
+       *                                                                       This number is greater than or equal to @c 1.
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OBJ_NOT_FOUND         The specified tone instance cannot be found in the list.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_OUT_OF_RANGE                  The count is out of range.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              The item(s) of the specified @c toneList should be an instance(s) of Tone.
+       * @see                  Close()
+       */
+       result Open(const Tizen::Base::Collection::IList& toneList, int repeatCount = 1);
+
+       /**
+       * Opens the specified tone.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    tone                            The tone instance
+       * @param[in]    repeatCount                     The number of times a tone should be played @n
+       *                                                                       This number is greater than or equal to @c 1.
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_OUT_OF_RANGE                  The count is out of range.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @see                  Close()
+       */
+       result Open(const Tizen::Media::Tone& tone, int repeatCount = 1);
+
+       /**
+       * Plays the playback or resumes the playback if Pause() has been called. @n
+       * In case of the TONE_PLAYER_STATE_END_OF_TONE state, the tone(s) can be played again.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device is busy for other operations.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @remarks              The playback starts from the current position. If playback is paused, playback restarts from
+       *                               the last position.
+       * @see                  Stop(), Pause()
+       */
+       result Play(void);
+
+       /**
+       * Stops the playback.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @see                  Play(), Pause()
+       */
+       result Stop(void);
+
+       /**
+       * Pauses the playback. @n
+       * To resume the paused playback, call Play().
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @see                  Play(), Stop()
+       */
+       result Pause(void);
+
+
+       /**
+       * Sets the volume level.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    volume                          The new value for volume @n
+       *                                                                       The range of this parameter is @c 0 to @c 100 and it is proportional to the current media sound volume level in setting.
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_OUT_OF_RANGE                  The specified @c volume parameter is out of range.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @see                  GetVolume()
+       */
+       result SetVolume(int volume);
+
+       /**
+       * Gets the current volume level
+       *
+       * @since                2.0
+       *
+       * @return               The current volume level @n
+       *                               The range of this return value is @c 0 to @c 100.
+       * @remarks              If the @c volume is not set, the default volume @c 50 is returned.
+       * @see                  SetVolume()
+       */
+       int GetVolume(void) const;
+
+       /**
+       * Closes the tone player.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                                        A system error has occurred.
+       * @see                  Open()
+       */
+       result Close(void);
+
+       /**
+       * Gets the current state of the tone player instance.
+       *
+       * @since                2.0
+       *
+       * @return               The current state of the tone player
+       */
+       TonePlayerState GetState(void) const;
+
+       /**
+       * Sets audio stream type for tone playback
+       *
+       * @since                2.0
+       *
+       * @return                 An error code
+       * @param[in]    type                                            An audio stream type
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @remarks      This method should be called before Open().
+       */
+       result SetAudioStreamType(AudioStreamType type);
+
+private:
+       TonePlayer(const TonePlayer& rhs);
+       TonePlayer& operator =(const TonePlayer& rhs);
+
+       friend class _TonePlayerImpl;
+       _TonePlayerImpl* __pTonePlayerImpl;
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaToneTypes.h b/inc/FMediaToneTypes.h
new file mode 100644 (file)
index 0000000..9ba2d03
--- /dev/null
@@ -0,0 +1,129 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaToneTypes.h
+ * @brief                      This is the header file for the common types of Tone and TonePlayer.
+ *
+ * This header file contains the declarations of the enumerations of the Tone class.
+ */
+
+#ifndef _FMEDIA_TONE_TYPES_H_
+#define _FMEDIA_TONE_TYPES_H_
+
+namespace Tizen { namespace Media
+{
+
+
+//
+// This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+//
+// Default volume level.
+//
+// @since              2.0
+//
+static const int DEFAULT_TONE_PLAYER_VOLUME = 50;
+
+//
+// This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+//
+// Sampling rate.
+//
+// @since              2.0
+//
+static const int SAMPLING_RATE = 22050;
+
+//
+// This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+//
+// Maximum frequency.
+//
+// @since              2.0
+//
+static const int MAX_FREQUENCY = 15000;
+
+//
+// This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+//
+// Minimum frequency.
+//
+// @since              2.0
+//
+static const int MIN_FREQUENCY = 0;
+
+//
+// This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+//
+// Minimum duration.
+//
+// @since              2.0
+//
+static const int MIN_DURATION = 1;
+
+/**
+ * @enum TonePlayerState
+ *
+ * Defines the state of the tone player.
+ *
+ * @since              2.0
+ *
+ * @see        Tizen::Media::TonePlayer::GetState()
+ */
+enum TonePlayerState
+{
+       TONE_PLAYER_STATE_IDLE = 0x00,          /**< The tone player is idle */
+       TONE_PLAYER_STATE_INITIALIZED,          /**< The tone player is initialized */
+       TONE_PLAYER_STATE_OPENED,               /**< The tone player instance is opened */
+       TONE_PLAYER_STATE_PLAYING,              /**< The tone player is playing the tone(s) */
+       TONE_PLAYER_STATE_PAUSED,               /**< The tone player playback is paused  */
+       TONE_PLAYER_STATE_STOPPED,              /**< The tone player has stopped and has no current play-time @n
+                                                            However, the tone(s) is still opened and initialized. */
+       TONE_PLAYER_STATE_CLOSED,               /**< The tone player is closed */
+       TONE_PLAYER_STATE_END_OF_TONE,          /**< The tone player has reached the end of the tone(s) */
+       TONE_PLAYER_STATE_ERROR,                /**< An error has occurred */
+};
+
+/**
+ * @enum DtmfPreset
+ *
+ * Defines the Dual-Tone Multi-Frequency (DTMF) presets for the keys.
+ *
+ * @since              2.0
+ */
+enum DtmfPreset
+{
+       DTMF_PRESET_0 = 0x00,       /**< The DTMF tone for key 0: 1336Hz, 941Hz */
+       DTMF_PRESET_1,              /**< The DTMF tone for key 1: 1209Hz, 697Hz */
+       DTMF_PRESET_2,              /**< The DTMF tone for key 2: 1336Hz, 697Hz */
+       DTMF_PRESET_3,              /**< The DTMF tone for key 3: 1477Hz, 697Hz */
+       DTMF_PRESET_4,              /**< The DTMF tone for key 4: 1209Hz, 770Hz */
+       DTMF_PRESET_5,              /**< The DTMF tone for key 5: 1336Hz, 770Hz */
+       DTMF_PRESET_6,              /**< The DTMF tone for key 6: 1477Hz, 770Hz */
+       DTMF_PRESET_7,              /**< The DTMF tone for key 7: 1209Hz, 852Hz */
+       DTMF_PRESET_8,              /**< The DTMF tone for key 8: 1336Hz, 852Hz */
+       DTMF_PRESET_9,              /**< The DTMF tone for key 9: 1477Hz, 852Hz */
+       DTMF_PRESET_A,              /**< The DTMF tone for key A: 1633Hz, 697Hz */
+       DTMF_PRESET_B,              /**< The DTMF tone for key B: 1633Hz, 770Hz */
+       DTMF_PRESET_C,              /**< The DTMF tone for key C: 1633Hz, 852Hz */
+       DTMF_PRESET_D,              /**< The DTMF tone for key D: 1633Hz, 941Hz */
+       DTMF_PRESET_P,              /**< The DTMF tone for key #: 1477Hz, 941Hz */
+       DTMF_PRESET_S,              /**< The DTMF tone for key *: 1209Hz, 941Hz */
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaVideoDecoder.h b/inc/FMediaVideoDecoder.h
new file mode 100644 (file)
index 0000000..eae9e6e
--- /dev/null
@@ -0,0 +1,317 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FMediaVideoDecoder.h
+ * @brief      This is the header file for the %VideoDecoder class.
+ *
+ * This header file contains the declarations of the %VideoDecoder class.
+ */
+
+#ifndef _FMEDIA_VIDEO_DECODER_H_
+#define _FMEDIA_VIDEO_DECODER_H_
+
+#include <FBase.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class VideoDecoder
+ * @brief This class decodes a compressed video stream into a raw video data.
+ *
+ * @since              2.0
+ *
+ * The %VideoDecoder class decodes a compressed video stream into a raw video data.
+ * The video decoding formats, such as CODEC_H263, CODEC_MPEG4, and CODEC_H264 are supported.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm">Encoding and Decoding Video</a>.
+ *
+ * The following example demonstrates how to use the %VideoDecoder class in H.264 decoding.
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FIo.h>
+ * #include <FApp.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Io;
+ * using namespace Tizen::Media;
+ *
+ * result
+ * VideoDecoderSample(void)
+ * {
+ *      VideoDecoder dec;
+ *      result r;
+ *      ByteBuffer srcBuf, dstBuf;
+ *      File srcFile;
+ *      bool gotFrame;
+ *      int width, height;
+ *      MediaPixelFormat pixelFormat;
+ *      String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.h264";
+ *      FileAttributes attr;
+ *
+ *      // Loads data from src file
+ *      File::GetAttributes(filePath, attr);
+ *      srcBuf.Construct(attr.GetFileSize());
+ *      srcFile.Construct(filePath, "rb");
+ *      srcFile.Read(srcBuf);
+ *      srcBuf.Flip();  // Sets the position of source buffer to zero
+ *
+ *      dec.Construct(CODEC_H264);
+ *      r = dec.Probe(srcBuf, width, height, pixelFormat);
+ *      if (IsFailed(r) || (pixelFormat != MEDIA_PIXEL_FORMAT_YUV420P))
+ *      {
+ *              return E_INVALID_DATA;
+ *      }
+ *
+ *      dstBuf.Construct(width * height * 3 / 2);
+ *
+ *      while (srcBuf.GetRemaining() > 0)
+ *      {
+ *              gotFrame = false;
+ *              r = dec.Decode(srcBuf, dstBuf, gotFrame);
+ *              if (IsFailed(r))
+ *              {
+ *                      return r;
+ *              }
+ *
+ *              if (gotFrame)
+ *              {
+ *                      // Adds code handling decoded frame
+ *              }
+ *              dstBuf.Clear();
+ *      }
+ *
+ *      return E_SUCCESS;
+ * }
+ *
+ * @endcode
+ *
+ *
+ */
+class _OSP_EXPORT_ VideoDecoder
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        *      The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        *      @since          2.0
+        *
+        *      @remarks        After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        *      @see            Construct()
+        */
+       VideoDecoder(void);
+
+       /**
+        *      This destructor overrides Tizen::Base::Object::~Object().
+        *
+        *      @since          2.0
+        */
+       virtual ~VideoDecoder(void);
+
+       /**
+        *      Initializes this instance of %VideoDecoder with the specified parameters.
+        *
+        *      @since          2.0
+        *
+        *      @return         An error code
+        *      @param[in]      type                            The codec type
+        *      @param[in]      pOption                         The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm#decoding_video">optional parameters</a>
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_UNSUPPORTED_CODEC The specified decoder is not supported.
+        *      @exception      E_OUT_OF_RANGE          A specified input parameter has a value that is out of range.
+        *      @exception      E_OUT_OF_MEMORY         The memory is insufficient. 
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        *      @remarks        The key type of the specified option is Tizen::Base::Integer and the value type varies depending on the key type.
+        */
+       result Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption = null);
+
+public:
+       /**
+        *      Probes whether the video data can be decoded and sets the width, height, and pixel format of the video data.
+        *
+        *      @since          2.0
+        *
+        *      @return  An error code
+        *      @param[in]      srcBuf                                  The source buffer that stores the compressed video data
+        *      @param[out]     width                                   The width of the decoded video frame
+        *      @param[out]     height                                  The height of the decoded video frame
+        *      @param[out]     pixelFormat                             The pixel format of the decoded video frame
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_ARG                   The specified @c srcBuf is invalid.
+        *      @exception      E_UNSUPPORTED_FORMAT    The input data is not in a supported format.
+        *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
+        *      @exception  E_SYSTEM                            A system error has occurred.
+        *      @remarks        This method resets the internal state of the video decoder.
+        */
+       result Probe(const Tizen::Base::ByteBuffer& srcBuf, int& width, int& height, MediaPixelFormat& pixelFormat);
+
+
+       /**
+        *      Decodes the video data from the source buffer and stores the decoded data into the destination buffer.
+        *
+        *      @since          2.0
+        *
+        *      @return  An error code
+        *      @param[in]      srcBuf                                  The source buffer that stores the compressed video data
+        *      @param[out]     dstBuf                                  The destination buffer that stores the decoded video data
+        *      @param[out]     gotFrame                            @c true when a frame is decoded, @n
+        *                                                                          else @c false
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_ARG                   The specified @c srcBuf or @c dstBuf is invalid.
+        *      @exception      E_UNSUPPORTED_FORMAT    The input data is not in a supported format.
+        *      @exception      E_OUT_OF_MEMORY                 The destination buffer has insufficient memory.
+        *  @exception    E_DIMENSION_CHANGED           The dimension of video stream has changed.
+        *      @exception  E_SYSTEM                            A system error has occurred.
+        *      @remarks        The destination buffer must have sufficient free space to store the decoded frame data.
+        *      @remarks        The decoder starts the decoding of the frame from the current position of the source buffer,
+        *                              and moves the position of the source buffer to the end of the consumed data.
+        *                              The decoder also fills the destination buffer with the decoded frame from the current position of the destination buffer,
+        *                              and moves the position of the destination buffer to the end of the decoded frame.
+        *  @remarks    When the first decoding begins, the @c E_DIMENSION_CHANGED exception can occur.
+        *                        An exception can also occur when the dimension of the video frame in the bitstream has changed.
+        *                        An application should increase the size of @c dstBuf if the @c dstBuf cannot hold the video frame with new dimensions.
+        *                        The video frame can be received even if the result is @c E_DIMENSION_CHANGED.
+        *                        The application should check the @c position of the destination buffer and the value of @c gotFrame
+        *                        when the result is @c E_DIMENSION_CHANGED.
+        * @remarks     The H.264 video decoder returns data with the width and height in multiples of 16.
+        *                              The application should detect the width and height of the frame and crop the decoder's output data if the original dimension is not a multiple of @c 16.
+        *      @see Probe()
+        */
+       result Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf, bool& gotFrame);
+
+       /**
+        *      Resets the internal state of the video decoder to process a new video stream.
+        *
+        *      @since          2.0
+        *
+        *      @return         An error code
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        */
+       result Reset(void);
+
+
+       /**
+        *      Gets the specified property value of this instance.
+        *
+        *      @since          2.0
+        *
+        *      @return          An error code
+        *      @param[in]              key                                     The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm#decoding_video">key</a> whose value is required
+        *      @param[out]             value                           The obtained property value
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_STATE             This instance is in an invalid state for this method.
+        *      @exception      E_OBJ_NOT_FOUND             The specified @c key is not found.
+        *      @exception      E_INVALID_ARG                   The specified @c key is not supported.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @remarks        The property whose value is of type enum can be obtained by using this method.
+        */
+       result GetValue(MediaPropertyType key, int& value) const;
+
+
+       /**
+        *      Gets the specified property value of this instance.
+        *
+        *      @since          2.0
+        *
+        *      @return          An error code
+        *      @param[in]              key                                     The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm#decoding_video">key</a> whose value is required
+        *      @param[out]             value                           The obtained property value
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_STATE                  This instance is in an invalid state for this method.
+        *      @exception      E_OBJ_NOT_FOUND         The specified @c key is not found.
+        *      @exception      E_INVALID_ARG                   The specified @c key is not supported.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @remarks        The property whose value is of type enum can be obtained using this method.
+        */
+       result GetValue(MediaPropertyType key, float& value) const;
+
+       /**
+        *      Gets the supported properties of this instance.
+        *
+        *      @since          2.0
+        *
+        *      @return  A list of supported properties, @n
+        *                              else @c null if no property is supported or if an exception occurs
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_OUT_OF_MEMORY          The memory is insufficient.
+        *      @exception      E_OBJ_NOT_FOUND                 This instance does not support any property.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @remarks        The specific error code can be accessed using the GetLastResult() method.
+        *      @remarks        The return value must be deleted.
+        */
+       Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       /**
+        *      Checks whether the specified property is supported.
+        *
+        *      @since          2.0
+        *
+        *      @return  @c true if the property is supported, @n
+        *                              else @c false
+        *      @param[in]      key                                     The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm#decoding_video">key</a> whose value is required
+        *      @exception      E_SUCCESS                  The method is successful.
+        *      @exception      E_OBJ_NOT_FOUND         The specified @c key is not found.
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        *      @remarks        The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool IsPropertySupported(MediaPropertyType key) const;
+
+       /**
+        * Gets a list of the supported codecs.
+        *
+        * @since               2.0
+        * @return     A list of the codecs supported by the %VideoDecoder class, @n
+        *             else @c null if an exception occurs
+        * @exception  E_SUCCESS             The method is successful.
+        * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+        * @remarks    The specific error code can be accessed using the GetLastResult() method.
+        * @remarks    The return value must be deleted by the caller.
+        */
+       static Tizen::Base::Collection::IListT<CodecType>* GetSupportedCodecListN(void);
+
+
+private:
+       /**
+       *       The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       *
+       *       @since          2.0
+       *
+       */
+       VideoDecoder(const VideoDecoder& dec);
+       /**
+       *       The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       *
+       *       @since          2.0
+       *
+       */
+       VideoDecoder& operator =(const VideoDecoder& dec);
+
+       friend class _VideoDecoderImpl;
+       class _VideoDecoderImpl* __pImpl;
+};
+
+}} // Tizen::Media
+
+
+#endif
diff --git a/inc/FMediaVideoEncoder.h b/inc/FMediaVideoEncoder.h
new file mode 100644 (file)
index 0000000..8464e79
--- /dev/null
@@ -0,0 +1,287 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *     @file   FMediaVideoEncoder.h
+ *     @brief  This is the header file for the %VideoEncoder class.
+ *
+ *     This header file contains the declarations of the %VideoEncoder class.
+ */
+
+#ifndef _FMEDIA_VIDEO_ENCODER_H_
+#define _FMEDIA_VIDEO_ENCODER_H_
+
+#include <FBase.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class VideoEncoder
+ * @brief This class encodes a raw video stream into a compressed video data.
+ *
+ * @since              2.0
+ *
+ * The %VideoEncoder class encodes a raw video stream into a compressed video data. The video encoders such as H.263, MPEG4 Part 2 are supported.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm">Encoding and Decoding Video</a>.
+ *
+ * The following example demonstrates how to use the %VideoEncoder class in H.263 encoding.
+ * @code
+ *
+ * #include <FBase.h>
+ * #include <FIo.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Io;
+ * using namespace Tizen::Media;
+ *
+ * result
+ * VideoEncoderSample(void)
+ * {
+ *      VideoEncoder enc;
+ *      result r;
+ *      ByteBuffer srcBuf, dstBuf;
+ *      int width = 352;
+ *      int height = 288;
+ *      int bitRate = 512000; // 512 Kbps
+ *      int frameRate = 15;
+ *      MediaPixelFormat pixelFormat = MEDIA_PIXEL_FORMAT_YUV420P;
+ *      HashMap option;
+ *      byte* pBuf = null;
+ *      int srcBufSize = width * height * 3 / 2;
+ *
+ *      option.Construct();
+ *      option.Add(*(new Integer(MEDIA_PROPERTY_VIDEO_WIDTH)), *(new Integer(width)));
+ *      option.Add(*(new Integer(MEDIA_PROPERTY_VIDEO_HEIGHT)), *(new Integer(height)));
+ *      option.Add(*(new Integer(MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT)), *(new Integer(pixelFormat)));
+ *      option.Add(*(new Integer(MEDIA_PROPERTY_VIDEO_FRAME_RATE)), *(new Integer(frameRate)));
+ *      option.Add(*(new Integer(MEDIA_PROPERTY_VIDEO_BIT_RATE)), *(new Integer(bitRate)));
+ *
+ *      pBuf = new byte[srcBufSize];
+ *      srcBuf.Construct(pBuf, 0, srcBufSize, srcBufSize);
+ *      dstBuf.Construct(width * height * 3 / 2);
+ *
+ *      enc.Construct(CODEC_H263, &option);
+ *
+ *      for (int i = 0; i < 255; i += 25)
+ *      {
+ *              // Fills source buffer with a gray color
+ *              memset(pBuf, i, width * height);                                          // Y
+ *              memset(pBuf + width * height, 128, width * height / 4);          // Cb
+ *              memset(pBuf + width * height * 5 / 4, 128, width * height / 4);  // Cr
+ *
+ *              srcBuf.SetPosition(0);
+ *              srcBuf.SetLimit(srcBufSize);
+ *
+ *              r = enc.Encode(srcBuf, dstBuf);
+ *              if (IsFailed(r))
+ *              {
+ *                      break;
+ *              }
+ *
+ *              // Adds code handling encoded data
+ *
+ *              dstBuf.Clear();
+ *      }
+ *
+ *      delete pBuf;
+ *      return r;
+ * }
+ *
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ VideoEncoder
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        *      The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+        *
+        *      @since          2.0
+        *
+        *      @remarks                 After creating an instance of this class, the Construct() method must be
+        *                                       called explicitly to initialize this instance.
+        *      @see            Construct()
+        */
+       VideoEncoder(void);
+
+       /**
+        *      This destructor overrides Tizen::Base::Object::~Object().
+        *
+        *      @since          2.0
+        */
+       virtual ~VideoEncoder(void);
+
+       /**
+        *      Initializes an instance of %VideoEncoder with the specified parameters.
+        *
+        *      @since          2.0
+        *
+        *      @return         An error code
+        *      @param[in]      type                            The codec type
+        *      @param[in]      pOption                         The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm#encoding_video">optional parameters</a>
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_UNSUPPORTED_CODEC The specified encoder is not supported.
+        *      @exception      E_INVALID_ARG           A specified input parameter has invalid data.
+        *      @exception      E_OUT_OF_MEMORY         The memory is insufficient. 
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        *      @remarks        The key type of the specified option is Tizen::Base::Integer and the value type varies depending
+        *                        on the key type.
+        *                              The unsupported keys in @c pOption are ignored.
+        *                              If specified @c pOption has an invalid value, @c E_INVALID_ARG is returned.
+        *  @remarks The supported codec types can vary depending on the device model or platform version.
+        */
+       result Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption = null);
+
+public:
+       /**
+        *      Encodes the video data from the source buffer and stores the encoded data in the destination buffer.
+        *
+        *      @since          2.0
+        *
+        *      @return  An error code
+        *      @param[in]      srcBuf                                  The source buffer that stores the raw video data
+        *      @param[out]     dstBuf                                  The destination buffer that stores the encoded video data
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_ARG                   The specified source or destination buffer is invalid or has insufficient memory.
+        *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @remarks        The destination buffer must have sufficient free space to store the encoded frame data.
+        *      @remarks        The position of the source buffer is moved to the end of the consumed data and the position of the destination buffer is moved to the end of the written data.
+        */
+       result Encode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf);
+
+       /**
+        *      Resets the internal state of the video encoder to process a new video stream.
+
+        *      @since          2.0
+        *
+        *      @return         An error code
+        *      @exception      E_SUCCESS                       The method is successful.
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        *      @remarks        This method resets the properties that were set after the execution of the Construct() method.
+        */
+       result Reset(void);
+
+       /**
+        *      Sets the specified property value of this instance.
+        *
+        *      @since          2.0
+        *
+        *      @return          An error code
+        *      @param[in]              key                                     The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm#encoding_video">key</a> value to set
+        *      @param[in]              value                           The property value to set
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_STATE          This instance is in an invalid state for this method.
+        *      @exception      E_OBJ_NOT_FOUND                 The specified @c key is not found.
+        *      @exception      E_INVALID_ARG                   A specified input parameter is invalid.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @remarks        The media property that has the value of type enum can be set using this method.
+        */
+       result SetValue(MediaPropertyType key, int value);
+
+       /**
+        *      Sets the specified property value of this instance.
+        *
+        *      @since          2.0
+        *
+        *      @return          An error code
+        *      @param[in]              key                                     The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm#encoding_video">key</a> value to set
+        *      @param[in]              value                           The property value to set
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_STATE          This instance is in an invalid state for this method.
+        *      @exception      E_OBJ_NOT_FOUND                 The specified @c key is not found.
+        *      @exception      E_INVALID_ARG                   A specified input parameter is invalid.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @remarks        The media property that has the value of type enum can be set using this method.
+        */
+       result SetValue(MediaPropertyType key, bool value);
+
+       /**
+        *      Gets the properties supported by this instance.
+        *
+        *      @since          2.0
+        *
+        *      @return  A list of the supported properties, @n
+        *                              else @c null if no property is supported or if an exception occurs
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_OUT_OF_MEMORY          The memory is insufficient.
+        *      @exception      E_SYSTEM                                A system error has occurred.
+        *      @exception      E_OBJ_NOT_FOUND                 This instance does not support any property.
+        *      @remarks        The specific error code can be accessed using the GetLastResult() method.
+        *                              The returned value must be deleted.
+        */
+       Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       /**
+        *      Checks whether the specified property is supported.
+        *
+        *      @since          2.0
+        *
+        *      @return  @c true if the property is supported, @n
+        *                              else @c false
+        *      @param[in]      key                                     The <a href="../org.tizen.native.appprogramming/html/guide/media/encoding_decoding_video.htm#encoding_video">key</a> value
+        *      @exception      E_SUCCESS                  The method is successful.
+        *      @exception      E_OBJ_NOT_FOUND         The specified @c key is not found.
+        *      @exception      E_SYSTEM                        A system error has occurred.
+        *      @remarks        The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool IsPropertySupported(MediaPropertyType key) const;
+
+       /**
+        * Gets a list of the supported codecs.
+        *
+        * @since               2.0
+        *
+        * @return     A list of the codecs supported by the %VideoEncoder class, @n
+        *             else @c null if an exception occurs
+        * @exception  E_SUCCESS             The method is successful.
+        * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+        * @remarks    The specific error code can be accessed using the GetLastResult() method.
+        * @remarks    The return value must be deleted by the caller.
+        */
+       static Tizen::Base::Collection::IListT<CodecType>* GetSupportedCodecListN(void);
+
+private:
+       /**
+        *      The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        *      @since          2.0
+        *
+        */
+       VideoEncoder(const VideoEncoder& enc);
+
+       /**
+        *      The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        *      @since          2.0
+        *
+        */
+       VideoEncoder& operator =(const VideoEncoder& enc);
+
+       friend class _VideoEncoderImpl;
+       class _VideoEncoderImpl* __pImpl;
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/inc/FMediaVideoFrameExtractor.h b/inc/FMediaVideoFrameExtractor.h
new file mode 100644 (file)
index 0000000..199ea3b
--- /dev/null
@@ -0,0 +1,200 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMediaVideoFrameExtractor.h
+ * @brief  This is the header file for the %VideoFrameExtractor class.
+ *
+ * This header file contains the declarations of the %VideoFrameExtractor class.
+ */
+
+#ifndef _FMEDIA_VIDEO_FRAME_EXTRACTOR_H_
+#define _FMEDIA_VIDEO_FRAME_EXTRACTOR_H_
+
+#include <FBaseObject.h>
+#include <FMediaImageBuffer.h>
+
+namespace Tizen { namespace Media {
+
+/**
+ * @class  VideoFrameExtractor
+ * @brief  This class is used to extract video frame from video file.
+ *
+ * @since              2.0
+ *
+ * The %VideoFrameExtractor class is used to extract video frame from video file.
+ *
+ * The following example demonstrates how to use the %VideoFrameExtractor class to extract video frame from video file.
+ *
+ * @code
+ * #include <FMedia.h>
+ * #include <FApp.h>
+ * #include <FGraphics.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Media;
+ * using namespace Tizen::Graphics;
+ *
+ *  result
+
+ * TestVideoFrameExtractor(void)
+ * {
+ *    VideoFrameExtractor extractor;
+ *    String path = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp4";
+ *    result r = extractor.Construct(path, MEDIA_PIXEL_FORMAT_BGRA8888);
+ *    long duration = extractor.GetDuration();
+ *
+ *    // Extracts video frames from the video file
+
+ *    for (int i = 0; i < 10; i++)
+ *    {
+ *        ImageBuffer* pImage = extractor.GetFrameN(duration*i/10);
+ *
+ *        // Adds some codes that handles extracted video frame
+ *
+ *        delete pImage;
+ *    }
+ *    return E_SUCCESS;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ VideoFrameExtractor
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @see    Construct()
+        */
+       VideoFrameExtractor(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.0
+        *
+        * @see    Construct()
+        */
+       virtual ~VideoFrameExtractor(void);
+
+       /**
+        * Initializes this instance of %VideoFrameExtractor with the specified parameters.
+        *
+        * @since               2.0
+        *
+        * @return     An error code
+        * @param[in]  filePath              The video file path
+        * @param[in]  pixelFormat           The pixel format of output image data.
+        * @exception  E_SUCCESS             The method is successful.
+        * @exception  E_INVALID_ARG         A specified input parameter is invalid.
+        * @exception  E_UNSUPPORTED_FORMAT  The specified format is not supported.
+        * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+        * @exception  E_FILE_NOT_FOUND      The specified file cannot be found or accessed.
+        */
+       result Construct(const Tizen::Base::String &filePath, MediaPixelFormat pixelFormat);
+
+       /**
+        * Gets the width of the video frame.
+        *
+        * @since               2.0
+        *
+        * @return  The width of video frame
+        */
+       int GetWidth(void) const;
+
+       /**
+        * Gets the height of the video frame.
+        *
+        * @since               2.0
+        *
+        * @return  The height of the video frame
+        */
+       int GetHeight(void) const;
+
+       /**
+        * Gets the duration of the video in millisecond.
+        *
+        * @since               2.0
+        *
+        * @return  The duration of the video in millisecond
+        */
+       long GetDuration(void) const;
+
+       /**
+        * Extract video frame at the specified position.
+        *
+        * @since               2.0
+        *
+        * @return     A pointer to the ImageBuffer containing extracted video frame.
+        * @param[in]  timestamp             The timestamp of video frame to extract
+        * @exception  E_SUCCESS             The method is successful.
+        * @exception  E_OUT_OF_RANGE        The specified @c timestamp is out of range.
+        * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+        * @exception  E_OPERATION_FAILED    Video frame at given position is not found or extraction is failed.
+        * @exception  E_UNSUPPORTED_FORMAT  The specified pixel format is not supported.
+        * @remarks    The specific error code can be accessed using the GetLastResult() method.
+        * @remarks    The extracted frame may not be exact frame of given timestamp,
+        *             so that the same frame can be returned even if the timestamp is different.
+        * @remarks    Frames near the end of contents may not be extracted if no key-frame is found after timestamp.
+        */
+       ImageBuffer* GetFrameN(long timestamp);
+
+       /**
+        * Extract video thumbnail from the specified position.
+        *
+        * @since               2.0
+        *
+        * @return     A pointer to the ImageBuffer containing the extracted video frame.
+        * @param[in]  path                  The video file path
+        * @param[in]  timestamp             The timestamp of video frame that want to extract
+        * @param[in]  pixelFormat           The pixel format of output image data.
+        * @exception  E_SUCCESS             The method is successful.
+        * @exception  E_INVALID_ARG         A specified input parameter is invalid.
+        * @exception  E_OUT_OF_RANGE        The specified @c timestamp is out of range.
+        * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+        * @exception  E_OPERATION_FAILED    Video frame at given position is not found or extraction is failed.
+        * @exception  E_UNSUPPORTED_FORMAT  The specified pixel format is not supported.
+        * @remarks    The specific error code can be accessed using the GetLastResult() method.
+        * @remarks    The extracted frame may not be exact frame of given timestamp,
+        *             so that the same frame can be returned even if the timestamp is different.
+        * @remarks    Frames near the end of contents may not be extracted if no key-frame is found after timestamp.
+        */
+       static ImageBuffer* GetFrameN(const Tizen::Base::String& path, MediaPixelFormat pixelFormat, long timestamp);
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        */
+       VideoFrameExtractor(const VideoFrameExtractor& rhs);
+
+       /**
+        * This is the assignment operator.
+        */
+       VideoFrameExtractor& operator =(const VideoFrameExtractor& rhs);
+
+private:
+       friend class _VideoFrameExtractorImpl;
+       class _VideoFrameExtractorImpl* __pImpl;
+};
+
+}} // Tizen::Media
+
+#endif // _FMEDIA_VIDEO_FRAME_EXTRACTOR_H_
+
diff --git a/inc/FMediaVideoRecorder.h b/inc/FMediaVideoRecorder.h
new file mode 100755 (executable)
index 0000000..b2bea15
--- /dev/null
@@ -0,0 +1,844 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaVideoRecorder.h
+ * @brief                      This is the header file for the %VideoRecorder class.
+ *
+ * This header file contains the declarations of the %VideoRecorder class.
+ */
+
+#ifndef _FMEDIA_VIDEO_RECORDER_H_
+#define _FMEDIA_VIDEO_RECORDER_H_
+
+#include <FMediaVideoRecorderTypes.h>
+#include <FMediaIVideoRecorderEventListener.h>
+#include <FMediaCamera.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+class _VideoRecorderImpl;
+
+/**
+ * @class      VideoRecorder
+ * @brief      This class records a video.
+ *
+ * @since              2.0
+ *
+ * The %VideoRecorder class provides video recording from the camera device. All the input sources must be
+ * controlled independently from the video recording operation. The supported codecs and resolutions are
+ * device-dependent and the available list can be retrieved using the methods available in this class.
+ * The recording operation is limited by the maximum time or size.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/recording_video.htm">Recording Video</a>.
+ *
+ * The following example demonstrates how to use the %VideoRecorder class.
+ *
+ * @code
+ * #include <FBase.h>
+ * #include <FGraphics.h>
+ * #include <FUi.h>
+ * #include <FApp.h>
+ * #include <FMedia.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Graphics;
+ * using namespace Tizen::Ui;
+ * using namespace Tizen::Ui::Controls;
+ * using namespace Tizen::Media;
+ *
+ * class VideoRecorderSample
+ *     : public Tizen::Ui::Controls::Form
+ *     , public Tizen::Media::ICameraEventListener
+ *     , public Tizen::Media::IVideoRecorderEventListener
+ * {
+ * public:
+ *     VideoRecorderSample(void);
+ *     result Start(void);
+ *     void Stop(void);
+ *
+ * protected:
+ *     // ICameraEventListener
+ *     virtual void OnCameraAutoFocused(bool completeCondition) {}
+ *     virtual void OnCameraCaptured(Tizen::Base::ByteBuffer &capturedData, result r) {}
+ *     virtual void OnCameraErrorOccurred(CameraErrorReason err) {}
+ *     virtual void OnCameraPreviewed(Tizen::Base::ByteBuffer &previewedData, result r) {}
+ *
+ *     // IVideoRecorderEventListener
+ *     virtual void OnVideoRecorderCanceled(result r) {}
+ *     virtual void OnVideoRecorderClosed(result r) {}
+ *     virtual void OnVideoRecorderEndReached(RecordingEndCondition endCondition) {}
+ *     virtual void OnVideoRecorderErrorOccurred( RecorderErrorReason r) {}
+ *     virtual void OnVideoRecorderPaused(result r) {}
+ *     virtual void OnVideoRecorderStarted(result r) {}
+ *     virtual void OnVideoRecorderStopped(result r) {}
+ *
+ * private:
+ *     Camera __camera;
+ *     VideoRecorder __recorder;
+ *     OverlayRegion *__pOverlay;
+ * };
+ *
+ *
+ * VideoRecorderSample::VideoRecorderSample(void)
+ * {
+ *     __pOverlay = null;
+ * }
+ *
+ * result
+ * VideoRecorderSample::Start(void)
+ * {
+ *     result r = E_SUCCESS;
+ *     Tizen::Graphics::Rectangle rect(0, 0, 320, 240);
+ *     BufferInfo bufferInfo;
+ *     String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp4";
+ *
+ *     __pOverlay = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_PRIMARY_CAMERA);
+ *     if (__pOverlay == null)
+ *     {
+ *         return GetLastResult();
+ *     }
+ *
+ *      __pOverlay->GetBackgroundBufferInfo(bufferInfo);
+ *
+ *      r = __camera.Construct(*this);
+ *      if (IsFailed(r))
+ *     {
+ *          goto CATCH;
+ *     }
+ *
+ *      r = __camera.PowerOn();
+ *      if (IsFailed(r))
+ *     {
+ *          goto CATCH;
+ *     }
+ *
+ *      r = __recorder.Construct(*this, __camera);
+ *      if (IsFailed(r))
+ *     {
+ *          goto CATCH;
+ *     }
+ *
+ *      r = __camera.StartPreview(&bufferInfo, false);
+ *      if (IsFailed(r))
+ *     {
+ *          goto CATCH;
+ *     }
+ *
+ *      r = __recorder.CreateVideoFile(filePath, true);
+ *      if (IsFailed(r))
+ *     {
+ *          goto CATCH;
+ *     }
+ *
+ *      r = __recorder.Record();
+ *      if (IsFailed(r))
+ *     {
+ *          goto CATCH;
+ *     }
+ *
+ *      return E_SUCCESS;
+ *
+ * CATCH:
+ *      if (__pOverlay)
+ *      {
+ *          delete __pOverlay;
+ *          __pOverlay = null;
+ *      }
+ *      return r;
+ * }
+ *
+ * void
+ * VideoRecorderSample::Stop(void)
+ * {
+ *     __recorder.Stop();
+ *     __camera.StopPreview();
+ *     __camera.PowerOff();
+ *     if (__pOverlay)
+ *     {
+ *         delete __pOverlay;
+ *         __pOverlay = null;
+ *     }
+ * }
+ *
+ *
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ VideoRecorder
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks     The object is not fully constructed after this constructor is called. For full construction,
+        * the Construct() method must be called right after calling this constructor.
+        */
+       VideoRecorder(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method must be called in the same thread in
+        * which the Construct() method is called.This polymorphic destructor should be overridden if required. This way,
+        * the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since               2.0
+        *
+        */
+       virtual ~VideoRecorder(void);
+
+       /**
+       * Initializes this instance of %VideoRecorder with an associated listener and an input source.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[in]    listener                        An event listener object
+       * @param[in]    camera                          A Camera object for the input source
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY The memory is insufficient.
+       * @exception    E_DEVICE_BUSY           The recorder is under use by other application or already used in this application.
+       * @exception    E_UNSUPPORTED_OPERATION This video recorder usage is not supported.
+       */
+       result Construct(IVideoRecorderEventListener& listener, const Camera& camera);
+
+       /**
+       * Creates a video file for a recording.
+       *
+       * @if OSPCOMPAT
+       * @brief <i> [Compatibility] </i>
+       * @endif
+       * @since                2.0
+       * @if OSPCOMPAT
+       * @compatibility        This method has compatibility issues with OSP compatible applications. @n
+       *                                       For more information, see @ref CompIoPathPage "here".
+       * @endif
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    destMediaPath                           The destination for the file that is written @n
+       *                                                                               The available paths start with prefixes retrieved from the functions such as: @n
+       *                                                                                       Tizen::App::App::GetInstance()->GetAppRootPath() @n
+       *                                                                                       Tizen::System::Environment::GetMediaPath() @n
+       *                                                                                       Tizen::System::Environment::GetExternalStoragePath()
+       * @param[in]    overwrite                       Set to @c true to overwrite the file, @n
+       *                                                                                       else @c false
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_RESOURCE_UNAVAILABLE          The required file path is unavailable.
+       * @exception    E_FILE_ALREADY_EXIST            The specified file already exists.
+       * @exception    E_STORAGE_FULL                          The storage is full.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The application can register newly created files into the Contents database using Tizen::Content::ContentManager::CreateContent().
+       * @see          Close()
+       */
+       result CreateVideoFile(const Tizen::Base::String& destMediaPath, bool overwrite);
+
+       /**
+       * Closes the video file. @n
+       * This is a synchronous method.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  CreateVideoFile()
+       */
+       result Close(void);
+
+       /**
+       * Records the video file. @n
+       * Resumes the recording if Pause() has been called.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The recorder is under use by other application.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks      This method must be called after the input media source is started (for example, Camera::StartPreview()).
+       * @see                  Stop()
+       */
+       result Record(void);
+
+       /**
+       * Stops the recording.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  Record()
+       * @see                  Pause()
+       */
+       result Stop(void);
+
+       /**
+       * Pauses the recording. @n
+       * To resume the recording after the %Pause() method is called, Record() must be called.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED          The application does not have the privilege to call this method.
+       * @see                  Stop()
+       */
+       result Pause(void);
+
+       /**
+       * Cancels the recording operation without saving the data.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              When this method is called, the state is changed to ::RECORDER_STATE_STOPPING. @n
+       *                               After IVideoRecorderEventListener::OnVideoRecorderCanceled() is called, the state is changed to
+       *                               @c RECORDER_STATE_STOPPED.
+       * @see                  Record()
+       * @see                  Stop()
+       */
+       result Cancel(void);
+
+       /**
+       * Gets the state of a recorder.
+       *
+       * @since                2.0
+       *
+       * @return               The current state of the video recorder
+       * @see                  CreateVideoFile()
+       * @see                  Close()
+       * @see                  Record()
+       * @see                  Stop()
+       * @see                  Pause()
+       * @see                  RecorderState
+       */
+       RecorderState GetState(void) const;
+
+       /**
+       * Gets the current recording time.
+       *
+       * @since                2.0
+       *
+       * @return               The current recording time in milliseconds, @n
+       *                               else @c -1 if the recording has not started as yet
+       */
+       long GetRecordingTime(void) const;
+
+       /**
+       * Gets the current recording size.
+       *
+       * @since                2.0
+       *
+       * @return               A @c long value indicating the current recording size in bytes, @n
+       *                               else @c -1 if the recording has not started as yet
+       */
+       long GetRecordingSize(void) const;
+
+       /**
+       * Sets the time limit for the recording in milliseconds.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    msTime                          The maximum recording time in milliseconds @n
+       *                                                                       The time must be greater than @c 0.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE          The specified time is out of range.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks              The default time is @c 60 seconds.
+       * @see                  GetMaxRecordingTime()
+       */
+       result SetMaxRecordingTime(long msTime);
+
+       /**
+       * Gets the time limit of the recording in milliseconds.
+       *
+       * @since                2.0
+       *
+       * @return               A @c long value indicating the maximum recording time in milliseconds, @n
+       *                               else @c -1 if the recording has not started as yet
+       * @see                  SetMaxRecordingTime()
+       */
+       long GetMaxRecordingTime(void) const;
+
+       /**
+       * @if OSPDEPREC
+       * Sets the codec for the recorder. @n
+       * Initially, the default codec from the internal configuration is set.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+       * Instead of using this method, use the SetFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container) method that
+       * sets the audio/video codec and container together.
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    codec                                   The codec name @n
+       *                                                                               It must be one of the strings listed by GetSupportedCodecListN(). @n
+       *                                                                               GetSupportedCodecListN() returns the list of strings in the following formats: @n
+       *                                                                               - "VIDEO_CODEC_H263" @n
+       *                                                                               - "VIDEO_CODEC_MPEG4SP" @n
+       *                                                                               The returned strings are different depending on each device. @n
+       *                                                                               The following string is always operated upon. This value is different
+       *                                                                               for each device. @n
+       *                                                                               "VIDEO_CODEC_DEFAULT": the default codec
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  GetCodec()
+       * @endif
+       */
+       result SetCodec(const Tizen::Base::String& codec);
+
+       /**
+       * @if OSPDEPREC
+       * Gets the codec for the recorder.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+           * Instead of using this method, use the GetFormat(CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const
+       * method that gets the audio/video codec and container together.
+       * @since                2.0
+       *
+       * @return               The current codec
+       * @see                  SetCodec()
+       * @see                  GetSupportedCodecListN()
+       * @endif
+       */
+       Tizen::Base::String GetCodec(void) const;
+
+       /**
+       * @if OSPDEPREC
+       * Gets the list of supported video recorder codecs. @n
+       * Each item in the list is a Tizen::Base::String value.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+       * Instead of using this method, use the GetSupportedAudioCodecListN() and GetSupportedVideoCodecListN() methods.
+       * @since                2.0
+       *
+       * @return       The list of strings that represents the supported video recorder codecs, @n
+       *                               else @c null if no codec is supported or if an exception occurs
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *               The return value must be released by the caller. @n
+       *               All items in the list must be released by the caller.
+       * @see                  SetCodec()
+       * @see                  GetCodec()
+       * @endif
+       */
+       Tizen::Base::Collection::IList* GetSupportedCodecListN(void) const;
+
+       /**
+       * Gets the list of supported audio codecs. @n
+       * Each item in the list has a ::CodecType value.
+       *
+       * @since                2.0
+       *
+       * @return       A list of supported audio codecs, @n
+       *                               else @c null if no codec is supported or if an exception occurs
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *               The return value must be released by the caller.
+       * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container )
+       * @see                  GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
+       */
+       Tizen::Base::Collection::IListT <CodecType>* GetSupportedAudioCodecListN(void) const;
+
+       /**
+       * Gets the list of supported video codecs. @n
+       * Each item in the list has a ::CodecType value.
+       *
+       * @since                2.0
+       *
+       * @return       A list of supported video codecs, @n
+       *                               else @c null if no codec is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *               The return value must be released by the caller.
+       * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container )
+       * @see                  GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
+       */
+       Tizen::Base::Collection::IListT <CodecType>* GetSupportedVideoCodecListN(void) const;
+
+       /**
+       * Gets the list of supported containers. @n
+       * Each item in the list has a ::MediaContainerType value.
+       *
+       * @since                2.0
+       *
+       * @return       A list of supported containers, @n
+       *                               else @c null if no container is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *               The return value must be released by the caller.
+       * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container )
+       * @see                  GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
+       */
+       Tizen::Base::Collection::IListT <MediaContainerType>* GetSupportedContainerListN(void) const;
+
+       /**
+       * @if OSPDEPREC
+       * Sets the video format of the recorder. @n
+       * Initially, the default format from internal configuration is set.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+       * Instead of using this method, use the SetFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container) method that sets
+       * the audio/video codec and container together.
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    format                                  The video format @n
+       *                                                                               ::VIDEORECORDING_FORMAT_DEFAULT sets the system's default recording format.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  GetFormat()
+       * @endif
+       */
+       result SetFormat(VideoRecordingFormat format);
+
+       /**
+       * @if OSPDEPREC
+       * Gets the current format that has been set for the recorder.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+       * Instead of using this method, use the GetFormat(CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const method
+       * that gets the audio/video codec and container together.
+       * @since                2.0
+       *
+       * @return               The current video format, @n
+       *               else the default format if SetFormat() is not called before this method
+       * @see                  SetFormat()
+       * @endif
+       */
+       VideoRecordingFormat GetFormat(void) const;
+
+       /**
+       * @if OSPDEPREC
+       * Sets the mode of the recorder.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+       * Instead of using this method, use the SetFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container) method that
+       * determines whether the video recorder includes the audio codec.
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    mode                            The mode for the recording @n
+       *                                                                       The default mode is ::VIDEORECORDER_MODE_VIDEO_WITH_AUDIO.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c mode is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @see                  GetMode()
+       * @endif
+       */
+       result SetMode(VideoRecorderMode mode);
+
+       /**
+       * @if OSPDEPREC
+       * Gets the mode of the recorder.
+       *
+       * @brief <i> [Deprecated]  </i>
+       * @deprecated   This method is deprecated. @n
+       * Instead of using this method, use the GetFormat(CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const
+       * method that determines whether the video recorder includes the audio codec.
+       * @since                2.0
+       *
+       * @return               The current mode
+       * @see                  SetMode()
+       * @endif
+       */
+       VideoRecorderMode GetMode(void) const;
+
+       /**
+       * Sets the audio and video codecs, and the container of the recorder. @n
+       * Initially, the default codec and container format are set with the internal configuration.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    audioCodec                              The audio codec to set @n
+       *                                                                               ::CODEC_NONE makes the audio stream empty.
+       * @param[in]    videoCodec                              The video codec to set @n
+       *                                                                               ::CODEC_NONE cannot be set.
+       * @param[in]    container                               The media container to set
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified container format is not supported.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              If the audio codec is ::CODEC_NONE, the audio will be ignored, and only the video stream will be recorded. @n
+       *                               If the specified container does not support the specified codec, @c E_UNSUPPORTED_FORMAT may be returned.
+       * @see                  GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
+       */
+       result SetFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container);
+
+       /**
+       * Gets the audio and video codecs, and the container of the recorder.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @param[out]   audioCodec                      The retrieved audio codec
+       * @param[out]   videoCodec                      The retrieved video codec
+       * @param[out]   container                       The retrieved container
+       * @exception    E_SUCCESS                       The method is successful.
+       * @remarks              The default codecs and container are retrieved, if SetFormat( CodecType audioCodec, CodecType
+       *                               videoCodec, MediaContainerType container) is not called before calling this method. @n
+       *                               This method always returns E_SUCCESS.
+       * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container )
+       */
+       result GetFormat(CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const;
+
+       /**
+       * Sets the quality of the recorder.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    quality                         The quality of the recorder @n
+       *                                                                       The default quality is ::RECORDING_QUALITY_MEDIUM.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c quality is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @see                  GetQuality()
+       */
+       result SetQuality(RecordingQuality quality);
+
+       /**
+       * Gets the quality of the recorder.
+       *
+       * @since                2.0
+       *
+       * @return               The current quality
+       * @see                  SetQuality()
+       */
+       RecordingQuality GetQuality(void) const;
+
+       /**
+       * Sets the recording resolution of the recorder. @n
+       * Initially, the default resolution from the internal configuration is set.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    resolution                      The recording resolution @n
+       *                                                                       It must be one of the listed strings extracted from
+       *                                                                       GetSupportedRecordingResolutionListN().
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE          The specified resolution is out of range.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks              If the input source is Tizen::Media::Camera, its preview resolution value must be same as that
+       *                               of this recording resolution.
+       * @see                  GetRecordingResolution()
+       */
+       result SetRecordingResolution(const Tizen::Graphics::Dimension& resolution);
+
+       /**
+       * Gets the recording resolution.
+       *
+       * @since                2.0
+       *
+       * @return               The recording resolution
+       * @see                  GetSupportedRecordingResolutionListN()
+       */
+       Tizen::Graphics::Dimension GetRecordingResolution(void) const;
+
+       /**
+       * Gets a list of the supported video recorder resolutions. @n
+       * Each list item is a Tizen::Graphics::Dimension value.
+       *
+       * @since                2.0
+       *
+       * @return               A list of strings representing the supported video recorder resolutions, @n
+       *                               else an empty list if no recording resolution is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be released by the calling method. @n
+       *                               All items in the list must be released by the calling method.
+       * @see                  SetRecordingResolution()
+       * @see                  GetRecordingResolution()
+       */
+       Tizen::Base::Collection::IList* GetSupportedRecordingResolutionListN(void) const;
+
+       /**
+       * Gets the maximum supported frame rate of the input resolution.
+       *
+       * @since                2.0
+       *
+       * @return               The maximum frame rate of the input recording resolution
+       * @param[in]    dim                                             The preview resolution of the source
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_ARG                   The specified input resolution is invalid.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult method.
+       * @see                  Camera::SetPreviewFrameRate()
+       */
+       int GetSupportedMaxFrameRate(const Tizen::Graphics::Dimension& dim) const;
+
+       /**
+       * Sets the mute state of a recorder.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    mute                Set to @c true to enable the mute state of the recorder, @n
+       *                                                                       else @c false
+       *                                   By default, the mute state is disabled.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks              The recording continues even in the mute state.
+       * @see                  IsMuted()
+       */
+       result SetMute(bool mute);
+
+       /**
+       * Checks whether the mute state of the recorder is enabled.
+       *
+       * @since                2.0
+       *
+       * @return               The mute state of the recorder
+       * @see                  SetMute()
+       */
+       bool IsMuted(void) const;
+
+       /**
+       * Sets the recording rotation of the recorder.
+       *
+       * @since                2.0
+       * @privilege    %http://tizen.org/privilege/videorecorder
+       *
+       * @return               An error code
+       * @param[in]    rotation                        The rotation of the recorder
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
+       * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks              This method add the rotation information to the video file.
+       *                     A video player can rotate the surface or the stream using this information to display correctly.
+       * @see                  GetRecordingRotation()
+       */
+       result SetRecordingRotation(RecordingRotation rotation);
+
+       /**
+       * Gets the rotation of the recorder.
+       *
+       * @since                2.0
+       *
+       * @return               The current recording rotation
+       * @see                  SetRecordingRotation()
+       */
+       RecordingRotation GetRecordingRotation(void) const;
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        * @see                 Construct()
+        */
+       VideoRecorder(const VideoRecorder& videoRecorder);
+       /**
+        * This is the copy assignment operator for this class.
+        *
+        * @since               2.0
+        *
+        * @remarks         The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        */
+       VideoRecorder& operator =(const VideoRecorder& videoRecorder);
+
+       friend class _VideoRecorderImpl;
+       _VideoRecorderImpl* __pImpl;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/inc/FMediaVideoRecorderTypes.h b/inc/FMediaVideoRecorderTypes.h
new file mode 100755 (executable)
index 0000000..fd06a60
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaVideoRecorderTypes.h
+ * @brief                      This is the header file for the video recording enumerations.
+ *
+ * This header file contains the declarations of the video recording enumerations.
+ */
+
+#ifndef _FMEDIA_VIDEO_RECORDER_TYPES_H_
+#define _FMEDIA_VIDEO_RECORDER_TYPES_H_
+
+#include "FMediaRecorderTypes.h"
+
+namespace Tizen { namespace Media
+{
+
+// 60 sec
+#define DEFAULT_VIDEORECORDING_TIME 60000
+
+// 1 Megabytes
+#define DEFAULT_VIDEORECORDING_SIZE 1024 * 1024
+
+/**
+ * @if OSPDEPREC
+ * @enum VideoRecordingFormat
+ *
+ * Defines the format of a video recorder.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This enum is deprecated because new methods do not use this enum. Instead of this enum, use
+ *                             ::MediaContainerType.
+ * @since              2.0
+ *
+ * @see                VideoRecorder::SetFormat()
+ * @see                VideoRecorder::GetFormat()
+ * @endif
+ */
+enum VideoRecordingFormat
+{
+       VIDEORECORDING_FORMAT_DEFAULT,                  /**< @if OSPDEPREC The default format @endif */
+       VIDEORECORDING_FORMAT_MP4,                      /**< @if OSPDEPREC The MP4 format @endif */
+       VIDEORECORDING_FORMAT_3GP,                      /**< @if OSPDEPREC The 3GP format @endif */
+};
+
+/**
+ * @if OSPDEPREC
+ * @enum VideoRecorderMode
+ *
+ * Defines the mode of a video recorder.
+ *
+ * @brief <i> [Deprecated]  </i>
+ * @deprecated This enum is deprecated because new methods do not use this enum. For video only recording, instead of using this enum, use
+ *                             ::CODEC_NONE.
+ * @since              2.0
+ *
+ * @see                VideoRecorder::SetMode()
+ * @see                VideoRecorder::GetMode()
+ * @endif
+ */
+enum VideoRecorderMode
+{
+       VIDEORECORDER_MODE_VIDEO_WITH_AUDIO,                /**< @if OSPDEPREC The video with audio mode @endif */
+       VIDEORECORDER_MODE_VIDEO_ONLY,                      /**< @if OSPDEPREC The video only mode @endif */
+};
+
+}}
+
+#endif
diff --git a/inc/FMediaVideoStreamInfo.h b/inc/FMediaVideoStreamInfo.h
new file mode 100644 (file)
index 0000000..d0b07b3
--- /dev/null
@@ -0,0 +1,161 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaVideoStreamInfo.h
+ * @brief                      This is the header file for the %VideoStreamInfo class.
+ *
+ * This header file contains the declarations of the %VideoStreamInfo class.
+ */
+
+#ifndef _FMEDIA_VIDEO_STREAM_INFO_H_
+#define _FMEDIA_VIDEO_STREAM_INFO_H_
+
+#include <FBaseObject.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @class       VideoStreamInfo
+ * @brief       This class provides methods to get video information.
+ *
+ * @since              2.0
+ *
+ * The %VideoStreamInfo class provides methods to get video stream information, such as codec type, video width or height, bit rate,
+ * and frame rate.
+ *
+ */
+
+class _OSP_EXPORT_ VideoStreamInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since                2.0
+       */
+       virtual ~VideoStreamInfo(void);
+
+public:
+       /**
+       * Gets the encoding type of a video.
+       *
+       * @since                2.0
+       *
+       * @return                        The value of the encoding type
+       */
+       CodecType GetCodecType(void) const;
+
+       /**
+       * Gets the width of a video.
+       *
+       * @since                2.0
+       *
+       * @return                        The value of the video width
+       */
+       int GetWidth(void) const;
+
+       /**
+       * Gets the height of a video.
+       *
+       * @since                2.0
+       *
+       * @return                        The value of the video height
+       */
+       int GetHeight(void) const;
+
+       /**
+       * Gets the bit rate of a video.
+       *
+       * @since                2.0
+       *
+       * @return                        The video bit rate in bits per second (bps)
+       */
+       int GetBitRate(void) const;
+
+       /**
+       * Gets the frame rate of a video.
+       *
+       * @since                2.0
+       *
+       * @return                        The video frame rate
+       */
+       float GetFrameRate(void) const;
+
+       /**
+       * Copying of objects using this copy constructor is allowed.
+       *
+       * @since                2.0
+       *
+       * @return               The copy of this instance
+       * @param[in] rhs An instance of %VideoStreamInfo
+       */
+       VideoStreamInfo(const VideoStreamInfo & rhs);
+
+       /**
+       * Copying of objects using this copy assignment operator is allowed.
+       *
+       * @since                2.0
+       *
+       * @return The reference of this instance
+       * @param[in] rhs An instance of %VideoStreamInfo
+       */
+       VideoStreamInfo & operator =(const VideoStreamInfo & rhs);
+
+       /**
+       * Compares the specified instance of Tizen::Base::Object with the calling instance of %VideoStreamInfo.
+       *
+       * @since                2.0
+       *
+       * @return                                                 @c true if the value of the specified instance equals the value of the current instance, @n
+       *                else @c false
+       * @param[in]       rhs                                    The object to compare with the current instance
+       */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+       * Gets the hash value of the current instance.
+       *
+       * @since                2.0
+       *
+       * @return                                                 The hash value of the current instance
+       */
+       virtual int GetHashCode(void) const;
+
+private:
+       /**
+       * This default constructor is intentionally declared as private so that only the platform can create an instance.
+       *
+       * @param [in]   codecType       The value of the encoding type
+       * @param [in]   width           The value of the video width
+       * @param [in]   height          The value of the video height
+       * @param [in]   bitrate         The video bit rate in bits per second (bps)
+       * @param [in]   frameRate       The video frame rate
+       */
+       VideoStreamInfo(CodecType codecType, int width, int height, int bitrate, float frameRate);
+
+private:
+       friend class _PlayerImpl;
+       class _VideoStreamInfoImpl *__pVideoStreamInfoImpl;
+};
+
+}}//Tizen::Media
+
+
+#endif
diff --git a/inc/FMediaVoipAudioSessionManager.h b/inc/FMediaVoipAudioSessionManager.h
new file mode 100755 (executable)
index 0000000..3b4dbca
--- /dev/null
@@ -0,0 +1,201 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaVoipAudioSessionManager.h
+ * @brief                      This is the header file for the %VoipAudioSessionManager class.
+ *
+ * This header file contains the declarations of the %VoipAudioSessionManager class.
+ */
+
+#ifndef _FMEDIA_VOIP_AUDIO_SESSION_MANAGER_H_
+#define _FMEDIA_VOIP_AUDIO_SESSION_MANAGER_H_
+
+#include <FMediaAudioManagerTypes.h>
+
+namespace Tizen { namespace Media
+{
+/**
+ * @if VISPARTNER
+ *     @class VoipAudioSessionManager
+ * @brief      This class is used to manage audio session for VoIP call.
+ * The audio system related operation will be performed based on the VoIP call scenario with the methods of this class.
+ * As the precondition, all media-related instances MUST be destroyed before this class is used.
+ *
+ *     @since          2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ *     @visibility                     partner
+ *
+ * @remarks   Only one instance of the class works at a time.
+ * @endif
+ */
+class _OSP_EXPORT_ VoipAudioSessionManager
+       :public Tizen::Base::Object
+{
+public:
+       /**
+       *       @if VISPARTNER
+       *       Gets the VoIP audio session  manager instance's pointer.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.voipsession
+       *
+       *       @return                 A pointer to the VoIP audio session manager instance, @n
+                                                                       else @c null if it fails
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_OUT_OF_MEMORY                 Not enough memory to perform the operation
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks            The specific error code can be accessed using the GetLastResult() method.
+       *       @endif
+       */
+       static VoipAudioSessionManager* GetInstance(void);
+
+       /**
+       * @if VISPARTNER
+       *       Enters a new VoIP call session
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.voipsession
+       *
+       *       @return                                 An error code
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_OUT_OF_MEMORY                 Not enough memory to make a VoIP call
+       *       @exception                      E_INVALID_STATE                         This instance is in an invalid state for this method
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks                        The method returns E_INVALID_STATE when this method is called more than once.
+       *       @remarks                        All media-related instances MUST be destroyed before entering the VoIP call audio session.@n
+                                                                       if not,  this method returns E_INVALID_STATE.
+       *       @endif
+       */
+       result EnterCallSession(void);
+
+       /**
+       * @if VISPARTNER
+       *       Sets the VoIP call session's current operation mode such as voice calling, ringing, or playing media stream.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.voipsession
+       *
+       *       @return                                 An error code
+       *       @param[in]                              mode                                                                    The VoIP audio session mode
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_INVALID_STATE                         This instance is in an invalid state for this method.
+       *       @exception                      E_INVALID_ARG                                   A specified input parameter is invalid
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks This method should be called after EnterCallSession(), if not, this method returns E_INVALID_STATE.
+       *       @endif
+       */
+       result SetCallSessionMode(VoipAudioSessionMode mode);
+
+       /**
+       * @if VISPARTNER
+       *       Gets the current VoIP call session mode
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.voipsession
+       *
+       *       @return                                 VoIP audio session mode,@n
+                                                                               or returns VOIP_AUDIO_SESSION_MODE_NONE when this method fail.
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *       @exception                      E_INVALID_STATE                         This instance is in an invalid state for this method.
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks                        If exception is occured then this method returns VOIP_CALL_SESSION_MODE_NONE
+       *       @remarks This method should be called after EnterCallSession(), if not, this method returns E_INVALID_STATE.
+       *       @endif
+       */
+       VoipAudioSessionMode GetCallSessionMode(void) const;
+
+       /**
+       * @if VISPARTNER
+       *       Exits current VoIP call session
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @privilege                              %http://tizen.org/privilege/audiomanager.voipsession
+       *
+       *       @return                         An error code
+       *       @exception                      E_SUCCESS                                               The method is successful
+       *  @exception                   E_INVALID_STATE                         This instance is in an invalid state for this method.
+       *       @exception                      E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method
+       *       @remarks This method should be called after EnterCallSession(), if not, this method returns E_INVALID_STATE.
+       *       @endif
+       */
+       result ExitCallSession(void);
+
+private:
+       /**
+       * @if VISPARTNER
+       *       This default constructor is intentionally declared as private to implement the Singleton semantic.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @endif
+       */
+       VoipAudioSessionManager(void);
+
+       /**
+       *  @if VISPARTNER
+       *       This destructor is intentionally declared as private to implement the Singleton semantic.
+       *
+       *       @since          2.0
+       *
+       *       @visibility                             partner
+       *       @endif
+       */
+       virtual ~VoipAudioSessionManager(void);
+
+       /**
+        * @if VISPARTNER
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since               2.0
+        *
+        * @visibility          partner
+        * @endif
+        */
+       VoipAudioSessionManager(const VoipAudioSessionManager& rhs);
+
+       /**
+        * @if VISPARTNER
+        * The implementation of this copy assignment  operator is intentionally blank and declared as private to prohibit assigning of objects.
+        *
+        * @since               2.0
+        *
+        * @visibility          partner
+        * @endif
+        */
+       VoipAudioSessionManager& operator =(const VoipAudioSessionManager& rhs);
+
+       class _VoipAudioSessionManagerImpl* __pVoipAudioSessionManagerImpl;
+
+};
+
+}} // Tizen::Media
+
+#endif
diff --git a/osp-media.manifest b/osp-media.manifest
new file mode 100644 (file)
index 0000000..ae3e6f7
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
\ No newline at end of file
diff --git a/osp-media.pc.in b/osp-media.pc.in
new file mode 100755 (executable)
index 0000000..c064287
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib/osp
+includedir=/usr/include/osp
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
\ No newline at end of file
diff --git a/packaging/osp-media.spec b/packaging/osp-media.spec
new file mode 100755 (executable)
index 0000000..9562231
--- /dev/null
@@ -0,0 +1,130 @@
+%define debug_package %{nil}
+%define __strip /bin/true
+
+Name:       osp-media
+Summary:    The Media library of OSP 
+Version:    1.2.0.0
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    TO BE FILLED IN
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(chromium)
+BuildRequires:  pkgconfig(capi-media-sound-manager)
+BuildRequires:  pkgconfig(capi-media-player)
+BuildRequires:  pkgconfig(capi-media-audio-io)
+BuildRequires:  pkgconfig(capi-media-camera)
+BuildRequires:  pkgconfig(capi-media-recorder)
+BuildRequires:  pkgconfig(capi-media-metadata-extractor)
+BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires:  pkgconfig(capi-system-device)
+BuildRequires:  pkgconfig(evas)
+BuildRequires:  pkgconfig(libcurl)
+BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(libavcodec)
+BuildRequires:  pkgconfig(libavformat)
+BuildRequires:  pkgconfig(libavutil)
+BuildRequires:  pkgconfig(libswscale)
+BuildRequires:  pkgconfig(libwbxml2)
+BuildRequires:  pkgconfig(osp-appfw)
+BuildRequires:  osp-appfw-internal-devel
+BuildRequires:  pkgconfig(osp-image-core)
+BuildRequires:  osp-image-core-internal-devel
+BuildRequires:  pkgconfig(osp-uifw)
+BuildRequires:  osp-uifw-internal-devel
+BuildRequires:  pkgconfig(osp-net)
+BuildRequires:  osp-net-internal-devel
+BuildRequires:  pkgconfig(osp-image)
+BuildRequires:  osp-image-internal-devel
+BuildRequires:  pkgconfig(opencore-amrnb)
+BuildRequires:  pkgconfig(ogg)
+BuildRequires:  pkgconfig(vorbis)
+BuildRequires:  libexif-devel
+BuildRequires:  boost-devel
+
+# runtime requires
+Requires: capi-media-player
+Requires: capi-media-audio-io  
+Requires: capi-media-camera  
+Requires: capi-media-recorder  
+Requires: capi-media-metadata-extractor  
+Requires: osp-appfw
+Requires: osp-image-core
+Requires: osp-uifw
+Requires: osp-net
+Requires: osp-image
+
+Provides:   libosp-media.so.1
+
+Requires(post): /sbin/ldconfig  
+Requires(postun): /sbin/ldconfig
+
+%description
+The Media library of OSP
+
+%package devel
+Summary:    The Media library of OSP (Development)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+The Media library of OSP (DEV)
+
+%package internal-devel
+Summary:    osp media internel (Internal)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description internal-devel
+The Media library of OSP (Internal-DEV)
+
+%package debug
+Summary:    The Media library of OSP (Development)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description debug
+The Media library of OSP (DEV)
+
+%prep
+%setup -q
+
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%ifarch %{ix86}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=x86
+%else
+CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=arm
+%endif
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2.0  %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-media.manifest
+/usr/share/license/%{name}
+%{_libdir}/osp/libosp-media.so*
+
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/osp-media.pc
+
+%files internal-devel
+%{_includedir}/osp/media/*.h
+
+%files debug
+%{_libdir}/osp/debug/*.so*
+
diff --git a/src/FMediaAudioDecoder.cpp b/src/FMediaAudioDecoder.cpp
new file mode 100644 (file)
index 0000000..a620e2a
--- /dev/null
@@ -0,0 +1,190 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FMediaAudioDecoder.h>
+#include <FBaseSysLog.h>
+#include "FMedia_AudioDecoderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+AudioDecoder::AudioDecoder(void)
+{
+       __pImpl = null;
+}
+
+AudioDecoder::~AudioDecoder(void)
+{
+       if (__pImpl != null)
+       {
+               delete __pImpl;
+       }
+}
+
+result
+AudioDecoder::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl == null,
+               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       _AudioDecoderImpl* pAudioDecoderImpl = new (std::nothrow) _AudioDecoderImpl();
+       SysTryCatch(NID_MEDIA, pAudioDecoderImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                         "[%s] Memory Allocation  Failed. Propagating. ",GetErrorMessage(E_OUT_OF_MEMORY));    \r
+
+       r = pAudioDecoderImpl->Construct(type, pOption);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(r);
+       __pImpl = pAudioDecoderImpl;
+       return E_SUCCESS;
+
+CATCH:
+       if (pAudioDecoderImpl != null)
+       {
+               delete pAudioDecoderImpl;
+               pAudioDecoderImpl = null;
+       }
+       return r;
+}
+
+result
+AudioDecoder::Probe(const Tizen::Base::ByteBuffer& srcBuf, AudioSampleType& sampleType,
+                                       AudioChannelType& channelType, int& sampleRate)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pImpl->Probe(srcBuf, sampleType, channelType, sampleRate);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+AudioDecoder::Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pImpl->Decode(srcBuf, dstBuf);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+AudioDecoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pImpl->Reset();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+AudioDecoder::GetValue(MediaPropertyType GetValue, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pImpl->GetValue(GetValue, value);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+AudioDecoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::IListT<MediaPropertyType> *pList = null;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       pList = __pImpl->GetSupportedPropertyListN();
+       SysTryCatch(NID_MEDIA, pList != null, , GetLastResult(), "[%s] Propagating", GetErrorMessage(GetLastResult()));
+
+       SetLastResult(E_SUCCESS);
+       return pList;
+
+CATCH:
+       return null;
+}
+
+bool
+AudioDecoder::IsPropertySupported(MediaPropertyType key) const
+{
+       result r = E_SUCCESS;
+       bool supported = false;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       supported = __pImpl->IsPropertySupported(key);
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(r);
+       return supported;
+
+CATCH:
+       return false;
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+AudioDecoder::GetSupportedCodecListN(void)
+{
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::IListT<CodecType> *pList = null;
+
+       pList = _AudioDecoderImpl::GetSupportedCodecListN();
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, pList != null, null, r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+} } // Tizen::Media
diff --git a/src/FMediaAudioEncoder.cpp b/src/FMediaAudioEncoder.cpp
new file mode 100644 (file)
index 0000000..5bc5c9e
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseColArrayListT.h>
+#include <FMediaAudioEncoder.h>
+#include <FBaseSysLog.h>
+#include "FMedia_AudioEncoderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+AudioEncoder::AudioEncoder(void)
+{
+       __pImpl = null;
+}
+
+AudioEncoder::~AudioEncoder(void)
+{
+       if (__pImpl != null)
+       {
+               delete __pImpl;
+       }
+}
+
+result
+AudioEncoder::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl == null,
+               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       _AudioEncoderImpl* pAudioEncoderImpl = new (std::nothrow) _AudioEncoderImpl();
+       SysTryCatch(NID_MEDIA, pAudioEncoderImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                         "[%s] Memory Allocation Failed.", GetErrorMessage(E_OUT_OF_MEMORY));\r
+
+       r = pAudioEncoderImpl->Construct(type, pOption);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct _AudioEncoderImpl", GetErrorMessage(r));\r
+
+       __pImpl = pAudioEncoderImpl;
+       return E_SUCCESS;
+
+CATCH:
+       if (pAudioEncoderImpl != null)
+       {
+               delete pAudioEncoderImpl;
+               pAudioEncoderImpl = null;
+       }
+       return r;
+}
+
+result
+AudioEncoder::Encode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->Encode(srcBuf, dstBuf);
+}
+
+result
+AudioEncoder::Reset(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->Reset();
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+AudioEncoder::GetSupportedCodecListN(void)
+{
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::IListT<CodecType> *pList = null;
+
+       pList = _AudioEncoderImpl::GetSupportedCodecListN();
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, pList != null, null, r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+
+}} // Tizen::Media
diff --git a/src/FMediaAudioEqualizer.cpp b/src/FMediaAudioEqualizer.cpp
new file mode 100644 (file)
index 0000000..6ef6f07
--- /dev/null
@@ -0,0 +1,157 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+#include "FMedia_PlayerEvent.h"
+#include "FMedia_PlayerVideoEvent.h"
+#include "FMedia_PlayerEventTypes.h"
+#include "FMedia_PlayerVideoEventTypes.h"
+#include "FMedia_PlayerImpl.h"
+#include <FMediaAudioEqualizer.h>
+#include <FMedia_AudioEqualizerImpl.h>
+
+
+namespace Tizen { namespace Media
+{
+
+AudioEqualizer::AudioEqualizer(void)
+       : __pAudioEqualizerImpl(null)
+{
+
+}
+
+AudioEqualizer::~AudioEqualizer()
+{
+
+       if (__pAudioEqualizerImpl != null)
+       {
+               delete __pAudioEqualizerImpl;
+               __pAudioEqualizerImpl = null;
+       }
+
+}
+
+result
+AudioEqualizer::Construct(Player& player)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioEqualizerImpl == null,
+               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       _AudioEqualizerImpl* pAudioEqualizerImpl = new (std::nothrow) _AudioEqualizerImpl();
+       SysTryCatch(NID_MEDIA, pAudioEqualizerImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pAudioEqualizerImpl->Construct(player);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct _pAudioEqualizerImpl.", GetErrorMessage(r));
+
+       __pAudioEqualizerImpl = pAudioEqualizerImpl;
+       return E_SUCCESS;
+
+CATCH:
+       if (pAudioEqualizerImpl != null)
+       {
+               delete pAudioEqualizerImpl;
+               pAudioEqualizerImpl = null;
+       }
+       return r;
+}
+
+int
+AudioEqualizer::GetBandCount(void) const
+{
+       SysAssertf(__pAudioEqualizerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+       return __pAudioEqualizerImpl->GetBandCount();
+}
+
+result
+AudioEqualizer::GetBandLevelRange(int index, int& minValue, int& maxValue) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioEqualizerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioEqualizerImpl->GetBandLevelRange(index,minValue,maxValue);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform GetBandLevelRange operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioEqualizer::SetBandLevel(int index, int level)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioEqualizerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioEqualizerImpl->SetBandLevel(index,level);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform SetBandLevel operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioEqualizer::SetAllBandsLevel(const Tizen::Base::Collection::IListT<int>* pLevels)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioEqualizerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioEqualizerImpl->SetAllBandsLevel(pLevels);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform SetAllBandsLevel operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioEqualizer::GetBandLevel(int index, int& level) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioEqualizerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioEqualizerImpl->GetBandLevel(index,level);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform GetBandLevel operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioEqualizer::GetBandCenterFrequency(int index, int& frequency) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioEqualizerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioEqualizerImpl->GetBandCenterFrequency(index,frequency);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform GetBandCenterFrequency operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioEqualizer::ResetAllToDefault(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioEqualizerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioEqualizerImpl->ResetAllToDefault();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform ResetAllToDefault operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+};
+};
+
diff --git a/src/FMediaAudioIn.cpp b/src/FMediaAudioIn.cpp
new file mode 100644 (file)
index 0000000..e3ac3e4
--- /dev/null
@@ -0,0 +1,243 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FMediaAudioIn.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_AudioInImpl.h"
+
+
+namespace Tizen { namespace Media
+{
+
+
+AudioIn::AudioIn(void)
+       : __pAudioInImpl(null)
+{
+}
+
+AudioIn::~AudioIn(void)
+{
+       if (__pAudioInImpl)
+       {
+               delete __pAudioInImpl;
+       }
+}
+
+result
+AudioIn::Construct(IAudioInEventListener& listener)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioInImpl == null,      "Failed to construct an instance of AudioIn. Calling Construct() twice or more on a same instance is not allowed for this class");
+
+       _AudioInImpl* pAudioInImpl = new (std::nothrow) _AudioInImpl;
+
+       SysTryCatch(NID_MEDIA, pAudioInImpl, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY , "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pAudioInImpl->Construct(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pAudioInImpl = pAudioInImpl;
+
+       return r;
+
+CATCH:
+       if (pAudioInImpl)
+       {
+               delete pAudioInImpl;
+               pAudioInImpl = null;
+       }
+       return r;
+}
+
+result
+AudioIn::Prepare(AudioInputDevice audioInputDevice, AudioSampleType audioSampleType, AudioChannelType audioChannelType,
+                                int audioSampleRate)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioInImpl->Prepare(audioSampleType, audioChannelType, audioSampleRate);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioIn::Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioInImpl->Prepare(audioSampleType, audioChannelType, audioSampleRate);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioIn::Unprepare(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioInImpl->Unprepare();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioIn::AddBuffer(const Tizen::Base::ByteBuffer* pByteBuffer)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+       SysTryReturn(NID_MEDIA, pByteBuffer, E_INVALID_ARG, E_INVALID_ARG, "The value of pByteBuffer is null.");
+
+       r = __pAudioInImpl->AddBuffer(pByteBuffer);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioIn::Start(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioInImpl->Start();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioIn::Stop(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioInImpl->Stop();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+result
+AudioIn::Reset(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioInImpl->Reset();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+AudioInState
+AudioIn::GetState(void) const
+{
+       ClearLastResult();
+       AudioInState audioState = AUDIOIN_STATE_ERROR;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       audioState = __pAudioInImpl->GetState();
+       SysTryReturn(NID_MEDIA, audioState != AUDIOIN_STATE_ERROR , audioState, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       return audioState;
+
+}
+
+int
+AudioIn::GetMaxBufferSize(void) const
+{
+       ClearLastResult();
+       int bufferSize = -1;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       bufferSize = __pAudioInImpl->GetMaxBufferSize();
+       SysTryReturn(NID_MEDIA, bufferSize != -1, bufferSize, GetLastResult(), "[%s] Progogated", GetErrorMessage(GetLastResult()));
+       return bufferSize;
+}
+
+int
+AudioIn::GetMinBufferSize(void) const
+{
+       ClearLastResult();
+       int bufferSize = -1;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       bufferSize = __pAudioInImpl->GetMinBufferSize();
+       SysTryReturn(NID_MEDIA,  bufferSize != -1, bufferSize, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       return bufferSize;
+}
+
+AudioSampleType
+AudioIn::GetOptimizedSampleType(void) const
+{
+       ClearLastResult();
+       AudioSampleType audioSampleType = AUDIO_TYPE_NONE;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       audioSampleType = __pAudioInImpl->GetOptimizedSampleType();
+       SysTryReturn(NID_MEDIA, audioSampleType != AUDIO_TYPE_NONE , audioSampleType, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       return audioSampleType;
+}
+
+AudioChannelType
+AudioIn::GetOptimizedChannelType(void) const
+{
+       ClearLastResult();
+       AudioChannelType audioChannelType = AUDIO_CHANNEL_TYPE_NONE;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       audioChannelType = __pAudioInImpl->GetOptimizedChannelType();
+       SysTryReturn(NID_MEDIA, audioChannelType != AUDIO_CHANNEL_TYPE_NONE , audioChannelType, GetLastResult(), " [%s] Progpogated", GetErrorMessage(GetLastResult()));
+       return audioChannelType;
+}
+
+int
+AudioIn::GetOptimizedSampleRate(void) const
+{
+       ClearLastResult();
+       int sampleRate = 0;
+
+       SysAssertf(__pAudioInImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       sampleRate = __pAudioInImpl->GetOptimizedSampleRate();
+       SysTryReturn(NID_MEDIA, sampleRate != 0, sampleRate, GetLastResult(), "[%s] Propogeated", GetErrorMessage(GetLastResult()));
+       return sampleRate;
+}
+
+
+}} // Tizen::Media
diff --git a/src/FMediaAudioOut.cpp b/src/FMediaAudioOut.cpp
new file mode 100644 (file)
index 0000000..de0bb9b
--- /dev/null
@@ -0,0 +1,279 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FMediaAudioOut.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_AudioOutImpl.h"
+
+
+namespace Tizen { namespace Media
+{
+
+AudioOut::AudioOut(void)
+       : __pAudioOutImpl(null)
+{
+}
+
+AudioOut::~AudioOut(void)
+{
+       if (__pAudioOutImpl)
+       {
+               delete __pAudioOutImpl;
+       }
+
+}
+
+result
+AudioOut::Construct(IAudioOutEventListener& listener)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl == null, "This instance is already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
+
+       _AudioOutImpl* pAudioOutImpl = new (std::nothrow) _AudioOutImpl;
+       SysTryCatch(NID_MEDIA, pAudioOutImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pAudioOutImpl->Construct(this, listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pAudioOutImpl = pAudioOutImpl;
+
+       return r;
+
+CATCH:
+       if (pAudioOutImpl)
+       {
+               delete pAudioOutImpl;
+               pAudioOutImpl = null;
+       }
+       return r;
+}
+
+result
+AudioOut::Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioOutImpl->Prepare(audioSampleType, audioChannelType, audioSampleRate);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioOut::Prepare(AudioStreamType audioStreamType, AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioOutImpl->Prepare(audioStreamType, audioSampleType, audioChannelType, audioSampleRate);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioOut::Unprepare(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioOutImpl->UnPrepare();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioOut::WriteBuffer(const Tizen::Base::ByteBuffer& userData)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioOutImpl->WriteBuffer(userData);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioOut::Start(void)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioOutImpl->Start();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioOut::Stop(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioOutImpl->Stop();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioOut::Reset(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pAudioOutImpl->Reset();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+AudioOutState
+AudioOut::GetState(void) const
+{
+       ClearLastResult();
+       AudioOutState audioState = AUDIOOUT_STATE_ERROR;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       audioState = __pAudioOutImpl->GetState();
+       SysTryReturn(NID_MEDIA, audioState != AUDIOOUT_STATE_ERROR, AUDIOOUT_STATE_ERROR, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return audioState;
+}
+
+int
+AudioOut::GetMaxBufferSize(void) const
+{
+       ClearLastResult();
+       int bufferSize = -1;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       bufferSize = __pAudioOutImpl->GetMaxBufferSize();
+       SysTryReturn(NID_MEDIA, bufferSize != -1, bufferSize, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return bufferSize;
+}
+
+int
+AudioOut::GetMinBufferSize(void) const
+{
+       ClearLastResult();
+       int bufferSize = -1;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       bufferSize = __pAudioOutImpl->GetMinBufferSize();
+       SysTryReturn(NID_MEDIA, bufferSize != -1, bufferSize, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       return bufferSize;
+}
+
+AudioSampleType
+AudioOut::GetOptimizedSampleType(void) const
+{
+       ClearLastResult();
+       AudioSampleType audioSampleType = AUDIO_TYPE_NONE;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       audioSampleType = __pAudioOutImpl->GetOptimizedSampleType();
+       SysTryReturn(NID_MEDIA, audioSampleType != AUDIO_TYPE_NONE, AUDIO_TYPE_NONE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       return audioSampleType;
+}
+
+AudioChannelType
+AudioOut::GetOptimizedChannelType(void) const
+{
+       ClearLastResult();
+       AudioChannelType audioChannelType = AUDIO_CHANNEL_TYPE_NONE;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       audioChannelType = __pAudioOutImpl->GetOptimizedChannelType();
+       SysTryReturn(NID_MEDIA, audioChannelType != AUDIO_CHANNEL_TYPE_NONE, AUDIO_CHANNEL_TYPE_NONE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       return audioChannelType;
+}
+
+int
+AudioOut::GetOptimizedSampleRate(void) const
+{
+       ClearLastResult();
+       int sampleRate = 0;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       sampleRate = __pAudioOutImpl->GetOptimizedSampleRate();
+       SysTryReturn(NID_MEDIA, sampleRate != 0, 0, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return sampleRate;
+}
+
+result
+AudioOut::SetVolume(int volume)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+       SysTryReturn(NID_MEDIA, (volume <= 100) && (volume >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                       "[E_OUT_OF_RANGE] volume is out of range. The value of volume should be between 0 and 100");
+
+       r = __pAudioOutImpl->SetVolume(volume);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+int
+AudioOut::GetVolume(void) const
+{
+       ClearLastResult();
+       int volume = -1;
+
+       SysAssertf(__pAudioOutImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       volume = __pAudioOutImpl->GetVolume();
+       SysTryReturn(NID_MEDIA, volume != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return volume;
+}
+
+}} // Tizen::Media
diff --git a/src/FMediaAudioRecorder.cpp b/src/FMediaAudioRecorder.cpp
new file mode 100755 (executable)
index 0000000..7657dcc
--- /dev/null
@@ -0,0 +1,428 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMediaAudioRecorder.cpp
+ * @brief              This file contains the implementation of the %AudioRecorder class.
+ */
+
+#include <FMediaAudioRecorder.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMedia_RecorderTypes.h"
+#include "FMedia_AudioRecorderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Media
+{
+
+AudioRecorder::AudioRecorder(void)
+       : __pImpl(null)
+{
+
+}
+
+AudioRecorder::~AudioRecorder(void)
+{
+       if (__pImpl != null)
+       {
+               delete __pImpl;
+       }
+}
+
+result
+AudioRecorder::Construct(IAudioRecorderEventListener& listener)
+{
+       SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       result r = E_SUCCESS;
+
+       //Create impl
+       _AudioRecorderImpl* pImpl = new (std::nothrow) _AudioRecorderImpl();
+       SysTryCatch(NID_MEDIA, pImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pImpl->Construct(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pImpl = pImpl;
+       return r;
+
+CATCH:
+       if (pImpl != null)
+       {
+               delete pImpl;
+               pImpl = null;
+       }
+       return r;
+}
+
+result
+AudioRecorder::CreateAudioFile(const Tizen::Base::String& mediaLocalPath, bool overwrite)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->CreateAudioFile(mediaLocalPath, overwrite);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioRecorder::Close(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Close();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioRecorder::Record(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Record();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioRecorder::Stop(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Stop();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioRecorder::Pause(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Pause();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioRecorder::Cancel(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Cancel();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+RecorderState
+AudioRecorder::GetState(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       ClearLastResult();
+
+       state = __pImpl->GetState();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return state;
+
+CATCH:
+       return static_cast<RecorderState>( MEDIA_INVALID_VALUE);
+
+}
+
+long
+AudioRecorder::GetRecordingTime(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       long time = MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       time = __pImpl->GetRecordingTime();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return time;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+long
+AudioRecorder::GetRecordingSize(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       long size = MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       size = __pImpl->GetRecordingSize();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return size;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+result
+AudioRecorder::SetMaxRecordingTime(long msTime)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetMaxRecordingTime(msTime);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+long
+AudioRecorder::GetMaxRecordingTime(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       long time = MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       time = __pImpl->GetMaxRecordingTime();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return time;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+
+}
+
+
+result
+AudioRecorder::SetFormat(AudioRecordingFormat format)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetFormat(format);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+AudioRecordingFormat
+AudioRecorder::GetFormat(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       AudioRecordingFormat format = AUDIORECORDING_FORMAT_AMR;
+       ClearLastResult();
+
+       format = __pImpl->GetFormat();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return format;
+
+CATCH:
+       return static_cast<AudioRecordingFormat>( MEDIA_INVALID_VALUE);
+
+}
+
+result
+AudioRecorder::SetFormat(CodecType audioCodec, MediaContainerType container)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetFormat(audioCodec, container);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+AudioRecorder::GetFormat(CodecType& audioCodec, MediaContainerType& container) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       __pImpl->GetFormat(audioCodec, container);
+       return r;
+}
+
+Tizen::Base::Collection::IListT <CodecType>*
+AudioRecorder::GetSupportedCodecListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       ArrayListT <CodecType>* pDestListT = null;
+       ClearLastResult();
+
+       pDestListT = __pImpl->GetSupportedCodecListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       return pDestListT;
+
+CATCH:
+       if (pDestListT != null)
+       {
+               pDestListT->RemoveAll();
+               delete pDestListT;
+       }
+
+       return null;
+}
+
+Tizen::Base::Collection::IListT <MediaContainerType>*
+AudioRecorder::GetSupportedContainerListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       ArrayListT <MediaContainerType>* pDestListT = null;
+       ClearLastResult();
+
+       pDestListT = __pImpl->GetSupportedContainerListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pDestListT;
+
+CATCH:
+       if (pDestListT != null)
+       {
+               pDestListT->RemoveAll();
+               delete pDestListT;
+       }
+
+       return null;
+}
+
+result
+AudioRecorder::SetQuality(RecordingQuality quality)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetQuality(quality);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+RecordingQuality
+AudioRecorder::GetQuality(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       RecordingQuality quality = RECORDING_QUALITY_LOW;
+       ClearLastResult();
+
+       quality = __pImpl->GetQuality();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return quality;
+
+CATCH:
+       return static_cast<RecordingQuality>( MEDIA_INVALID_VALUE);
+
+}
+
+result
+AudioRecorder::SetMute(bool mute)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetMute(mute);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+bool
+AudioRecorder::IsMuted(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       bool mute = false;
+       ClearLastResult();
+
+       mute = __pImpl->IsMuted();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return mute;
+
+CATCH:
+       return false;
+}
+
+}}// Tizen::Media
diff --git a/src/FMediaAudioRouteInfo.cpp b/src/FMediaAudioRouteInfo.cpp
new file mode 100644 (file)
index 0000000..bd50bd1
--- /dev/null
@@ -0,0 +1,105 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+#include <FBaseSysLog.h>
+#include <FMediaAudioRouteInfo.h>
+#include "FMedia_AudioRouteInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+AudioRouteInfo::AudioRouteInfo(InputAudioDevice in, OutputAudioDevice out)
+{
+       __pAudioRouteInfoImpl = new (std::nothrow) _AudioRouteInfoImpl(in,out);
+}
+
+AudioRouteInfo::~AudioRouteInfo()
+{
+       if (__pAudioRouteInfoImpl)
+       {
+               delete __pAudioRouteInfoImpl;
+               __pAudioRouteInfoImpl = null;
+       }
+}
+
+AudioRouteInfo::AudioRouteInfo(const AudioRouteInfo& rhs)
+{
+       if (rhs.__pAudioRouteInfoImpl)
+       {
+               __pAudioRouteInfoImpl = new (std::nothrow)_AudioRouteInfoImpl(*(rhs.__pAudioRouteInfoImpl));
+       }
+}
+
+void
+AudioRouteInfo::SetInputAudioDevice(InputAudioDevice in)
+{
+       __pAudioRouteInfoImpl->SetInputAudioDevice(in);
+
+}
+
+void
+AudioRouteInfo::SetOutputAudioDevice(OutputAudioDevice out)
+{
+
+       __pAudioRouteInfoImpl->SetOutputAudioDevice(out);
+}
+
+InputAudioDevice
+AudioRouteInfo::GetInputAudioDevice(void) const
+{
+       return __pAudioRouteInfoImpl->GetInputAudioDevice();
+}
+
+OutputAudioDevice
+AudioRouteInfo::GetOutputAudioDevice(void) const
+{
+       return __pAudioRouteInfoImpl->GetOutputAudioDevice();
+}
+
+AudioRouteInfo&
+AudioRouteInfo::operator =(const AudioRouteInfo& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+       *__pAudioRouteInfoImpl = *(rhs.__pAudioRouteInfoImpl);
+       return *this;
+}
+
+bool
+AudioRouteInfo::Equals(const Object& obj) const
+{
+       const AudioRouteInfo *pRhs = dynamic_cast<const AudioRouteInfo *>(&obj);
+       if (pRhs == null)
+       {
+               return false;
+       }
+       return __pAudioRouteInfoImpl->Equals(*pRhs->__pAudioRouteInfoImpl);
+
+}
+
+int
+AudioRouteInfo::GetHashCode(void) const
+{
+       return __pAudioRouteInfoImpl->GetHashCode();
+}
+
+};};           //Tizen::Media
diff --git a/src/FMediaAudioRouteManager.cpp b/src/FMediaAudioRouteManager.cpp
new file mode 100644 (file)
index 0000000..844148f
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License)
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include <FMediaAudioRouteInfo.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaAudioRouteManager.h>
+#include <FMediaIAudioRouteEventListener.h>
+#include "FMedia_AudioRouteManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Media
+{
+
+AudioRouteManager::AudioRouteManager()
+{
+       __pAudioRouteManagerImpl = _AudioRouteManagerImpl::GetInstance();
+}
+
+AudioRouteManager::~AudioRouteManager()
+{
+       if (__pAudioRouteManagerImpl != null)
+       {
+               __pAudioRouteManagerImpl = null;
+       }
+}
+
+AudioRouteManager*
+AudioRouteManager::GetInstance(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_ROUTE);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       static AudioRouteManager routeManager;
+       return (&routeManager);
+
+CATCH:
+       return null;
+}
+
+result
+AudioRouteManager::SetAudioRouteEventListener(IAudioRouteEventListener* pListener)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_ROUTE);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioRouteManagerImpl->SetAudioRouteEventListener(pListener);
+}
+
+
+
+Tizen::Base::String
+AudioRouteManager::GetActiveBluetoothA2dpName(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_ROUTE);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioRouteManagerImpl->GetActiveBluetoothA2dpName();
+
+CATCH:
+       return null;
+}
+
+AudioStreamType
+AudioRouteManager::GetActiveAudioStreamType(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_ROUTE);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioRouteManagerImpl->GetActiveAudioStreamType();
+
+CATCH:
+       return (AudioStreamType) -1;
+}
+
+Tizen::Base::Collection::IList*
+AudioRouteManager::GetAvailableAudioRouteListN(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_ROUTE);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioRouteManagerImpl->GetAvailableAudioRouteListN();
+
+CATCH:
+       return null;
+}
+
+bool
+AudioRouteManager::IsAudioRouteAvailable(const AudioRouteInfo& route) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_ROUTE);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioRouteManagerImpl->IsAudioRouteAvailable(route);
+
+CATCH:
+       return false;
+}
+
+result
+AudioRouteManager::SetActiveAudioRoute(const AudioRouteInfo& route)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_ROUTE);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioRouteManagerImpl->SetActiveAudioRoute(route);
+}
+
+AudioRouteInfo
+AudioRouteManager::GetActiveAudioRoute(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_ROUTE);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioRouteManagerImpl->GetActiveAudioRoute();
+
+CATCH:
+       return AudioRouteInfo(INPUT_AUDIO_DEVICE_NONE,OUTPUT_AUDIO_DEVICE_NONE);
+}
+
+};
+};
diff --git a/src/FMediaAudioSessionManager.cpp b/src/FMediaAudioSessionManager.cpp
new file mode 100644 (file)
index 0000000..53c27e9
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License)
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaAudioSessionManager.h>
+#include "FMedia_AudioSessionManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Media
+{
+
+AudioSessionManager::AudioSessionManager(void)
+{
+       __pAudioSessionManagerImpl = _AudioSessionManagerImpl::GetInstance();
+}
+
+AudioSessionManager::~AudioSessionManager(void)
+{
+       if (__pAudioSessionManagerImpl != null)
+       {
+               __pAudioSessionManagerImpl = null;
+       }
+}
+
+AudioSessionManager*
+AudioSessionManager::GetInstance(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_SESSION);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       static AudioSessionManager audioSessionManager;
+       return (&audioSessionManager);
+
+CATCH:
+       return null;
+
+}
+
+result
+AudioSessionManager::SetAudioSessionEventListener(IAudioSessionEventListener* pListener)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_SESSION);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioSessionManagerImpl->SetAudioSessionEventListener(pListener);
+}
+
+result
+AudioSessionManager::SetMode(AudioSessionMode sessionMode)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_SESSION);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioSessionManagerImpl->SetMode(sessionMode);
+}
+
+AudioSessionMode
+AudioSessionManager::GetMode(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_SESSION);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pAudioSessionManagerImpl->GetMode();
+
+CATCH:
+       return (AudioSessionMode) -1;
+}
+
+};
+};
diff --git a/src/FMediaAudioStreamInfo.cpp b/src/FMediaAudioStreamInfo.cpp
new file mode 100644 (file)
index 0000000..a2d41ad
--- /dev/null
@@ -0,0 +1,135 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMediaAudioStreamInfo.h"
+#include "FMediaMediaStreamInfo.h"
+#include "FMedia_AudioStreamInfoImpl.h"
+#include <FBaseSysLog.h>
+#include "stdio.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace Media
+{
+
+AudioStreamInfo::AudioStreamInfo(CodecType codecType, int bitrate, int sampleRate, AudioChannelType channel)
+{
+       __pAudioStreamInfoImpl = new (std::nothrow) _AudioStreamInfoImpl(codecType, bitrate, sampleRate, channel);
+}
+
+AudioStreamInfo::~AudioStreamInfo()
+{
+       if (__pAudioStreamInfoImpl)
+       {
+               delete __pAudioStreamInfoImpl;
+       }
+       __pAudioStreamInfoImpl = null;
+}
+
+AudioStreamInfo::AudioStreamInfo(const AudioStreamInfo& rhs)
+       : Tizen::Base::Object()
+       , __pAudioStreamInfoImpl(new (std::nothrow) _AudioStreamInfoImpl(*rhs.__pAudioStreamInfoImpl))
+{
+}
+
+AudioStreamInfo&
+AudioStreamInfo::operator =(const AudioStreamInfo & rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+       *__pAudioStreamInfoImpl = *rhs.__pAudioStreamInfoImpl;
+
+       return *this;
+}
+
+bool
+AudioStreamInfo::Equals(const Tizen::Base::Object& rhs) const
+{
+       const AudioStreamInfo* pRhs = dynamic_cast <const AudioStreamInfo*>(&rhs);
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       return __pAudioStreamInfoImpl->Equals(*pRhs->__pAudioStreamInfoImpl);
+}
+
+int
+AudioStreamInfo::GetHashCode(void) const
+{
+       return __pAudioStreamInfoImpl->GetHashCode();
+}
+
+
+CodecType
+AudioStreamInfo::GetCodecType() const
+{
+       if (__pAudioStreamInfoImpl)
+       {
+               return __pAudioStreamInfoImpl->GetCodecType();
+       }
+       else
+       {
+               return CODEC_NONE;
+       }
+}
+
+int
+AudioStreamInfo::GetBitRate() const
+{
+       if (__pAudioStreamInfoImpl)
+       {
+               return __pAudioStreamInfoImpl->GetBitRate();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+int
+AudioStreamInfo::GetSampleRate() const
+{
+       if (__pAudioStreamInfoImpl)
+       {
+               return __pAudioStreamInfoImpl->GetSampleRate();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+AudioChannelType
+AudioStreamInfo::GetChannelType() const
+{
+       if (__pAudioStreamInfoImpl)
+       {
+               return __pAudioStreamInfoImpl->GetChannelType();
+       }
+       else
+       {
+               return AUDIO_CHANNEL_TYPE_NONE;
+       }
+}
+
+};
+};
diff --git a/src/FMediaCamera.cpp b/src/FMediaCamera.cpp
new file mode 100755 (executable)
index 0000000..82247f2
--- /dev/null
@@ -0,0 +1,1057 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                FMediaCamera.cpp
+* @brief               This file contains the implementation of subsystem's Camera.
+*/
+
+#include <FMediaCamera.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMedia_CameraImpl.h"
+
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Media
+{
+
+Camera::Camera()
+       : __pImpl(null)
+{
+
+}
+
+Camera::~Camera()
+{
+       if (__pImpl != null)
+       {
+               delete __pImpl;
+       }
+}
+
+result
+Camera::Construct(ICameraEventListener& listener, CameraSelection camSel)
+{
+       SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       // Create impl
+       _CameraImpl* pImpl = new (std::nothrow) _CameraImpl();
+       SysTryCatch(NID_MEDIA, pImpl !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       r = pImpl->Construct(listener, camSel);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pImpl = pImpl;
+       return r;
+
+CATCH:
+       if (pImpl != null)
+       {
+               delete pImpl;
+               pImpl = null;
+       }
+       return r;
+}
+
+result
+Camera::PowerOn(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->PowerOn();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Camera::PowerOff(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->PowerOff();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+bool
+Camera::IsPoweredOn(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       bool powerStatus = false;
+       ClearLastResult();
+
+       powerStatus = __pImpl->IsPoweredOn();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return powerStatus;
+
+CATCH:
+       return false;
+}
+
+result
+Camera::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo, bool previewedData)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->StartPreview(pBufferInfo, previewedData);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Camera::StopPreview(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->StopPreview();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Camera::Capture(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Capture();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraState
+Camera::GetState(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       ClearLastResult();
+
+       state = __pImpl->GetState();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return state;
+
+CATCH:
+       return (CameraState) MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::SetBrightness(int brightness)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetBrightness(brightness);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+Camera::GetBrightness(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       int brightness = 0;
+       ClearLastResult();
+
+       brightness = __pImpl->GetBrightness();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return brightness;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+
+}
+
+result
+Camera::SetContrast(int contrast)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetContrast(contrast);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+Camera::GetContrast(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       int contrast = 0;
+       ClearLastResult();
+
+       contrast = __pImpl->GetContrast();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return contrast;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::ZoomIn(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->ZoomIn();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Camera::ZoomOut(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->ZoomOut();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+Camera::GetMaxZoomLevel(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       int maxZoomLevel = 0;
+       ClearLastResult();
+
+       maxZoomLevel = __pImpl->GetMaxZoomLevel();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return maxZoomLevel;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+int
+Camera::GetZoomLevel(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       int zoomLevel = 0;
+       ClearLastResult();
+
+       zoomLevel = __pImpl->GetZoomLevel();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return zoomLevel;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::SetPreviewResolution(const Tizen::Graphics::Dimension& resolution)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetPreviewResolution(resolution);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+Tizen::Graphics::Dimension
+Camera::GetPreviewResolution(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       Dimension dim;
+       ClearLastResult();
+
+       dim = __pImpl->GetPreviewResolution();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return dim;
+
+CATCH:
+       return Dimension(0, 0);
+}
+
+Tizen::Base::Collection::IList*
+Camera::GetSupportedPreviewResolutionListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       IList* pList = null;
+       ClearLastResult();
+
+       pList = __pImpl->GetSupportedPreviewResolutionListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+
+CATCH:
+       if (pList != null)
+       {
+               pList->RemoveAll(true);
+               delete pList;
+       }
+
+       return null;
+}
+
+
+result
+Camera::SetCaptureResolution(const Tizen::Graphics::Dimension& resolution)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetCaptureResolution(resolution);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+Tizen::Graphics::Dimension
+Camera::GetCaptureResolution(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       Dimension dim;
+       ClearLastResult();
+
+       dim = __pImpl->GetCaptureResolution();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return dim;
+
+CATCH:
+       return Dimension(0, 0);
+}
+
+Tizen::Base::Collection::IList*
+Camera::GetSupportedCaptureResolutionListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       IList* pList = null;
+       ClearLastResult();
+
+       pList = __pImpl->GetSupportedCaptureResolutionListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+
+CATCH:
+       if (pList != null)
+       {
+               pList->RemoveAll(true);
+               delete pList;
+       }
+
+       return null;
+}
+
+
+result
+Camera::SetEffect(CameraEffect effect)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetEffect(effect);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraEffect
+Camera::GetEffect(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraEffect effect = CAMERA_EFFECT_NONE;
+       ClearLastResult();
+
+       effect = __pImpl->GetEffect();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return effect;
+
+CATCH:
+       return (CameraEffect) MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::SetFlashMode(CameraFlashMode flashMode)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetFlashMode(flashMode);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraFlashMode
+Camera::GetFlashMode(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraFlashMode flashMode = CAMERA_FLASH_MODE_OFF;
+       ClearLastResult();
+
+       flashMode = __pImpl->GetFlashMode();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return flashMode;
+
+CATCH:
+       return CAMERA_FLASH_MODE_OFF;
+}
+
+result
+Camera::SetExposure(int exposure)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetExposure(exposure);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+Camera::GetExposure(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       int exposure = 0;
+       ClearLastResult();
+
+       exposure = __pImpl->GetExposure();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return exposure;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+
+}
+
+result
+Camera::SetWhiteBalance(CameraWhiteBalance whiteBalance)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetWhiteBalance(whiteBalance);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+CameraWhiteBalance
+Camera::GetWhiteBalance(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraWhiteBalance wb = CAMERA_WHITE_BALANCE_AUTO;
+       ClearLastResult();
+
+       wb = __pImpl->GetWhiteBalance();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return wb;
+
+CATCH:
+       return (CameraWhiteBalance) MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::SetQuality(CameraQuality quality)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetQuality(quality);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraQuality
+Camera::GetQuality(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraQuality quality = CAMERA_QUALITY_NORMAL;
+       ClearLastResult();
+
+       quality = __pImpl->GetQuality();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return quality;
+
+CATCH:
+       return (CameraQuality) MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::SetFocusMode(CameraFocusMode focusMode)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetFocusMode(focusMode);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraFocusMode
+Camera::GetFocusMode(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraFocusMode mode = CAMERA_FOCUS_MODE_NONE;
+       ClearLastResult();
+
+       mode = __pImpl->GetFocusMode();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return mode;
+
+CATCH:
+       return CAMERA_FOCUS_MODE_NONE;
+}
+
+
+result
+Camera::SetAutoFocus(bool autoFocus)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetAutoFocus(autoFocus);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Camera::SetAutoFocusPoint(const Tizen::Base::Collection::IList& pointList)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetAutoFocusPoint(pointList);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+Tizen::Base::Collection::IList*
+Camera::GetAutoFocusPointN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::IList* pList = null;
+       ClearLastResult();
+
+       pList = __pImpl->GetAutoFocusPointN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+
+CATCH:
+       return null;
+}
+
+result
+Camera::SetCaptureFormat(const Tizen::Graphics::PixelFormat format)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetCaptureFormat(format);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+Tizen::Graphics::PixelFormat
+Camera::GetCaptureFormat(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       PixelFormat format = PIXEL_FORMAT_JPEG;
+       ClearLastResult();
+
+       format = __pImpl->GetCaptureFormat();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return format;
+
+CATCH:
+       return (PixelFormat) MEDIA_INVALID_VALUE;
+}
+
+
+Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>*
+Camera::GetSupportedCaptureFormatListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       IListT <PixelFormat>* pListT = null;
+       ClearLastResult();
+
+       pListT = __pImpl->GetSupportedCaptureFormatListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pListT;
+
+CATCH:
+       if (pListT != null)
+       {
+               pListT->RemoveAll();
+               delete pListT;
+       }
+
+       return null;
+}
+
+result
+Camera::SetPreviewFormat(const Tizen::Graphics::PixelFormat format)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetPreviewFormat(format);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+Tizen::Graphics::PixelFormat
+Camera::GetPreviewFormat(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       PixelFormat format = PIXEL_FORMAT_YCbCr420_PLANAR;
+       ClearLastResult();
+
+       format = __pImpl->GetPreviewFormat();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return format;
+
+CATCH:
+       return (PixelFormat) MEDIA_INVALID_VALUE;
+}
+
+
+Tizen::Base::Collection::IListT <Tizen::Graphics::PixelFormat>*
+Camera::GetSupportedPreviewFormatListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       IListT <PixelFormat>* pListT = null;
+       ClearLastResult();
+
+       pListT = __pImpl->GetSupportedPreviewFormatListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pListT;
+
+CATCH:
+       if (pListT != null)
+       {
+               pListT->RemoveAll();
+               delete pListT;
+       }
+
+       return null;
+
+}
+
+result
+Camera::SetIsoLevel(CameraIsoLevel isoLevel)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetIsoLevel(isoLevel);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraIsoLevel
+Camera::GetIsoLevel(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraIsoLevel isoLevel = CAMERA_ISO_DEFAULT;
+       ClearLastResult();
+
+       isoLevel = __pImpl->GetIsoLevel();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return isoLevel;
+
+CATCH:
+       return (CameraIsoLevel) MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::SetPreviewFrameRate(int fps)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetPreviewFrameRate(fps);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+Camera::GetPreviewFrameRate(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       int fps = 0;
+       ClearLastResult();
+
+       fps = __pImpl->GetPreviewFrameRate();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return fps;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+Tizen::Base::Collection::IListT <int>*
+Camera::GetSupportedPreviewFrameRateListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       IListT <int>* pListT = null;
+       ClearLastResult();
+
+       pListT = __pImpl->GetSupportedPreviewFrameRateListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pListT;
+
+CATCH:
+       if (pListT != null)
+       {
+               pListT->RemoveAll();
+               delete pListT;
+       }
+
+       return null;
+}
+
+Tizen::Base::Collection::IListT <int>*
+Camera::GetSupportedPreviewFrameRateListN(const Tizen::Graphics::Dimension& dim) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       IListT <int>* pListT = null;
+       ClearLastResult();
+
+       pListT = __pImpl->GetSupportedPreviewFrameRateListN(dim);
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pListT;
+
+CATCH:
+       if (pListT != null)
+       {
+               pListT->RemoveAll();
+               delete pListT;
+       }
+
+       return null;
+}
+
+
+result
+Camera::SetExifOrientation(CameraExifOrientation orientation)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetExifOrientation(orientation);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Camera::SetExifGpsCoordinates(double latitude, double longitude, float altitude)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetExifGpsCoordinates(latitude, longitude, altitude);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Camera::DisableExifGpsCoordinates(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->DisableExifGpsCoordinates();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Camera::SetFlip(CameraFlipType flip)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetFlip(flip);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraFlipType
+Camera::GetFlip(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraFlipType flip = CAMERA_FLIP_NONE;
+       ClearLastResult();
+
+       flip = __pImpl->GetFlip();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return flip;
+
+CATCH:
+       return (CameraFlipType) MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::SetPreviewRotation(CameraRotation rotation)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetPreviewRotation(rotation);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraRotation
+Camera::GetPreviewRotation(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraRotation rotation = CAMERA_ROTATION_NONE;
+       ClearLastResult();
+
+       rotation = __pImpl->GetPreviewRotation();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return rotation;
+
+CATCH:
+       return (CameraRotation) MEDIA_INVALID_VALUE;
+}
+
+result
+Camera::SetMeteringMode(CameraMeteringMode meteringMode)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_CAMERA);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetMeteringMode(meteringMode);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+CameraMeteringMode
+Camera::GetMeteringMode(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       CameraMeteringMode mode = CAMERA_METERING_MODE_NONE;
+       ClearLastResult();
+
+       mode = __pImpl->GetMeteringMode();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return mode;
+
+CATCH:
+       return CAMERA_METERING_MODE_NONE;
+}
+
+}}// Tizen::Media
diff --git a/src/FMediaCapability.cpp b/src/FMediaCapability.cpp
new file mode 100644 (file)
index 0000000..1ebe6fa
--- /dev/null
@@ -0,0 +1,221 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                FMediaCapability.cpp
+* @brief       This file contains the implementation of subsystem's Camera.
+*/
+
+#include <FMediaCapability.h>
+#include <FMediaCameraTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_CapabilityImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+const wchar_t* const AUDIOIN_SAMPLE_RATE = L"AudioIn.SampleRate";
+const wchar_t* const AUDIOIN_SAMPLE_TYPE = L"AudioIn.SampleType";
+
+const wchar_t* const AUDIOOUT_COUNT_MAX = L"AudioOut.CountMax";
+const wchar_t* const AUDIOOUT_SAMPLE_RATE = L"AudioOut.SampleRate";
+const wchar_t* const AUDIOOUT_SAMPLE_TYPE = L"AudioOut.SampleType";
+
+const wchar_t* const AUDIORECORDER_FORMAT = L"AudioRecorder.Format";
+
+const wchar_t* const CAMERA_COUNT = L"Camera.Count";
+const wchar_t* const CAMERA_PRIMARY_CAPTURE_FORMAT = L"Camera.Primary.CaptureFormat";
+const wchar_t* const CAMERA_PRIMARY_CAPTURE_RESOLUTION = L"Camera.Primary.CaptureResolution";
+const wchar_t* const CAMERA_PRIMARY_DIRECTION = L"Camera.Primary.Direction";
+const wchar_t* const CAMERA_PRIMARY_EFFECT = L"Camera.Primary.Effect";
+const wchar_t* const CAMERA_PRIMARY_ISO_LEVEL = L"Camera.Primary.IsoLevel";
+const wchar_t* const CAMERA_PRIMARY_PREVIEW_FORMAT = L"Camera.Primary.PreviewFormat";
+const wchar_t* const CAMERA_PRIMARY_PREVIEW_FRAMERATE = L"Camera.Primary.PreviewFrameRate";
+const wchar_t* const CAMERA_PRIMARY_PREVIEW_RESOLUTION = L"Camera.Primary.PreviewResolution";
+const wchar_t* const CAMERA_PRIMARY_RECORDING_RESOLUTION = L"Camera.Primary.RecordingResolution";
+const wchar_t* const CAMERA_PRIMARY_ROTATION = L"Camera.Primary.Rotation";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_BRIGHTNESS = L"Camera.Primary.SupportBrightness";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_CAPTURE = L"Camera.Primary.SupportCapture";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_CONTRAST = L"Camera.Primary.SupportContrast";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_EXPOSURE = L"Camera.Primary.SupportExposure";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_FLASH = L"Camera.Primary.SupportFlash";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_FOCUS = L"Camera.Primary.SupportFocus";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_PREVIEW = L"Camera.Primary.SupportPreview";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_RECORDING = L"Camera.Primary.SupportRecording";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_ZOOM = L"Camera.Primary.SupportZoom";
+const wchar_t* const CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG = L"Camera.Primary.SupportZeroShutterLag";
+const wchar_t* const CAMERA_PRIMARY_WHITE_BALANCE = L"Camera.Primary.WhiteBalance";
+const wchar_t* const CAMERA_PRIMARY_ZOOM_TYPE = L"Camera.Primary.ZoomType";
+const wchar_t* const CAMERA_PRIMARY_FLIP = L"Camera.Primary.Flip";
+const wchar_t* const CAMERA_PRIMARY_PREVIEW_ROTATION = L"Camera.Primary.PreviewRotation";
+const wchar_t* const CAMERA_PRIMARY_FOCUS_MODE = L"Camera.Primary.FocusMode";
+const wchar_t* const CAMERA_PRIMARY_FOCUS_POINT = L"Camera.Primary.FocusPoint";
+const wchar_t* const CAMERA_PRIMARY_FLASH_MODE = L"Camera.Primary.FlashMode";
+const wchar_t* const CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT = L"Camera.Primary.DefaultPreviewFormat";
+const wchar_t* const CAMERA_PRIMARY_METERING_MODE = L"Camera.Primary.MeteringMode";
+
+const wchar_t* const CAMERA_SECONDARY_CAPTURE_FORMAT = L"Camera.Secondary.CaptureFormat";
+const wchar_t* const CAMERA_SECONDARY_CAPTURE_RESOLUTION = L"Camera.Secondary.CaptureResolution";
+const wchar_t* const CAMERA_SECONDARY_DIRECTION = L"Camera.Secondary.Direction";
+const wchar_t* const CAMERA_SECONDARY_EFFECT = L"Camera.Secondary.Effect";
+const wchar_t* const CAMERA_SECONDARY_ISO_LEVEL = L"Camera.Secondary.IsoLevel";
+const wchar_t* const CAMERA_SECONDARY_PREVIEW_FORMAT = L"Camera.Secondary.PreviewFormat";
+const wchar_t* const CAMERA_SECONDARY_PREVIEW_FRAMERATE = L"Camera.Secondary.PreviewFrameRate";
+const wchar_t* const CAMERA_SECONDARY_PREVIEW_RESOLUTION = L"Camera.Secondary.PreviewResolution";
+const wchar_t* const CAMERA_SECONDARY_RECORDING_RESOLUTION = L"Camera.Secondary.RecordingResolution";
+const wchar_t* const CAMERA_SECONDARY_ROTATION = L"Camera.Secondary.Rotation";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_BRIGHTNESS = L"Camera.Secondary.SupportBrightness";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_CAPTURE = L"Camera.Secondary.SupportCapture";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_CONTRAST = L"Camera.Secondary.SupportContrast";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_EXPOSURE = L"Camera.Secondary.SupportExposure";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_FLASH = L"Camera.Secondary.SupportFlash";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_FOCUS = L"Camera.Secondary.SupportFocus";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_PREVIEW = L"Camera.Secondary.SupportPreview";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_RECORDING = L"Camera.Secondary.SupportRecording";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_ZOOM = L"Camera.Secondary.SupportZoom";
+const wchar_t* const CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG = L"Camera.Secondary.SupportZeroShutterLag";
+const wchar_t* const CAMERA_SECONDARY_WHITE_BALANCE = L"Camera.Secondary.WhiteBalance";
+const wchar_t* const CAMERA_SECONDARY_ZOOM_TYPE = L"Camera.Secondary.ZoomType";
+const wchar_t* const CAMERA_SECONDARY_FLIP = L"Camera.Secondary.Flip";
+const wchar_t* const CAMERA_SECONDARY_PREVIEW_ROTATION = L"Camera.Secondary.PreviewRotation";
+const wchar_t* const CAMERA_SECONDARY_FOCUS_MODE = L"Camera.Secondary.FocusMode";
+const wchar_t* const CAMERA_SECONDARY_FOCUS_POINT = L"Camera.Secondary.FocusPoint";
+const wchar_t* const CAMERA_SECONDARY_FLASH_MODE = L"Camera.Secondary.FlashMode";
+const wchar_t* const CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT = L"Camera.Secondary.DefaultPreviewFormat";
+const wchar_t* const CAMERA_SECONDARY_METERING_MODE = L"Camera.Secondary.MeteringMode";
+
+const wchar_t* const PLAYER_AUDIO_CODEC = L"Player.AudioCodec";
+const wchar_t* const PLAYER_COUNT_MAX = L"Player.CountMax";
+const wchar_t* const PLAYER_PROTOCOL = L"Player.Protocol";
+const wchar_t* const PLAYER_VIDEO_CODEC = L"Player.VideoCodec";
+const wchar_t* const PLAYER_VIDEO_HEIGHT = L"Player.VideoHeight";
+const wchar_t* const PLAYER_VIDEO_WIDTH = L"Player.VideoWidth";
+
+const wchar_t* const VIDEORECORDER_AUDIO_CODEC = L"VideoRecorder.AudioCodec";
+const wchar_t* const VIDEORECORDER_FORMAT = L"VideoRecorder.Format";
+const wchar_t* const VIDEORECORDER_VIDEO_CODEC = L"VideoRecorder.VideoCodec";
+
+MediaCapability::MediaCapability()
+:__pImpl(null)
+{
+}
+
+MediaCapability::~MediaCapability()
+{
+}
+
+result
+MediaCapability::GetValue(const Tizen::Base::String& key, bool& value)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+       _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
+
+       SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
+
+       return pImpl->GetValue(key, value);
+
+CATCH:
+       return r;
+}
+
+result
+MediaCapability::GetValue(const Tizen::Base::String& key, int& value)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+       _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
+       SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
+
+       return pImpl->GetValue(key, value);
+CATCH:
+       return r;
+}
+
+result
+MediaCapability::GetValue(const Tizen::Base::String& key, long long& value)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+       _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
+       SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
+
+       return pImpl->GetValue(key, value);
+CATCH:
+       return r;
+}
+
+result
+MediaCapability::GetValue(const Tizen::Base::String& key, double& value)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+       _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
+       SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
+
+       return pImpl->GetValue(key, value);
+CATCH:
+       return r;
+}
+
+result
+MediaCapability::GetValue(const Tizen::Base::String& key, Tizen::Base::String& value)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+       _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
+       SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
+
+       return pImpl->GetValue(key, value);
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IList*
+MediaCapability::GetValueN(const Tizen::Base::String& key)
+{
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::ArrayList* pList = null;
+       ClearLastResult();
+
+       _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
+       SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
+
+       pList = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+       SysTryCatch(NID_MEDIA, pList !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pImpl->GetValueN(key, *pList);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+
+CATCH:
+       if (pList != null)
+       {
+               delete pList;
+       }
+
+       return null;
+}
+
+
+}}// Tizen::Media
diff --git a/src/FMediaMediaStreamInfo.cpp b/src/FMediaMediaStreamInfo.cpp
new file mode 100644 (file)
index 0000000..b5aad03
--- /dev/null
@@ -0,0 +1,200 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file               FMediaMediaStreamInfo.cpp
+// @brief              This file contains the implementation of media stream information
+//
+
+#include <stdio.h>
+#include <FMediaMediaStreamInfo.h>
+#include <FBaseSysLog.h>
+#include "FMedia_MediaStreamInfoImpl.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+MediaStreamInfo::MediaStreamInfo(const Tizen::Base::String& title, const Tizen::Base::String& artist, const Tizen::Base::String& albumTitle, const Tizen::Base::String& genre, int year, Tizen::Base::ByteBuffer* pAlbumArt, Tizen::Base::Collection::IList* pAudioStream, Tizen::Base::Collection::IList* pVideoStream, result audioStreamException, result videoStreamException)
+{
+       __pMediaStreamInfoImpl = new  (std::nothrow) _MediaStreamInfoImpl(title, artist, albumTitle, genre, year, pAlbumArt, pAudioStream, pVideoStream, audioStreamException, videoStreamException);
+}
+
+MediaStreamInfo::~MediaStreamInfo()
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               delete __pMediaStreamInfoImpl;
+       }
+       __pMediaStreamInfoImpl = null;
+}
+
+//sicne 3.0
+MediaStreamInfo::MediaStreamInfo(const MediaStreamInfo& rhs)
+       : Tizen::Base::Object()
+{
+       __pMediaStreamInfoImpl = new (std::nothrow) _MediaStreamInfoImpl(*rhs.__pMediaStreamInfoImpl);
+}
+
+//since 3.0
+MediaStreamInfo&
+MediaStreamInfo::operator =(const MediaStreamInfo & rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+       if (__pMediaStreamInfoImpl )
+       {
+               delete __pMediaStreamInfoImpl;
+               __pMediaStreamInfoImpl = null;
+       }
+       __pMediaStreamInfoImpl = new (std::nothrow) _MediaStreamInfoImpl(*rhs.__pMediaStreamInfoImpl);
+
+       return *this;
+}
+
+//since 3.0
+bool
+MediaStreamInfo::Equals(const Tizen::Base::Object& rhs) const
+{
+       const MediaStreamInfo* pRhs = dynamic_cast <const MediaStreamInfo*>(&rhs);
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       return __pMediaStreamInfoImpl->Equals(*pRhs->__pMediaStreamInfoImpl);
+}
+
+//since 3.0
+int
+MediaStreamInfo::GetHashCode(void) const
+{
+       return __pMediaStreamInfoImpl->GetHashCode();
+}
+
+
+String
+MediaStreamInfo::GetTitle() const
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               return __pMediaStreamInfoImpl->GetTitle();
+       }
+       else
+       {
+               return String("");
+       }
+}
+
+String
+MediaStreamInfo::GetArtist(void) const
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               return __pMediaStreamInfoImpl->GetArtist();
+       }
+       else
+       {
+               return String("");
+       }
+}
+
+String
+MediaStreamInfo::GetAlbumTitle(void) const
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               return __pMediaStreamInfoImpl->GetAlbumTitle();
+       }
+       else
+       {
+               return String("");
+       }
+}
+
+int
+MediaStreamInfo::GetYear(void) const
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               return __pMediaStreamInfoImpl->GetYear();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+String
+MediaStreamInfo::GetGenre(void) const
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               return __pMediaStreamInfoImpl->GetGenre();
+       }
+       else
+       {
+               return String("");
+       }
+}
+
+ByteBuffer*
+MediaStreamInfo::GetAlbumArtN(void) const
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               return __pMediaStreamInfoImpl->GetAlbumArtN();
+       }
+       else
+       {
+               return null;
+       }
+}
+
+const IList*
+MediaStreamInfo::GetAudioStreamInfoList() const
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               return __pMediaStreamInfoImpl->GetAudioStreamInfoList();
+       }
+       else
+       {
+               return null;
+       }
+}
+
+const IList*
+MediaStreamInfo::GetVideoStreamInfoList() const
+{
+       if (__pMediaStreamInfoImpl)
+       {
+               return __pMediaStreamInfoImpl->GetVideoStreamInfoList();
+       }
+       else
+       {
+               return null;
+       }
+}
+
+};
+};
diff --git a/src/FMediaPlayer.cpp b/src/FMediaPlayer.cpp
new file mode 100644 (file)
index 0000000..6573112
--- /dev/null
@@ -0,0 +1,465 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMediaPlayer.cpp
+// @brief              This file contains the implementation of subsystem's Player.
+//
+
+#include <stdio.h>
+#include <FMediaPlayer.h>
+#include <FMediaMediaStreamInfo.h>
+#include <FBaseSysLog.h>
+#include "FMedia_PlayerEvent.h"
+#include "FMedia_PlayerVideoEvent.h"
+#include "FMedia_PlayerEventTypes.h"
+#include "FMedia_PlayerVideoEventTypes.h"
+#include "FMedia_PlayerImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+Player::Player(void)
+       : __pPlayerImpl(null)
+{
+}
+
+Player::~Player(void)
+{
+       if (__pPlayerImpl)
+       {
+               delete __pPlayerImpl;
+               __pPlayerImpl = null;
+       }
+
+}
+
+result
+Player::Construct(IPlayerEventListener& listener, const Tizen::Graphics::BufferInfo* pBufferInfo)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+
+       SysAssertf(__pPlayerImpl == null,
+                                                                               "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
+
+       // Create PlayerImpl instance
+       _PlayerImpl* pPlayerImpl = new (std::nothrow) _PlayerImpl();
+       SysTryCatch(NID_MEDIA, pPlayerImpl, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = pPlayerImpl->Construct(listener,pBufferInfo);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct pPlayerImple.", GetErrorMessage(r));
+
+       __pPlayerImpl = pPlayerImpl;
+
+       return r;
+
+CATCH:
+       // Delete PlayerImpl instance
+       if (pPlayerImpl)
+       {
+               delete pPlayerImpl;
+               pPlayerImpl = null;
+       }
+
+       return r;
+
+}
+
+result
+Player::Construct(IPlayerEventListener& listener,IPlayerVideoEventListener& videoListener)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl == null,
+                                                                               "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
+
+       // Create PlayerImpl instance
+       _PlayerImpl* pPlayerImpl = new (std::nothrow) _PlayerImpl();
+       SysTryCatch(NID_MEDIA, pPlayerImpl, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = pPlayerImpl->Construct(listener, videoListener, (void*) this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct pPlayerImpl.", GetErrorMessage(r));
+
+       __pPlayerImpl = pPlayerImpl;
+
+       return r;
+
+CATCH:
+       // Delete PlayerImpl instance
+       if (pPlayerImpl)
+       {
+               delete pPlayerImpl;
+               pPlayerImpl = null;
+       }
+
+       return r;
+
+}
+
+result
+Player::Construct(IPlayerEventListener& listener, Tizen::Graphics::Opengl::VideoTexture& videoTexture)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+       SysAssertf(__pPlayerImpl == null,
+                                                                               "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
+       // Create PlayerImpl instance
+       _PlayerImpl* pPlayerImpl = new (std::nothrow) _PlayerImpl();
+       SysTryCatch(NID_MEDIA, pPlayerImpl, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = pPlayerImpl->Construct(listener, videoTexture);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct pPlayerImpl.", GetErrorMessage(r));
+
+       __pPlayerImpl = pPlayerImpl;
+       return r;
+
+CATCH:
+       // Delete PlayerImpl instance
+       if (pPlayerImpl)
+       {
+               delete pPlayerImpl;
+               pPlayerImpl = null;
+       }
+
+       return r;
+
+}
+
+result
+Player::OpenFile(const Tizen::Base::String& mediaLocalPath, bool isAync)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->OpenFile(mediaLocalPath, isAync);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform OpenFile operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Player::OpenUrl(const Tizen::Base::Utility::Uri& mediaUri, bool isAync)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->OpenUrl(mediaUri, isAync);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform OpenUrl operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Player::OpenBuffer(const Tizen::Base::ByteBuffer& mediaBuffer, bool isAsync)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->OpenBuffer(mediaBuffer, isAsync);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform OpenBuffer operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Player::Close(void)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->Close();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Close operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+Player::Play(void)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->Play();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Play operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+Player::Stop(void)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->Stop();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Stop operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+Player::Pause(void)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->Pause();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Pause operation.", GetErrorMessage(r));
+       return r;
+}
+
+PlayerState
+Player::GetState(void) const
+{
+       PlayerState state = PLAYER_STATE_INITIALIZED;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       state = __pPlayerImpl->GetState();
+       return state;
+}
+
+long
+Player::GetPosition(void) const
+{
+       long position = -1; //MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       position = __pPlayerImpl->GetPosition();
+       return position;
+}
+
+result
+Player::SeekTo(long msTime)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+       r = __pPlayerImpl->SeekTo(msTime);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform SeekTo operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+long
+Player::GetDuration(void) const
+{
+       long duration = 0;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       duration = __pPlayerImpl->GetDuration();
+       return duration;
+}
+
+result
+Player::SetVolume(int volume)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->SetVolume(volume);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform SetVolume operation.", GetErrorMessage(r));
+       return r;
+}
+
+int
+Player::GetVolume(void) const
+{
+       int volume = -1; //MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       volume = __pPlayerImpl->GetVolume();
+       return volume;
+}
+
+result
+Player::SetMute(bool mute)
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->SetMute(mute);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform SetMute operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+bool
+Player::IsMuted(void) const
+{
+       bool muted = false;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       muted = __pPlayerImpl->IsMute();
+       return muted;
+}
+
+result
+Player::SetLooping(bool looping)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->SetLooping(looping);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform SetLooping operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+bool
+Player::IsLooping(void) const
+{
+       bool isLoop = false;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       isLoop = __pPlayerImpl->IsLooping();
+       return isLoop;
+}
+
+MediaStreamInfo*
+Player::GetCurrentMediaStreamInfoN(void) const
+{
+       MediaStreamInfo* pStreamInfo = null;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       pStreamInfo = __pPlayerImpl->GetCurrentMediaStreamInfoN();
+       return pStreamInfo;
+}
+
+
+result
+Player::SetRenderingBuffer(const Tizen::Graphics::BufferInfo& bufferInfo)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       // Set the canvas to subsystem's player
+       r = __pPlayerImpl->SetRenderingBuffer(bufferInfo);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform SetRenderingBuffer operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Player::CaptureVideo(void)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->CaptureVideo();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform CaptureVideo operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Player::SetAudioStreamType(AudioStreamType type)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pPlayerImpl->SetAudioStreamType(type);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform SetAudioStreamType operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+Player::OpenUrlAsync(const Tizen::Base::String& url, const Tizen::Base::Collection::IMap* pHeader)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+       r = __pPlayerImpl->OpenUrlAsync(url, pHeader);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform OpenUrlAsync operation.", GetErrorMessage(r));
+       return r;
+}
+
+result
+Player::OpenUrlAsync(const Tizen::Base::String& url, const Tizen::Base::String& filePath, IPlayerProgressiveDownloadListener& listener, const Tizen::Base::Collection::IMap* pHeader)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+       r = __pPlayerImpl->OpenUrlAsync(this, url, filePath, listener, pHeader);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform OpenUrlAsync operation.", GetErrorMessage(r));
+       return r;
+}
+
+void
+Player::SetProgressiveDownloadIntervalByPercent(int percent)
+{
+       ClearLastResult();
+
+       SysAssertf(__pPlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+       __pPlayerImpl->SetProgressiveDownloadIntervalByPercent(percent);
+}
+
+}}  // Tizen::Media
diff --git a/src/FMediaTone.cpp b/src/FMediaTone.cpp
new file mode 100644 (file)
index 0000000..ab5ab46
--- /dev/null
@@ -0,0 +1,348 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FMediaTone.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+
+namespace Tizen { namespace Media
+{
+
+Tone::Tone()
+{
+       __firstFrequency = 0;
+       __secondFrequency = 0;
+       __duration = 0;
+       __isConstructed = false;
+}
+
+Tone::~Tone()
+{
+
+}
+
+Tone::Tone(const Tone& rhs)
+{
+       __firstFrequency = rhs.__firstFrequency;
+       __secondFrequency = rhs.__secondFrequency;
+       __duration = rhs.__duration;
+       __isConstructed = true;
+}
+
+//Deprecated
+result
+Tone::Construct(int firstFrequency, int secondFrequency, long duration)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       SysTryReturn(NID_MEDIA, (__isConstructed == false ), E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Tone is in an invalid state");
+
+       SysTryReturn(NID_MEDIA, ((firstFrequency >= MIN_FREQUENCY) && (firstFrequency <= MAX_FREQUENCY)), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                          "[E_OUT_OF_RANGE] First frequency is out of range. firstFrequency = %d", firstFrequency);
+
+       SysTryReturn(NID_MEDIA, ((secondFrequency >= MIN_FREQUENCY) && (secondFrequency <= MAX_FREQUENCY)), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                          "[E_OUT_OF_RANGE] Second frequency is out of range. secondFrequency = %d", secondFrequency);
+
+       SysTryReturn(NID_MEDIA, (duration >= MIN_DURATION), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                       "[E_OUT_OF_RANGE] Duration is out of range. duration = %d", duration);
+
+       __isConstructed = true;
+       __firstFrequency = firstFrequency;
+       __secondFrequency = secondFrequency;
+       __duration = duration;
+
+       return r;
+}
+
+//Deprecated
+result
+Tone::Construct(DtmfPreset preset, long duration)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+
+       SysTryReturn(NID_MEDIA, (__isConstructed == false ), E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Tone is in an invalid state");
+
+       SysTryReturn(NID_MEDIA, (duration >= MIN_DURATION), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                       "[E_OUT_OF_RANGE] Duration is out of range. duration = %d", duration);
+
+       switch (preset)
+       {
+       case DTMF_PRESET_0:
+               __firstFrequency = 941;
+               __secondFrequency = 1336;
+               break;
+
+       case DTMF_PRESET_1:
+               __firstFrequency = 697;
+               __secondFrequency = 1209;
+               break;
+
+       case DTMF_PRESET_2:
+               __firstFrequency = 697;
+               __secondFrequency = 1336;
+               break;
+
+       case DTMF_PRESET_3:
+               __firstFrequency = 697;
+               __secondFrequency = 1477;
+               break;
+
+       case DTMF_PRESET_4:
+               __firstFrequency = 770;
+               __secondFrequency = 1209;
+               break;
+
+       case DTMF_PRESET_5:
+               __firstFrequency = 770;
+               __secondFrequency = 1336;
+               break;
+
+       case DTMF_PRESET_6:
+               __firstFrequency = 770;
+               __secondFrequency = 1477;
+               break;
+
+       case DTMF_PRESET_7:
+               __firstFrequency = 852;
+               __secondFrequency = 1209;
+               break;
+
+       case DTMF_PRESET_8:
+               __firstFrequency = 852;
+               __secondFrequency = 1336;
+               break;
+
+       case DTMF_PRESET_9:
+               __firstFrequency = 852;
+               __secondFrequency = 1477;
+               break;
+
+       case DTMF_PRESET_A:
+               __firstFrequency = 697;
+               __secondFrequency = 1633;
+               break;
+
+       case DTMF_PRESET_B:
+               __firstFrequency = 770;
+               __secondFrequency = 1633;
+               break;
+
+       case DTMF_PRESET_C:
+               __firstFrequency = 852;
+               __secondFrequency = 1633;
+               break;
+
+       case DTMF_PRESET_D:
+               __firstFrequency = 941;
+               __secondFrequency = 1633;
+               break;
+
+       case DTMF_PRESET_P:
+               __firstFrequency = 941;
+               __secondFrequency = 1477;
+               break;
+
+       case DTMF_PRESET_S:
+               __firstFrequency = 941;
+               __secondFrequency = 1209;
+               break;
+
+       default:
+               r = E_OUT_OF_RANGE;
+               SysLog(NID_MEDIA,  "[E_OUT_OF_RANGE] The value of DTMF PRESET is %d.", preset);
+               return r;
+               break;
+       }
+
+       __isConstructed = true;
+       __duration = duration;
+
+       return r;
+}
+
+Tone::Tone(int firstFrequency, int secondFrequency, long duration)
+{
+       ClearLastResult();
+
+       __firstFrequency = firstFrequency;
+       __secondFrequency = secondFrequency;
+       __duration = duration;
+       __isConstructed = false;
+       return;
+}
+
+
+Tone::Tone(DtmfPreset preset, long duration)
+{
+       ClearLastResult();
+
+       switch (preset)
+       {
+       case DTMF_PRESET_0:
+               __firstFrequency = 941;
+               __secondFrequency = 1336;
+               break;
+
+       case DTMF_PRESET_1:
+               __firstFrequency = 697;
+               __secondFrequency = 1209;
+               break;
+
+       case DTMF_PRESET_2:
+               __firstFrequency = 697;
+               __secondFrequency = 1336;
+               break;
+
+       case DTMF_PRESET_3:
+               __firstFrequency = 697;
+               __secondFrequency = 1477;
+               break;
+
+       case DTMF_PRESET_4:
+               __firstFrequency = 770;
+               __secondFrequency = 1209;
+               break;
+
+       case DTMF_PRESET_5:
+               __firstFrequency = 770;
+               __secondFrequency = 1336;
+               break;
+
+       case DTMF_PRESET_6:
+               __firstFrequency = 770;
+               __secondFrequency = 1477;
+               break;
+
+       case DTMF_PRESET_7:
+               __firstFrequency = 852;
+               __secondFrequency = 1209;
+               break;
+
+       case DTMF_PRESET_8:
+               __firstFrequency = 852;
+               __secondFrequency = 1336;
+               break;
+
+       case DTMF_PRESET_9:
+               __firstFrequency = 852;
+               __secondFrequency = 1477;
+               break;
+
+       case DTMF_PRESET_A:
+               __firstFrequency = 697;
+               __secondFrequency = 1633;
+               break;
+
+       case DTMF_PRESET_B:
+               __firstFrequency = 770;
+               __secondFrequency = 1633;
+               break;
+
+       case DTMF_PRESET_C:
+               __firstFrequency = 852;
+               __secondFrequency = 1633;
+               break;
+
+       case DTMF_PRESET_D:
+               __firstFrequency = 941;
+               __secondFrequency = 1633;
+               break;
+
+       case DTMF_PRESET_P:
+               __firstFrequency = 941;
+               __secondFrequency = 1477;
+               break;
+
+       case DTMF_PRESET_S:
+               __firstFrequency = 941;
+               __secondFrequency = 1209;
+               break;
+
+       default:
+               __firstFrequency = -1;
+               __secondFrequency = -1;
+               break;
+       }
+
+       __isConstructed = false;
+       __duration = duration;
+       return;
+}
+
+bool
+Tone::Equals(const Object& rhs) const
+{
+       const Tone *pRhs = dynamic_cast<const Tone *>(&rhs);
+       if (!pRhs)
+       {
+               return false;
+       }
+
+       return (((__firstFrequency == pRhs->__firstFrequency) && (__secondFrequency == pRhs->__secondFrequency) && (__duration == pRhs->__duration)) ? true : false);
+}
+
+
+int
+Tone::GetHashCode(void) const
+{
+       int shift = __duration && 0xFF;
+       return ((((__firstFrequency && 0xFFFF) << 16) | (__secondFrequency && 0xFFFF) << shift) | shift);
+}
+
+
+Tone&
+Tone::operator =(const Tone& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       this->__firstFrequency = rhs.__firstFrequency;
+       this->__secondFrequency = rhs.__secondFrequency;
+       this->__duration = rhs.__duration;
+       this->__isConstructed = rhs.__isConstructed;
+
+       return *this;
+
+}
+
+result
+Tone::GetFrequency(int& firstFrequency, int& secondFrequency) const
+{
+       ClearLastResult();
+
+
+       firstFrequency = __firstFrequency;
+       secondFrequency = __secondFrequency;
+
+       return E_SUCCESS;
+}
+
+
+long
+Tone::GetDuration(void) const
+{
+       ClearLastResult();
+
+       return __duration;
+}
+};
+};  //Tizen::Media
diff --git a/src/FMediaTonePlayer.cpp b/src/FMediaTonePlayer.cpp
new file mode 100644 (file)
index 0000000..52aef1a
--- /dev/null
@@ -0,0 +1,209 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FMediaTonePlayer.h>
+#include <FBaseSysLog.h>
+#include <FBaseColIList.h>
+
+#include "FMedia_TonePlayerImpl.h"
+
+namespace Tizen { namespace Media
+{
+
+#define MAX_TONEPLAYER_CAPACITY 16
+
+TonePlayer::TonePlayer()
+       : __pTonePlayerImpl(null)
+{
+}
+
+TonePlayer::~TonePlayer()
+{
+       if (__pTonePlayerImpl)
+       {
+               delete __pTonePlayerImpl;
+       }
+}
+
+result
+TonePlayer::Construct(Tizen::Media::ITonePlayerEventListener& listener)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pTonePlayerImpl == null,
+                                                                               "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
+
+       _TonePlayerImpl* pTonePlayerImpl = new (std::nothrow) _TonePlayerImpl;
+       SysTryCatch(NID_MEDIA, pTonePlayerImpl, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pTonePlayerImpl->Construct(listener, *this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct pTonePlayerImpl.", GetErrorMessage(r));
+
+       __pTonePlayerImpl = pTonePlayerImpl;
+
+       return r;
+
+CATCH:
+       if (pTonePlayerImpl)
+       {
+               delete pTonePlayerImpl;
+               pTonePlayerImpl = null;
+       }
+       return r;
+}
+
+
+result
+TonePlayer::Open(const Tizen::Base::Collection::IList& toneList, int repeatCount)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pTonePlayerImpl->Open(toneList, repeatCount);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Open operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+TonePlayer::Open(const Tizen::Media::Tone& tone, int repeatCount)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pTonePlayerImpl->Open(tone, repeatCount);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Open operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+TonePlayer::SetAudioStreamType(AudioStreamType type)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pTonePlayerImpl->SetAudioStreamType(type);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform SetAudioStreamType operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+TonePlayer::Play(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pTonePlayerImpl->Play();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Play operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+result
+TonePlayer::Stop(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pTonePlayerImpl->Stop();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Stop operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+TonePlayer::Pause(void)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pTonePlayerImpl->Pause();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Pause operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+result
+TonePlayer::Close(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pTonePlayerImpl->Close();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform Close operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+TonePlayer::SetVolume(int volume)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       r = __pTonePlayerImpl->SetVolume(volume);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform SetVolume operation.", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+TonePlayer::GetVolume(void) const
+{
+       ClearLastResult();
+       int volume = 0;
+
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+
+       volume = __pTonePlayerImpl->GetVolume();
+       SysTryReturn(NID_MEDIA,  volume != -1, -1, GetLastResult(), "[%s] Failed to perform GetVolume operation.", GetErrorMessage(GetLastResult()));
+
+       return volume;
+}
+
+
+TonePlayerState
+TonePlayer::GetState(void) const
+{
+       ClearLastResult();
+       SysAssertf(__pTonePlayerImpl !=  null, "Not yet constructed! Construct() should be called before use");
+       return __pTonePlayerImpl->GetState();
+}
+
+
+}}   //Tizen::Media
diff --git a/src/FMediaVideoDecoder.cpp b/src/FMediaVideoDecoder.cpp
new file mode 100644 (file)
index 0000000..daaea92
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseColArrayListT.h>
+#include <FMediaVideoDecoder.h>
+#include <FBaseSysLog.h>
+#include "FMedia_VideoDecoderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace Media
+{
+
+VideoDecoder::VideoDecoder(void)
+{
+       __pImpl = null;
+}
+
+VideoDecoder::~VideoDecoder(void)
+{
+       if (__pImpl != null)
+       {
+               delete __pImpl;
+       }
+}
+
+result
+VideoDecoder::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl == null,
+               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       _VideoDecoderImpl* pVideoDecoderImpl = new (std::nothrow) _VideoDecoderImpl();
+       SysTryCatch(NID_MEDIA, pVideoDecoderImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                         "[E_OUT_OF_MEMORY] Construct Failed ");
+       r = pVideoDecoderImpl->Construct(type, pOption);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagated", GetErrorMessage(r));
+       __pImpl = pVideoDecoderImpl;
+       return E_SUCCESS;
+CATCH:
+       if (pVideoDecoderImpl != null)
+       {
+               delete pVideoDecoderImpl;
+               pVideoDecoderImpl = null;
+       }
+       return r;
+}
+
+result
+VideoDecoder::Probe(const Tizen::Base::ByteBuffer& srcBuf,
+                                       int& width, int& height, MediaPixelFormat& pixelFormat)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->Probe(srcBuf, width, height, pixelFormat);
+}
+
+result
+VideoDecoder::Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf, bool& gotFrame)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       r = __pImpl->Decode(srcBuf, dstBuf, gotFrame);
+       return r;
+}
+
+result
+VideoDecoder::Reset(void)
+{
+       result r = E_SUCCESS;
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       r = __pImpl->Reset();
+       return r;
+}
+
+result
+VideoDecoder::GetValue(MediaPropertyType key, int& value) const
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_MEDIA, __pImpl, E_INVALID_STATE, "not constructed");
+       r = __pImpl->GetValue(key, value);
+       return r;
+}
+
+result
+VideoDecoder::GetValue(MediaPropertyType key, float& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pImpl, E_INVALID_STATE, "not constructed");
+       r = __pImpl->GetValue(key, value);
+
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+VideoDecoder::GetSupportedPropertyListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return  __pImpl->GetSupportedPropertyListN();
+
+}
+
+bool
+VideoDecoder::IsPropertySupported(MediaPropertyType key) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->IsPropertySupported(key);
+
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+VideoDecoder::GetSupportedCodecListN(void)
+{
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::IListT<CodecType> *pList = null;
+
+       pList = _VideoDecoderImpl::GetSupportedCodecListN();
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, pList != null, null, r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+}}  // Tizen::Media
diff --git a/src/FMediaVideoEncoder.cpp b/src/FMediaVideoEncoder.cpp
new file mode 100644 (file)
index 0000000..e5ed804
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseColArrayListT.h>
+#include <FMediaVideoEncoder.h>
+#include <FBaseSysLog.h>
+#include "FMedia_VideoEncoderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace Media
+{
+
+VideoEncoder::VideoEncoder(void)
+{
+       __pImpl = null;
+}
+
+VideoEncoder::~VideoEncoder(void)
+{
+       if (__pImpl != null)
+       {
+               delete __pImpl;
+       }
+}
+
+result
+VideoEncoder::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl == null,
+               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       _VideoEncoderImpl* pVideoEncoderImpl = new (std::nothrow) _VideoEncoderImpl();
+       SysTryCatch(NID_MEDIA, pVideoEncoderImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                         "[%s] Memory Allocation Failed ", GetErrorMessage(E_OUT_OF_MEMORY));\r
+       r = pVideoEncoderImpl->Construct(type, pOption);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct _VideoEncoderImpl", GetErrorMessage(r));\r
+       __pImpl = pVideoEncoderImpl;
+       return E_SUCCESS;
+
+CATCH:
+       if (pVideoEncoderImpl != null)
+       {
+               delete pVideoEncoderImpl;
+               pVideoEncoderImpl = null;
+       }
+       return r;
+}
+
+result
+VideoEncoder::Encode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       r = __pImpl->Encode(srcBuf, dstBuf);
+
+       return r;
+}
+
+result
+VideoEncoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       r = __pImpl->Reset();
+
+       return r;
+}
+
+result
+VideoEncoder::SetValue(MediaPropertyType key, int value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pImpl, E_INVALID_STATE, "not constructed");
+       r = __pImpl->SetValue(key, value);
+
+       return r;
+}
+
+
+result
+VideoEncoder::SetValue(MediaPropertyType key, bool value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pImpl, E_INVALID_STATE, "not constructed");
+       r = __pImpl->SetValue(key, value);
+
+       return r;
+}
+
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+VideoEncoder::GetSupportedPropertyListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->GetSupportedPropertyListN();
+}
+
+
+bool
+VideoEncoder::IsPropertySupported(MediaPropertyType key) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       return __pImpl->IsPropertySupported(key);
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+VideoEncoder::GetSupportedCodecListN(void)
+{
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::IListT<CodecType> *pList = null;
+
+       pList = _VideoEncoderImpl::GetSupportedCodecListN();
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, pList != null, null, r, "[%s] Propagating", GetErrorMessage(r));
+
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+
+}} // Tizen::Media
diff --git a/src/FMediaVideoFrameExtractor.cpp b/src/FMediaVideoFrameExtractor.cpp
new file mode 100644 (file)
index 0000000..bb80e28
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <FMediaVideoFrameExtractor.h>
+#include <FMedia_VideoFrameExtractorImpl.h>
+#include <FBaseSysLog.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media {
+
+VideoFrameExtractor::VideoFrameExtractor(void)
+       :__pImpl(null)
+{
+}
+
+VideoFrameExtractor::~VideoFrameExtractor(void)
+{
+
+       if (__pImpl != null)
+       {
+               delete __pImpl;
+               __pImpl = null;
+        }
+}
+
+result
+VideoFrameExtractor::Construct(const Tizen::Base::String &filePath, MediaPixelFormat pixelFormat)
+{
+       result r = E_SUCCESS;
+       _VideoFrameExtractorImpl* pVideoFrameExtractorImpl = null;
+
+       SysAssertf(__pImpl == null,
+               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturn(NID_MEDIA, !filePath.IsEmpty(), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+               "[%s] Propagating.", GetErrorMessage(E_FILE_NOT_FOUND));
+
+       pVideoFrameExtractorImpl = new (std::nothrow) _VideoFrameExtractorImpl();
+       SysTryReturnResult(NID_MEDIA, pVideoFrameExtractorImpl != null, E_OUT_OF_MEMORY, "Create instance failed.");
+
+       r = pVideoFrameExtractorImpl->Construct(filePath, pixelFormat);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , GetLastResult(),
+                       "[%s] Failed to Construct pVideoFrameExtractorImpl.", GetErrorMessage(GetLastResult()));
+
+       __pImpl = pVideoFrameExtractorImpl;
+
+       return E_SUCCESS;
+
+CATCH:
+       delete pVideoFrameExtractorImpl;
+       pVideoFrameExtractorImpl = null;
+
+       return r;
+}
+
+
+int
+VideoFrameExtractor::GetWidth(void) const
+{
+       SysAssertf(__pImpl != null,
+               "Not yet constructed. Construct() should be called before use.");
+
+       return __pImpl->GetWidth();
+}
+
+int
+VideoFrameExtractor::GetHeight(void) const
+{
+       SysAssertf(__pImpl != null,
+               "Not yet constructed. Construct() should be called before use.");
+
+       return __pImpl->GetHeight();
+
+}
+
+long
+VideoFrameExtractor::GetDuration(void) const
+{
+       SysAssertf(__pImpl != null,
+               "Not yet constructed. Construct() should be called before use.");
+
+       return __pImpl->GetDuration();
+}
+
+ImageBuffer*
+VideoFrameExtractor::GetFrameN(long timestamp)
+{
+       SysAssertf(__pImpl != null,
+               "Not yet constructed. Construct() should be called before use.");
+
+       return  __pImpl->GetFrameN(timestamp);
+
+}
+
+ImageBuffer*
+VideoFrameExtractor::GetFrameN(const Tizen::Base::String& path, MediaPixelFormat pixelFormat, long timestamp )
+{
+        return _VideoFrameExtractorImpl::GetFrameN(path, pixelFormat, timestamp);
+
+}
+
+}} // Tizen::Media
+
diff --git a/src/FMediaVideoRecorder.cpp b/src/FMediaVideoRecorder.cpp
new file mode 100755 (executable)
index 0000000..85677ff
--- /dev/null
@@ -0,0 +1,643 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                        FMediaVideoRecorder.cpp
+ * @brief                       This is the implementation file for the %VideoRecorder class.
+ */
+
+#include <FMediaVideoRecorder.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMedia_VideoRecorderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Media
+{
+
+VideoRecorder::VideoRecorder(void)
+       : __pImpl(null)
+{
+
+}
+
+VideoRecorder::~VideoRecorder(void)
+{
+       if (__pImpl != null)
+       {
+               delete __pImpl;
+               __pImpl = null;
+       }
+}
+
+result
+VideoRecorder::Construct(IVideoRecorderEventListener& listener, const Camera& camera)
+{
+       SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       result r = E_SUCCESS;
+
+       _VideoRecorderImpl* pImpl = new (std::nothrow) _VideoRecorderImpl();
+       SysTryCatch(NID_MEDIA, pImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       r = pImpl->Construct(listener, camera);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pImpl = pImpl;
+       return r;
+
+CATCH:
+       if (pImpl != null)
+       {
+               delete pImpl;
+               pImpl = null;
+       }
+
+       return r;
+}
+
+result
+VideoRecorder::CreateVideoFile(const Tizen::Base::String& mediaLocalPath, bool overwrite)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->CreateVideoFile(mediaLocalPath, overwrite);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+VideoRecorder::Close(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Close();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+VideoRecorder::Record(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Record();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+VideoRecorder::Stop(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Stop();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+VideoRecorder::Pause(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Pause();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+VideoRecorder::Cancel(void)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->Cancel();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+RecorderState
+VideoRecorder::GetState(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       ClearLastResult();
+
+       state = __pImpl->GetState();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return state;
+
+CATCH:
+       return (RecorderState) MEDIA_INVALID_VALUE;
+}
+
+long
+VideoRecorder::GetRecordingTime(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       long time = MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       time = __pImpl->GetRecordingTime();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return time;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+long
+VideoRecorder::GetRecordingSize(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       long size = MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       size = __pImpl->GetRecordingSize();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return size;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+result
+VideoRecorder::SetMaxRecordingTime(long msTime)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetMaxRecordingTime(msTime);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+long
+VideoRecorder::GetMaxRecordingTime(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       long time = MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       time = __pImpl->GetMaxRecordingTime();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return time;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+result
+VideoRecorder::SetCodec(const Tizen::Base::String& codec)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       String realCodec;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetCodec(codec);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+Tizen::Base::String
+VideoRecorder::GetCodec(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       String codec;
+       ClearLastResult();
+
+       codec = __pImpl->GetCodec();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return codec;
+
+CATCH:
+       codec.Clear();
+       return codec;
+}
+
+Tizen::Base::Collection::IList*
+VideoRecorder::GetSupportedCodecListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::IList* pCodecList = null;
+       ClearLastResult();
+
+       pCodecList = __pImpl->GetSupportedCodecListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+
+       return pCodecList;
+
+CATCH:
+       if (pCodecList != null)
+       {
+               pCodecList->RemoveAll(true);
+               delete pCodecList;
+       }
+
+       return null;
+}
+
+result
+VideoRecorder::SetFormat(VideoRecordingFormat format)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetFormat(format);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+VideoRecordingFormat
+VideoRecorder::GetFormat(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       VideoRecordingFormat format = VIDEORECORDING_FORMAT_MP4;
+       ClearLastResult();
+
+       format = __pImpl->GetFormat();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return format;
+
+CATCH:
+       return (VideoRecordingFormat) MEDIA_INVALID_VALUE;
+
+
+}
+
+result
+VideoRecorder::SetFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetFormat(audioCodec, videoCodec, container);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+VideoRecorder::GetFormat(CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       __pImpl->GetFormat(audioCodec, videoCodec, container);
+
+       return r;
+}
+
+Tizen::Base::Collection::IListT <CodecType>*
+VideoRecorder::GetSupportedAudioCodecListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       ArrayListT <CodecType>* pDestList = null;
+       ClearLastResult();
+
+       pDestList = __pImpl->GetSupportedAudioCodecListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pDestList;
+
+CATCH:
+       if (pDestList != null)
+       {
+               pDestList->RemoveAll();
+               delete pDestList;
+       }
+       return null;
+}
+
+Tizen::Base::Collection::IListT <CodecType>*
+VideoRecorder::GetSupportedVideoCodecListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       ArrayListT <CodecType>* pDestList = null;
+       ClearLastResult();
+
+       pDestList = __pImpl->GetSupportedVideoCodecListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pDestList;
+
+CATCH:
+       if (pDestList != null)
+       {
+               pDestList->RemoveAll();
+               delete pDestList;
+       }
+       return null;
+}
+
+Tizen::Base::Collection::IListT <MediaContainerType>*
+VideoRecorder::GetSupportedContainerListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       ArrayListT <MediaContainerType>* pDestList = null;
+       ClearLastResult();
+
+       pDestList = __pImpl->GetSupportedContainerListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+
+       return pDestList;
+
+CATCH:
+       if (pDestList != null)
+       {
+               pDestList->RemoveAll();
+               delete pDestList;
+       }
+       return null;
+}
+
+result
+VideoRecorder::SetMode(VideoRecorderMode mode)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetMode(mode);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+VideoRecorderMode
+VideoRecorder::GetMode(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       VideoRecorderMode mode = VIDEORECORDER_MODE_VIDEO_WITH_AUDIO;
+       ClearLastResult();
+
+       mode = __pImpl->GetMode();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return mode;
+
+CATCH:
+       return (VideoRecorderMode) MEDIA_INVALID_VALUE;
+}
+
+result
+VideoRecorder::SetQuality(RecordingQuality quality)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetQuality(quality);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+RecordingQuality
+VideoRecorder::GetQuality(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       RecordingQuality quality = RECORDING_QUALITY_LOW;
+       ClearLastResult();
+
+       quality = __pImpl->GetQuality();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return quality;
+
+CATCH:
+       return (RecordingQuality) MEDIA_INVALID_VALUE;
+}
+
+result
+VideoRecorder::SetRecordingResolution(const Tizen::Graphics::Dimension& resolution)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetRecordingResolution(resolution);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+Tizen::Graphics::Dimension
+VideoRecorder::GetRecordingResolution(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       Tizen::Graphics::Dimension dimension;
+       ClearLastResult();
+
+       dimension = __pImpl->GetRecordingResolution();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return dimension;
+
+CATCH:
+       return Tizen::Graphics::Dimension(0, 0);
+}
+
+Tizen::Base::Collection::IList*
+VideoRecorder::GetSupportedRecordingResolutionListN(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       Tizen::Base::Collection::IList* pResolutionList = null;
+       ClearLastResult();
+
+       pResolutionList = __pImpl->GetSupportedRecordingResolutionListN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pResolutionList;
+
+CATCH:
+       if (pResolutionList != null)
+       {
+               pResolutionList->RemoveAll(true);
+               delete pResolutionList;
+       }
+       return null;
+}
+
+int
+VideoRecorder::GetSupportedMaxFrameRate(const Tizen::Graphics::Dimension& dim) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       int maxFrameRate = MEDIA_INVALID_VALUE;
+       ClearLastResult();
+
+       maxFrameRate = __pImpl->GetSupportedMaxFrameRate(dim);
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+
+       return maxFrameRate;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+result
+VideoRecorder::SetMute(bool mute)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetMute(mute);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+bool
+VideoRecorder::IsMuted(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+       bool mute = false;
+       ClearLastResult();
+
+       mute = __pImpl->IsMuted();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return mute;
+
+CATCH:
+       return false;
+}
+
+result
+VideoRecorder::SetRecordingRotation(RecordingRotation rotation)
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_VIDEORECORDER);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED]. This application does not have the privilege to call this method.");
+
+       r = __pImpl->SetRecordingRotation(rotation);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+RecordingRotation
+VideoRecorder::GetRecordingRotation(void) const
+{
+       SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+       RecordingRotation roation = RECORDING_ROTATION_NONE;
+
+       roation = __pImpl->GetRecordingRotation();
+       return roation;
+}
+
+}}// Osp::Media
+
diff --git a/src/FMediaVideoStreamInfo.cpp b/src/FMediaVideoStreamInfo.cpp
new file mode 100644 (file)
index 0000000..cdd701c
--- /dev/null
@@ -0,0 +1,150 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMediaVideoStreamInfo.h"
+#include "FMediaMediaStreamInfo.h"
+#include "FMedia_VideoStreamInfoImpl.h"
+#include <FBaseSysLog.h>
+#include "stdio.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+VideoStreamInfo::VideoStreamInfo(CodecType codecType, int width, int height, int bitrate, float frameRate)
+{
+       __pVideoStreamInfoImpl = new  (std::nothrow)  _VideoStreamInfoImpl(codecType, width, height, bitrate, frameRate);
+}
+
+VideoStreamInfo::~VideoStreamInfo()
+{
+       if (__pVideoStreamInfoImpl)
+       {
+               delete __pVideoStreamInfoImpl;
+       }
+       __pVideoStreamInfoImpl = null;
+}
+
+
+VideoStreamInfo::VideoStreamInfo(const VideoStreamInfo& rhs)
+       : Tizen::Base::Object()
+       , __pVideoStreamInfoImpl(new (std::nothrow) _VideoStreamInfoImpl(*rhs.__pVideoStreamInfoImpl))
+{
+}
+
+VideoStreamInfo&
+VideoStreamInfo::operator =(const VideoStreamInfo& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+       *__pVideoStreamInfoImpl = *rhs.__pVideoStreamInfoImpl;
+
+       return *this;
+}
+
+
+bool
+VideoStreamInfo::Equals(const Tizen::Base::Object& rhs) const
+{
+       const VideoStreamInfo* pRhs = dynamic_cast <const VideoStreamInfo*>(&rhs);
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       return __pVideoStreamInfoImpl->Equals(*pRhs->__pVideoStreamInfoImpl);
+}
+
+int
+VideoStreamInfo::GetHashCode(void) const
+{
+       return __pVideoStreamInfoImpl->GetHashCode();
+
+}
+
+int
+VideoStreamInfo::GetWidth() const
+{
+       if (__pVideoStreamInfoImpl)
+       {
+               return __pVideoStreamInfoImpl->GetWidth();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+int
+VideoStreamInfo::GetHeight() const
+{
+       if (__pVideoStreamInfoImpl)
+       {
+               return __pVideoStreamInfoImpl->GetHeight();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+int
+VideoStreamInfo::GetBitRate() const
+{
+       if (__pVideoStreamInfoImpl)
+       {
+               return __pVideoStreamInfoImpl->GetBitRate();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+CodecType
+VideoStreamInfo::GetCodecType() const
+{
+       if (__pVideoStreamInfoImpl)
+       {
+               return __pVideoStreamInfoImpl->GetCodecType();
+       }
+       else
+       {
+               return CODEC_NONE;
+       }
+}
+
+//Rational
+float
+VideoStreamInfo::GetFrameRate() const
+{
+       if (__pVideoStreamInfoImpl)
+       {
+               return __pVideoStreamInfoImpl->GetFrameRate();
+       }
+       else
+       {
+               return 0.0;
+       }
+}
+
+};
+};
diff --git a/src/FMediaVoipAudioSessionManager.cpp b/src/FMediaVoipAudioSessionManager.cpp
new file mode 100644 (file)
index 0000000..347da5b
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License)
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaVoipAudioSessionManager.h>
+#include "FMedia_VoipAudioSessionManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Media
+{
+
+
+VoipAudioSessionManager::VoipAudioSessionManager()
+{
+       __pVoipAudioSessionManagerImpl = _VoipAudioSessionManagerImpl::GetInstance();
+}
+
+VoipAudioSessionManager::~VoipAudioSessionManager()
+{
+       if (__pVoipAudioSessionManagerImpl != null)
+       {
+               __pVoipAudioSessionManagerImpl = null;
+       }
+}
+
+VoipAudioSessionManager*
+VoipAudioSessionManager::GetInstance(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       static VoipAudioSessionManager voipSessionManager;
+       return (&voipSessionManager);
+
+CATCH:
+       return null;
+}
+
+result
+VoipAudioSessionManager::EnterCallSession(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pVoipAudioSessionManagerImpl->EnterCallSession();
+}
+
+
+result
+VoipAudioSessionManager::ExitCallSession(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pVoipAudioSessionManagerImpl->ExitCallSession();
+}
+
+result
+VoipAudioSessionManager::SetCallSessionMode(VoipAudioSessionMode mode)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
+       SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pVoipAudioSessionManagerImpl->SetCallSessionMode(mode);
+}
+
+VoipAudioSessionMode
+VoipAudioSessionManager::GetCallSessionMode(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
+       SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
+
+       return __pVoipAudioSessionManagerImpl->GetCallSessionMode();
+
+CATCH:
+       return (VoipAudioSessionMode) -1;
+}
+
+};
+};
diff --git a/src/FMedia_AacDecoder.cpp b/src/FMedia_AacDecoder.cpp
new file mode 100644 (file)
index 0000000..3787da9
--- /dev/null
@@ -0,0 +1,550 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <unique_ptr.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColArrayListT.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_IAudioDecoder.h"
+#include "FMedia_AacDecoder.h"
+#include "FMedia_BitWriter.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+#define ADTS_HEADER_SIZE 7
+
+static const int _AAC_SAMPLE_RATE_INDEX[] = {
+       96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000 };
+
+_IAudioDecoder*
+_AacDecoder_CreateInstance(void)
+{
+       return new (std::nothrow) _AacDecoder();
+}
+
+_AacDecoder::_AacDecoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __decodeCalled = false;
+       __pOutBuf = null;
+}
+
+_AacDecoder::~_AacDecoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+       }
+}
+
+result
+_AacDecoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       Integer* pKey = null;
+       Integer* pValue = null;
+       int key = -1;
+       int value = -1;
+
+       SysAssertf((__pCodecCtx == null && __pCodec == null), " Already Constructed .");
+
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Context Allcoation Failed",GetErrorMessage(E_SYSTEM));
+       __pCodec = avcodec_find_decoder(CODEC_ID_AAC);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Find Decoder Failed for CODEC_ID_AAC",GetErrorMessage(E_SYSTEM));
+
+       if (pOption != null)
+       {
+               // The initialization values are given in the Hashmap
+               std::unique_ptr<IMapEnumerator> pMapEnum(pOption->GetMapEnumeratorN());
+               if (pMapEnum.get() != null)
+               {
+                       while (pMapEnum.get()->MoveNext() == E_SUCCESS)
+                       {
+                               pKey = static_cast<Integer*>(pMapEnum.get()->GetKey());
+                               pValue = static_cast<Integer*>(pMapEnum.get()->GetValue());
+                               if (pKey && pValue)
+                               {
+                                       key = pKey->ToInt();
+                                       value = pValue->ToInt();
+                                       switch (key)
+                                       {
+                                       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+                                               SysTryCatch(NID_MEDIA, (value == 0 || value == 1 || value == 2), r = E_OUT_OF_RANGE,
+                                                                  E_OUT_OF_RANGE, "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->channels = value;
+                                               break;
+
+                                       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+                                               SysTryCatch(NID_MEDIA, !(value < 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->sample_rate = value;
+                                               break;
+
+                                       case MEDIA_PROPERTY_AUDIO_BIT_RATE:
+                                               SysTryCatch(NID_MEDIA, !(value < 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->bit_rate = value;
+                                               break;
+
+                                       default:
+                                               break;
+                                       }
+                               }
+                       } // while
+               }
+       }
+
+       __pCodecCtx->sample_fmt = AV_SAMPLE_FMT_S16;
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Codec Open Failed for CODEC_ID_AAC",GetErrorMessage(E_SYSTEM));
+
+       // AVCodecContext parameters
+       if (__pCodec->capabilities & CODEC_CAP_TRUNCATED)
+       {
+               __pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+       }
+
+       __pCodecCtx->debug_mv = 0; //set by user
+       __pCodecCtx->debug = 0; //set by user
+       __pCodecCtx->workaround_bugs = 1; //set by user
+       __pCodecCtx->extradata_size = 0;
+
+       __pOutBuf = new (std::nothrow) byte[DEFAULT_BUFFER_SIZE];
+       SysTryCatch(NID_MEDIA, __pOutBuf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY)); 
+
+
+       return r;
+
+CATCH:
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       return r;
+}
+
+const ByteBuffer*
+_AacDecoder::GetHeaderN(int sampleRate, int channels, int size, int pce_size)
+{
+       ByteBuffer* pBuf = null;
+       result r = E_SUCCESS;
+
+       pBuf = new (std::nothrow) ByteBuffer();
+
+       if (pBuf == null)
+       {
+               return null;
+       }
+
+       r = pBuf->Construct(ADTS_HEADER_SIZE);
+       if (r != E_SUCCESS)
+       {
+               delete pBuf;
+               return null;
+       }
+
+       _BitWriter bw((byte*)pBuf->GetPointer(),pBuf->GetCapacity());
+       int sampleRateIndex = 0x0b;
+       int count = (int)(sizeof(_AAC_SAMPLE_RATE_INDEX)/sizeof(_AAC_SAMPLE_RATE_INDEX[0]));
+       for (int i = 0; i < count; i++)
+       {
+               if (_AAC_SAMPLE_RATE_INDEX[i] == sampleRate)
+               {
+                       sampleRateIndex = i;
+                       break;
+               }
+       }
+
+       // fixed header
+       bw.PutBits(12, 0xfff);                  // syncword
+       bw.PutBits(1, 0);                               // id
+       bw.PutBits(2, 0);                               // layer
+       bw.PutBits(1, 1);                               // protection
+       bw.PutBits(2, 1);                               // profile : LC: 01
+       bw.PutBits(4, sampleRateIndex); // sample rate index
+       bw.PutBits(1, 0);                               // private
+       bw.PutBits(3, channels);                // channel
+       bw.PutBits(1, 0);                               // original copy
+       bw.PutBits(1, 0);                               // home
+
+       // variable header
+       bw.PutBits(1, 0);                               // copyright id bit
+       bw.PutBits(1, 0);                               // copyright id start
+       bw.PutBits(13, ADTS_HEADER_SIZE+size+pce_size);                         // aac frame length
+       bw.PutBits(11, 0x7ff);                  // buffer fullness
+       bw.PutBits(2, 0);                               // number of raw data blocks in frame
+
+       pBuf->SetPosition(0);
+       r = pBuf->SetLimit(ADTS_HEADER_SIZE);
+       if (r != E_SUCCESS)
+       {
+               delete pBuf;
+               return null;
+       }
+
+       return pBuf;
+}
+
+result
+_AacDecoder::Decode(const byte* pSrcBuf, int srcBufSize, int& srcBufUsed,
+                                       byte* pDstBuf, int dstBufSize, int& dstBufUsed)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVPacket inputPacket;
+       int outBufSize = 0;
+       int16_t* pOutBuf = null;
+       int errStrLen = 256;
+       char errStr[errStrLen];
+       uint8_t* pInputData = null;
+       const  ByteBuffer* pAdtsHeader = null;
+
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, (pSrcBuf != null && pDstBuf != null && srcBufSize > 0 && dstBufSize > 0),
+                          r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+
+       av_init_packet(&inputPacket);
+       inputPacket.size = srcBufSize;
+       inputPacket.data = (uint8_t*)pSrcBuf;
+
+       if (dstBufSize >= DEFAULT_BUFFER_SIZE)
+       {
+               pOutBuf = (int16_t*)pDstBuf;
+               outBufSize = dstBufSize;
+       }
+       else
+       {
+               pOutBuf = (int16_t*)__pOutBuf;
+               outBufSize = DEFAULT_BUFFER_SIZE;
+       }
+
+       // Decoding the Audio  packet
+       res = avcodec_decode_audio3(__pCodecCtx, pOutBuf, &outBufSize, &inputPacket);
+       // add adts header and try to decode
+       if ( res < 0 && !((pSrcBuf[0] == 0xff) && ((pSrcBuf[1] & 0xf6) == 0xf0)))
+       {
+               pInputData = new (std::nothrow) uint8_t[srcBufSize + ADTS_HEADER_SIZE];
+               SysTryCatch(NID_MEDIA, pInputData != null, r = E_OUT_OF_MEMORY,
+                          E_OUT_OF_MEMORY, "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+                               pAdtsHeader = GetHeaderN(__pCodecCtx->sample_rate,__pCodecCtx->channels,srcBufSize,0);
+               if (pAdtsHeader)
+               {
+                                       memcpy(pInputData,pAdtsHeader->GetPointer(),ADTS_HEADER_SIZE);
+                                       memcpy(pInputData + ADTS_HEADER_SIZE  ,pSrcBuf,srcBufSize);
+                                       inputPacket.size = srcBufSize + ADTS_HEADER_SIZE;
+                                       inputPacket.data = pInputData;
+                                       res = avcodec_decode_audio3(__pCodecCtx, pOutBuf, &outBufSize, &inputPacket);
+                                       delete pAdtsHeader;
+                                       pAdtsHeader = null;
+               }
+                               delete []pInputData;
+                               pInputData = null;
+       }
+       SysTryCatch(NID_MEDIA,(res > 0 && outBufSize > 0), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                           "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysTryCatch(NID_MEDIA,dstBufSize >= outBufSize, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+
+       dstBufUsed = outBufSize; // The decoded audio data size
+       srcBufUsed = res; //Input bytes used
+       if (inputPacket.size == (srcBufSize + ADTS_HEADER_SIZE))
+       {
+               dstBufUsed = outBufSize; // The decoded audio data size
+               srcBufUsed = res - ADTS_HEADER_SIZE; //Input bytes used, substract the appended header bytes
+       }
+       else
+       {
+               dstBufUsed = outBufSize; // The decoded audio data size
+               srcBufUsed = res; //Input bytes used            
+       }
+
+       if ( pDstBuf != (byte*)pOutBuf)
+       {
+               memcpy(pDstBuf, pOutBuf, outBufSize);
+       }
+       __decodeCalled = true;
+       return r;
+
+CATCH:
+       if (res < 0)
+       {
+               res = av_strerror(res, errStr, errStrLen);
+               if (!res)
+       {
+                       SysLog(NID_MEDIA, "Error is %s. %d ", errStr, res);
+       }
+       }
+       return r;
+}
+
+result
+_AacDecoder::Probe(const byte* pSrcBuf, const int srcBufLength,
+                                                Tizen::Media::AudioSampleType& sampleType,
+                                                Tizen::Media::AudioChannelType& channelType, int& sampleRate)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVPacket inputPacket;
+       int outBufSize = 0;
+       int16_t* pOutBuf = null;
+
+
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, (pSrcBuf != null && srcBufLength > 0), r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+
+       av_init_packet(&inputPacket);
+
+       inputPacket.data = (uint8_t*) pSrcBuf;
+       inputPacket.size = srcBufLength;
+
+       pOutBuf = (int16_t*)__pOutBuf;
+       outBufSize = DEFAULT_BUFFER_SIZE;
+
+       // Decoding the Audio  packet
+       res = avcodec_decode_audio3(__pCodecCtx, pOutBuf, &outBufSize, &inputPacket);
+       SysTryCatch(NID_MEDIA, (res > 0 && outBufSize > 0) , r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));
+       switch (__pCodecCtx->channels)
+       {
+       case 0:
+               channelType = AUDIO_CHANNEL_TYPE_NONE;
+       break;
+
+       case 1:
+               channelType = AUDIO_CHANNEL_TYPE_MONO;
+       break;
+
+       case 2:
+               channelType = AUDIO_CHANNEL_TYPE_STEREO;
+       break;
+
+       default:
+               break;
+       }
+
+       switch (__pCodecCtx->sample_fmt)
+       {
+       case AV_SAMPLE_FMT_NONE:
+               // fall through
+       case AV_SAMPLE_FMT_S32:
+               // fall through
+       case AV_SAMPLE_FMT_FLT:
+               // fall through
+       case AV_SAMPLE_FMT_DBL:
+               // fall through
+       case AV_SAMPLE_FMT_NB:
+               sampleType = AUDIO_TYPE_NONE;
+       break;
+
+       case AV_SAMPLE_FMT_U8:
+               sampleType = AUDIO_TYPE_PCM_U8;
+       break;
+
+       case AV_SAMPLE_FMT_S16:
+               sampleType = AUDIO_TYPE_PCM_S16_LE;
+       break;
+
+       default:
+               sampleType = AUDIO_TYPE_NONE;
+               break;
+       }
+
+       sampleRate = __pCodecCtx->sample_rate;
+       __decodeCalled = true;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AacDecoder::Reset(void)
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       avcodec_flush_buffers(__pCodecCtx);
+       __decodeCalled = false;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AacDecoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, 0 < type, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, __decodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+               switch (__pCodecCtx->channels)
+               {
+               case 0:
+                       value = AUDIO_CHANNEL_TYPE_NONE;
+                       break;
+
+               case 1:
+                       value = AUDIO_CHANNEL_TYPE_MONO;
+                       break;
+
+               case 2:
+                       value = AUDIO_CHANNEL_TYPE_STEREO;
+                       break;
+
+               default:
+                       break;
+       }
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE:
+               switch (__pCodecCtx->sample_fmt)
+               {
+               case AV_SAMPLE_FMT_NONE:
+                       // fall through
+               case AV_SAMPLE_FMT_S32:
+                       // fall through
+               case AV_SAMPLE_FMT_FLT:
+                       // fall through
+               case AV_SAMPLE_FMT_DBL:
+                       // fall through
+               case AV_SAMPLE_FMT_NB:
+                       value = AUDIO_TYPE_NONE;
+                       break;
+
+               case AV_SAMPLE_FMT_U8:
+                       value = AUDIO_TYPE_PCM_U8;
+                       break;
+
+               case AV_SAMPLE_FMT_S16:
+                       value = AUDIO_TYPE_PCM_S16_LE;
+                       break;
+
+               default:
+                       value = AUDIO_TYPE_NONE;
+                       break;
+               }
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+               value = __pCodecCtx->sample_rate;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AacDecoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, type < 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, type < MEDIA_PROPERTY_VIDEO_WIDTH || type >= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysTryCatch(NID_MEDIA, __decodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_AacDecoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pPropList = new  (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pPropList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                         "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE);
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE);
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE);
+       SetLastResult(r);
+       return pPropList;
+
+CATCH:
+       return null;
+}
+
+bool
+_AacDecoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, ( type == MEDIA_PROPERTY_AUDIO_SAMPLE_RATE || type == MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE ) ||
+                          (type == MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE ), r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_AacDecoder.h b/src/FMedia_AacDecoder.h
new file mode 100644 (file)
index 0000000..e160ff1
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMedia_AacDecoder.h
+ * @brief  This is the header file for the Tizen::Media::_AacDecoder.
+ *
+ * This header file contains the declarations of the Tizen::Media::_AacDecoder.
+ */
+#ifndef _FMEDIA_INTERNAL_AACDECODER_H_
+#define _FMEDIA_INTERNAL_AACDECODER_H_
+
+
+namespace Tizen { namespace Media
+{
+
+class _AacDecoder
+       : public _IAudioDecoder
+{
+public:
+       _AacDecoder(void);
+
+       virtual ~_AacDecoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* pSrcBuf, const int length,
+                                                AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate);
+
+       virtual result Decode(const byte* pSrcBuf, int srcBufSize, int &srcBufUsed,
+                                                 byte* pDstBuf, int dstBufSize, int &dstBufUsed);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+       const Tizen::Base::ByteBuffer* GetHeaderN(int sampleRate, int channels, int size, int pce_size);
+private:
+       static const int DEFAULT_BUFFER_SIZE = 192000;
+
+       _AacDecoder(const _AacDecoder&);
+
+       _AacDecoder& operator =(const _AacDecoder&);
+
+private:
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       bool __decodeCalled;
+       byte* __pOutBuf;
+};
+
+} } // Tizen::Media
+
+#endif // _FMEDIA_INTERNAL_AACDECODER_H_
diff --git a/src/FMedia_AacEncoder.cpp b/src/FMedia_AacEncoder.cpp
new file mode 100644 (file)
index 0000000..5bac27d
--- /dev/null
@@ -0,0 +1,303 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <unique_ptr.h>
+#include <FBaseColHashMap.h>
+#include <FBaseInteger.h>
+#include <FMediaTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_AacEncoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_IAudioEncoder*
+_AacEncoder_CreateInstance(void)
+{
+       return new (std::nothrow) _AacEncoder();
+}
+
+_AacEncoder::_AacEncoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __pResampleContext = null;
+       __pInputBuf = null;
+       __pInputFrame = null;
+}
+
+_AacEncoder::~_AacEncoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+
+       if (__pResampleContext != null)
+       {
+               audio_resample_close(__pResampleContext);
+       }
+
+       if (__pInputBuf != null)
+       {
+               delete[] __pInputBuf;
+       }
+
+       if (__pInputFrame != null)
+       {
+               avcodec_free_frame(&__pInputFrame);
+       }
+
+}
+
+result
+_AacEncoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       Integer* pKey = null;
+       Integer* pValue = null;
+       int key = -1;
+       int value = -1;
+       int inputSize = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx == null, E_INVALID_STATE, "already constructed");
+
+       avcodec_register_all();
+
+       __pCodec = avcodec_find_encoder(CODEC_ID_AAC);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] Failed to get avcodec encoder", GetErrorMessage(E_SYSTEM));
+
+       __pCodecCtx = avcodec_alloc_context3(__pCodec);
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] Failed to allocate avcodec context", GetErrorMessage(E_SYSTEM));
+
+
+       __pCodecCtx->bit_rate = DEFAULT_BIT_RATE;
+       __pCodecCtx->sample_rate = DEFAULT_SAMPLE_RATE;
+       __pCodecCtx->channels = DEFAULT_CHANNEL_COUNT;
+       __pCodecCtx->sample_fmt = AV_SAMPLE_FMT_FLT;
+       __pCodecCtx->profile = FF_PROFILE_AAC_LOW;
+       __pCodecCtx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
+
+       if (pOption != null)
+       {
+               // The initialization values are given in the Hashmap
+               std::unique_ptr<IMapEnumerator> pMapEnum(pOption->GetMapEnumeratorN());
+               if (pMapEnum.get() != null)
+               {
+                       while (pMapEnum.get()->MoveNext() == E_SUCCESS)
+                       {
+                               pKey = dynamic_cast<Integer*>(pMapEnum.get()->GetKey());
+                               pValue = dynamic_cast<Integer*>(pMapEnum.get()->GetValue());
+
+                               if (pKey == null || pValue == null)
+                               {
+                                       continue;
+                               }
+
+                               key = pKey->ToInt();
+                               value = pValue->ToInt();
+                               switch (key)
+                               {
+                               case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+                                       SysTryCatch(NID_MEDIA, (value == 0 || value == 1 || value == 2), r = E_OUT_OF_RANGE,
+                                                          E_OUT_OF_RANGE, "[%s] Audio Channel Type %d is outof range",GetErrorMessage(E_OUT_OF_RANGE));
+                                       __pCodecCtx->channels = value;
+                                       break;
+
+                               case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+                                       SysTryCatch(NID_MEDIA, !(value < 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                          "[%s] Audio Sample rate is out of range", GetErrorMessage(E_OUT_OF_RANGE));
+                                       __pCodecCtx->sample_rate = value;
+                                       break;
+
+                               case MEDIA_PROPERTY_AUDIO_BIT_RATE:
+                                       SysTryCatch(NID_MEDIA, !(value < 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                          "[%s] Audio Bit Rate is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                       __pCodecCtx->bit_rate = value;
+                                       break;
+
+                               default:
+                                       SysLog(NID_MEDIA,"[%s] Ignore option:%d", GetErrorMessage(E_INVALID_ARG),key);
+                                       break;
+                               }
+                       }
+
+               }
+       }
+
+       if ( __pCodecCtx->bit_rate * SAMPLE_SIZE / __pCodecCtx->sample_rate
+                > __pCodecCtx->channels * BYTES_PER_SAMPLE)
+       {
+               __pCodecCtx->bit_rate = (__pCodecCtx->channels * BYTES_PER_SAMPLE)
+                       / SAMPLE_SIZE * __pCodecCtx->sample_rate;
+       }
+
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] avcodec open failed:%d", GetErrorMessage(E_SYSTEM), res);
+
+       if (__pCodecCtx->sample_fmt  == AV_SAMPLE_FMT_FLT)
+       {
+               inputSize = __pCodecCtx->frame_size * __pCodecCtx->channels * FLT_SAMPLE_SIZE;
+               __pInputBuf = new (std::nothrow) byte[inputSize];
+               SysTryCatch(NID_MEDIA, __pInputBuf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation Failed", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       __pInputFrame = avcodec_alloc_frame();
+       SysTryCatch(NID_MEDIA, __pInputFrame != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation Failed", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pInputFrame->nb_samples = __pCodecCtx->frame_size;
+       __pInputFrame->format = __pCodecCtx->sample_fmt;
+       __pInputFrame->channel_layout = __pCodecCtx->channel_layout;
+
+       return r;
+
+CATCH:
+
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       return r;
+}
+
+result
+_AacEncoder::Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       int outIndex = 0;
+       int samples = 0;
+       int minSrcBufLength = 0;
+       int minDstBufLength = FF_MIN_BUFFER_SIZE;
+       AVPacket outPacket;
+       outPacket.data = null;
+       int gotOutput = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+
+       minSrcBufLength = __pCodecCtx->frame_size * S16_SAMPLE_SIZE * __pCodecCtx->channels;
+
+       SysTryCatch(NID_MEDIA, srcBuf != null && dstBuf != null, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used: 0x%x %d %d 0x%x %d %d",
+                          GetErrorMessage(E_INVALID_ARG), srcBuf, srcBufLength, minSrcBufLength, dstBuf, dstBufLength, minDstBufLength);
+
+       //Partial frame encoding is supported hence no need of checking sourcebuf length.
+       SysTryCatch(NID_MEDIA, dstBufLength >= minDstBufLength,
+                          r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Destination Buffer Length is less than FF_MIN_BUFFER_SIZE: 0x%x %d %d 0x%x %d %d",
+                          GetErrorMessage(E_OUT_OF_MEMORY), srcBuf, srcBufLength, minSrcBufLength, dstBuf, dstBufLength, minDstBufLength);
+
+       //Only AV_SAMPLE_FMT_FLT is supported by FFMpeg AAC Encoder hence Sample Format Conversion from S16 to Float
+       if (__pCodecCtx->sample_fmt  == AV_SAMPLE_FMT_FLT)
+       {
+               if (!__pResampleContext)
+               {
+                       __pResampleContext = av_audio_resample_init(__pCodecCtx->channels, __pCodecCtx->channels,
+                                               __pCodecCtx->sample_rate, __pCodecCtx->sample_rate,
+                                               AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
+                                               0, 0, 0, 0);
+                       SysTryCatch(NID_MEDIA, __pResampleContext != null, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                                          "[%s] av audio resample init failed",GetErrorMessage(E_UNSUPPORTED_FORMAT));
+
+               }
+
+               memset(__pInputBuf,0,__pCodecCtx->frame_size * __pCodecCtx->channels * FLT_SAMPLE_SIZE);
+
+               if(srcBufLength >= minSrcBufLength)
+               {
+                       samples = audio_resample (__pResampleContext, (short *) __pInputBuf, (short *)srcBuf, __pCodecCtx->frame_size);
+               }
+               else
+               {
+                       int sampleCount = srcBufLength/(__pCodecCtx->channels * S16_SAMPLE_SIZE);
+                       samples = audio_resample (__pResampleContext, (short *) __pInputBuf, (short *)srcBuf,sampleCount);
+
+               }
+
+               res = avcodec_fill_audio_frame(__pInputFrame, __pCodecCtx->channels,__pCodecCtx->sample_fmt,
+                       (const uint8_t*)__pInputBuf,__pCodecCtx->frame_size * __pCodecCtx->channels * FLT_SAMPLE_SIZE,0 );
+
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] Fill Audio Frame failed %d", GetErrorMessage(E_SYSTEM));
+
+               av_init_packet(&outPacket);
+               outPacket.data = NULL;
+               outPacket.size = 0;
+
+               res = avcodec_encode_audio2(__pCodecCtx, &outPacket, __pInputFrame, &gotOutput);
+
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] Audio Encode Failed %d", GetErrorMessage(E_SYSTEM));
+
+               if(gotOutput)
+               {
+                       memcpy(dstBuf,outPacket.data,outPacket.size);
+                       dstBufLength = outPacket.size;
+                       av_free_packet(&outPacket);
+               }
+               else
+               {
+                       dstBufLength = 0;
+               }
+       }
+
+       srcBufLength = minSrcBufLength; //Input bytes used
+       return r;
+
+CATCH:
+       if (__pResampleContext != null)
+       {
+               audio_resample_close(__pResampleContext);
+       }
+
+       if(outPacket.data != null)
+       {
+               av_free_packet(&outPacket);
+       }
+
+       return r;
+}
+
+result
+_AacEncoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+
+       avcodec_flush_buffers(__pCodecCtx);
+       return r;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_AacEncoder.h b/src/FMedia_AacEncoder.h
new file mode 100644 (file)
index 0000000..26451b5
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMedia_AacEncoder.h
+ * @brief  This is the header file for the _AacEncoder.
+ *
+ * This header file contains the declarations of the _AacEncoder.
+ */
+#ifndef FMEDIA_INTERNAL_AACENCODER_H_
+#define FMEDIA_INTERNAL_AACENCODER_H_
+
+#include "FMedia_IAudioEncoder.h"
+
+namespace Tizen { namespace Media
+{
+
+class _AacEncoder
+       : public _IAudioEncoder
+{
+public:
+       _AacEncoder(void);
+
+       virtual ~_AacEncoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength);
+
+       virtual result Reset(void);
+
+private:
+       _AacEncoder(const _AacEncoder&);
+
+       _AacEncoder& operator =(const _AacEncoder&);
+
+private:
+       static const int DEFAULT_BIT_RATE = 64000;
+       static const int DEFAULT_SAMPLE_RATE = 44100;
+       static const int DEFAULT_CHANNEL_COUNT = 2;
+       static const float SAMPLE_SIZE = 1024.0;
+       static const int BYTES_PER_SAMPLE = 6144;
+       static const int FLT_SAMPLE_SIZE = 4;
+       static const int S16_SAMPLE_SIZE = 2;
+       static const int DEFAULT_BUFFER_SIZE = 4096;
+
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       AVFrame* __pInputFrame;
+       ReSampleContext* __pResampleContext;
+       byte* __pInputBuf;
+};
+
+};
+};
+
+
+#endif // FMEDIA_INTERNAL_AACENCODER_H_
diff --git a/src/FMedia_AlawDecoder.cpp b/src/FMedia_AlawDecoder.cpp
new file mode 100644 (file)
index 0000000..3c7a945
--- /dev/null
@@ -0,0 +1,405 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <stdio.h>
+#include <unique_ptr.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseInteger.h>
+#include <FBaseColHashMap.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_FfmpegUtil.h"
+#include "FMedia_IAudioDecoder.h"
+#include "FMedia_AlawDecoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_IAudioDecoder*
+_AlawDecoder_CreateInstance(void)
+{
+       return new (std::nothrow) _AlawDecoder();
+}
+
+_AlawDecoder::_AlawDecoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __decodeCalled = false;
+       __pOutBuf = null;
+       __decoderConfigured = false;
+}
+
+_AlawDecoder::~_AlawDecoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+       }
+}
+
+result
+_AlawDecoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       Integer* pKey = null;
+       Integer* pValue = null;
+       int key = -1;
+       int value = -1;
+
+       SysAssertf((__pCodecCtx == null && __pCodec == null), " Already Constructed .");
+       SysTryReturnResult(NID_MEDIA, pOption != null, E_INVALID_ARG, "pOtion is null");
+
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                           "[%s] AVCODEC Context Allcoation Failed",GetErrorMessage(E_SYSTEM));
+       __pCodec = avcodec_find_decoder(CODEC_ID_PCM_ALAW);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Find Decoder Failed for CODEC_ID_PCM_ALAW",GetErrorMessage(E_SYSTEM));
+
+       if (pOption != null)
+       {
+               // The initialization values are given in the Hashmap
+               std::unique_ptr<IMapEnumerator> pMapEnum(pOption->GetMapEnumeratorN());
+               if (pMapEnum.get() != null)
+               {
+                       while (pMapEnum.get()->MoveNext() == E_SUCCESS)
+                       {
+                               pKey = static_cast<Integer*>(pMapEnum.get()->GetKey());
+                               pValue = static_cast<Integer*>(pMapEnum.get()->GetValue());
+                               if (pKey && pValue)
+                               {
+                                       key = pKey->ToInt();
+                                       value = pValue->ToInt();
+                                       switch (key)
+                                       {
+                                       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+                                               SysTryCatch(NID_MEDIA, (value == 0 || value == 1 || value == 2), r = E_OUT_OF_RANGE,
+                                                                  E_OUT_OF_RANGE, "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->channels = value;
+                                               __decoderConfigured = true;
+                                               break;
+
+                                       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+                                               SysTryCatch(NID_MEDIA, !(value < 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->sample_rate = value;
+                                               break;
+
+                                       case MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE:
+                                               SysTryCatch(NID_MEDIA, !(value < 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->sample_fmt = _FfmpegUtil::ToAvSampleFormat((AudioSampleType)value);
+                                               break;
+
+                                       default:
+                                               break;
+                                       }
+                               }
+                       } // while
+
+               }
+       }
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx->channels != 0, E_INVALID_ARG, "Channel is not set");
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx->sample_rate != 0, E_INVALID_ARG, "Sample rate is not set");
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx->sample_fmt != AV_SAMPLE_FMT_NONE, E_INVALID_ARG, "Sample type is not set");
+
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Codec Open Failed for CODEC_ID_PCM_ALAW",GetErrorMessage(E_SYSTEM));
+
+       // AVCodecContext parameters
+       if (__pCodec->capabilities & CODEC_CAP_TRUNCATED)
+       {
+               __pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+       }
+
+       __pCodecCtx->debug_mv = 0; //set by user
+       __pCodecCtx->debug = 0; //set by user
+       __pCodecCtx->workaround_bugs = 1; //set by user
+       __pCodecCtx->lowres = 0; //set by user
+
+       __pOutBuf = new (std::nothrow) byte[MIN_OUT_BUFFER_SIZE];
+       SysTryCatch(NID_MEDIA, __pOutBuf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return r;
+
+CATCH:
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+               __pOutBuf = null;
+       }
+       return r;
+}
+
+result
+_AlawDecoder::Decode(const byte* pSrcBuf, int srcBufSize, int& srcBufUsed,
+                                       byte* pDstBuf, int dstBufSize, int& dstBufUsed)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVPacket inputPacket;
+       int outBufSize = 0;
+       byte* pOutBuf = null;
+       int offSet = 0;
+
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, pSrcBuf != null && pDstBuf != null && srcBufSize > 0 && dstBufSize > 0,
+                          r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+
+       // This blocks reads the input data format , i.e channel count and format type is read.
+       // No error checkin id done here as we are trying to get the channel count if user wont specify
+#if 0
+       if (__decoderConfigured == false)
+       {
+
+               _WavFormatInfo wavFormatInfo;
+               _RiffFileHeader riffHdr;
+               _RiffChunkHeader chunkHdr;
+
+               if ( srcBufSize > _MIN_WAVE_HEADER_SIZE )
+               {
+                       memcpy(&riffHdr, pSrcBuf, sizeof(riffHdr)); // file header of 12 bytes
+                       offSet += sizeof(riffHdr);
+                       memcpy(&chunkHdr, pSrcBuf + offSet, sizeof(chunkHdr)); // format sub chunk  header of 8 bytes
+                       offSet += sizeof(chunkHdr);
+                       memcpy(&wavFormatInfo, pSrcBuf + offSet, sizeof(wavFormatInfo)); // format sub chunk consists of wave info 16 bytes
+                       offSet += sizeof(wavFormatInfo);
+                       // assign to codec context if it is mono or stereo
+                       if ( riffHdr.chunkId == _RIFF_CHUNK_ID && riffHdr.format== _RIFF_FORMAT_WAVE )
+                       {
+                               __pCodecCtx->channels = wavFormatInfo.channels;
+                               __decoderConfigured = true;
+                               // Data starts in next sub chunk
+                               memcpy(&chunkHdr, pSrcBuf + offSet, sizeof(chunkHdr)); // data sub chunk  header of 8 bytes
+                               offSet += sizeof(chunkHdr); // offset is now at data start
+                       }
+                       else
+                       {
+                               offSet = 0; // Header info is not available
+                       }
+
+               }
+
+       }
+#endif
+
+       av_init_packet(&inputPacket);
+
+       inputPacket.size = srcBufSize -offSet;
+       inputPacket.data = (uint8_t*)pSrcBuf + offSet;
+
+       if (dstBufSize >= MIN_OUT_BUFFER_SIZE)
+       {
+               pOutBuf = pDstBuf;
+               outBufSize = dstBufSize;
+       }
+       else
+       {
+               pOutBuf = __pOutBuf;
+               outBufSize = MIN_OUT_BUFFER_SIZE;
+       }
+
+       SysTryCatch(NID_MEDIA, __decoderConfigured == true, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));
+       res = avcodec_decode_audio3(__pCodecCtx, (int16_t*)pOutBuf, &outBufSize, &inputPacket);
+       SysTryCatch(NID_MEDIA, (res > 0 && outBufSize > 0), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));
+
+       SysTryCatch(NID_MEDIA, dstBufSize >= outBufSize, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+
+       dstBufUsed = outBufSize; // the decoded audio data size
+       srcBufUsed = res + offSet; // // input bytes used + offset header that is skipped
+       if (pOutBuf != pDstBuf)
+       {
+               memcpy(pDstBuf, pOutBuf, outBufSize);
+       }
+       __decodeCalled = true;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AlawDecoder::Probe(const byte* pSrcBuf, const int srcBufSize,
+                                  AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate)
+{
+       result r = E_SUCCESS;
+       int dstBufUsed = 0;
+       int srcBufUsed = 0;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, pSrcBuf != null && srcBufSize > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+
+       r = Decode(pSrcBuf, srcBufSize, srcBufUsed, __pOutBuf, MIN_OUT_BUFFER_SIZE, dstBufUsed);
+
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Decode failed", GetErrorMessage(r));
+
+       channelType = _FfmpegUtil::ToAudioChannelType(__pCodecCtx->channels);
+       sampleType = _FfmpegUtil::ToAudioSampleType(__pCodecCtx->sample_fmt);
+       sampleRate = __pCodecCtx->sample_rate;
+
+       SetLastResult(E_SUCCESS);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AlawDecoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       avcodec_flush_buffers(__pCodecCtx);
+
+       __decodeCalled = false;
+       __decoderConfigured = false;
+
+       SetLastResult(E_SUCCESS);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AlawDecoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, __decodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+               value = _FfmpegUtil::ToAudioChannelType(__pCodecCtx->channels);
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE:
+               value = _FfmpegUtil::ToAudioSampleType(__pCodecCtx->sample_fmt);
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+               value = __pCodecCtx->sample_rate;
+       break;
+
+       default:
+               r = E_OBJ_NOT_FOUND;
+       break;
+       }
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AlawDecoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, __decodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_AlawDecoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+       pList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE);
+       pList->Add(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE);
+       pList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE);
+       SetLastResult(r);
+       return pList;
+
+CATCH:
+       return null;
+}
+
+bool
+_AlawDecoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, type == MEDIA_PROPERTY_AUDIO_SAMPLE_RATE ||
+                          type == MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE ||
+                          type == MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                         "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+} } // Tizen::Media
diff --git a/src/FMedia_AlawDecoder.h b/src/FMedia_AlawDecoder.h
new file mode 100644 (file)
index 0000000..639098d
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMedia_AlawDecoder.h
+ * @brief  This is the header file for the Tizen::Media::_AlawDecoder.
+ *
+ * This header file contains the declarations of the Tizen::Media::_AlawDecoder.
+ */
+#ifndef _FMEDIA_INTERNAL_ALAWDECODER_H_
+#define _FMEDIA_INTERNAL_ALAWDECODER_H_
+
+
+namespace Tizen { namespace Media
+{
+
+// Generally fiel header + format sub chunk is  36  byte + data chunk header 8 bytes;
+static const int _MIN_WAVE_HEADER_SIZE = 44;
+static const unsigned int _RIFF_CHUNK_ID = 0x46464952; // 'RIFF'
+static const unsigned int _RIFF_FORMAT_WAVE = 0x45564157; // 'WAVE'
+static const unsigned int _WAVE_FORMAT_CHUNK_ID = 0x20746d66; // 'fmt '
+static const unsigned int _WAVE_DATA_CHUNK_ID = 0x61746164; // 'data'
+
+struct _WavFormatInfo
+{
+       unsigned short formatTag;
+       unsigned short channels;
+       unsigned int samplesPerSec;
+       unsigned int avgBytesPerSec;
+       unsigned short blockAlign;
+       unsigned short bitsPerSample;
+};
+
+struct _RiffFileHeader
+{
+       unsigned int chunkId;
+       unsigned int size;
+       unsigned int format;
+};
+
+struct _RiffChunkHeader
+{
+       unsigned int chunkId;
+       unsigned int size;
+};
+
+class _AlawDecoder
+       : public _IAudioDecoder
+{
+public:
+       _AlawDecoder(void);
+
+       virtual ~_AlawDecoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* srcBuf, const int length,
+                                                AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate);
+
+       virtual result Decode(const byte* srcBuf, int srcBufSize, int &srcBufUsed,
+                                                 byte* dstBuf, int dstBufSize, int &dstBufUsed);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+private:
+       static const int MIN_OUT_BUFFER_SIZE = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+       static const int INPUT_BUFFER_PADDING_SIZE = 8;
+       static const int MONO_CHANNEL = 1;
+       static const int STEREO_CHANNEL = 2;
+
+       _AlawDecoder(const _AlawDecoder&);
+
+       _AlawDecoder& operator =(const _AlawDecoder&);
+
+private:
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       bool __decodeCalled;
+       byte* __pOutBuf;
+       bool __decoderConfigured;
+};
+
+} } // Tizen::Media
+
+#endif // _FMEDIA_INTERNAL_AlawDecoder_H_
diff --git a/src/FMedia_AmrDecoder.cpp b/src/FMedia_AmrDecoder.cpp
new file mode 100644 (file)
index 0000000..f2d086f
--- /dev/null
@@ -0,0 +1,364 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseColHashMap.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseInteger.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include <FMedia_Ffmpeg.h>
+#include "FMedia_AmrDecoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_IAudioDecoder*
+_AmrDecoder_CreateInstance(void)
+{
+       return new (std::nothrow) _AmrDecoder();
+}
+
+_AmrDecoder::_AmrDecoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __isDecodeCalled = false;
+       __pResampleContext = null;
+       __isHdrParsingDone = false;
+       __pOutBuf = null;
+}
+
+_AmrDecoder::~_AmrDecoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       if (__pResampleContext != null)
+       {
+               audio_resample_close(__pResampleContext);
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+       }
+}
+
+
+result
+_AmrDecoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+
+       SysAssertf((__pCodecCtx == null && __pCodec == null), " Already Constructed .");\r
+
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                           "[%s] AVCODEC Context Allcoation Failed",GetErrorMessage(E_SYSTEM));\r
+       __pCodec = avcodec_find_decoder(CODEC_ID_AMR_NB);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Find Decoder Failed for CODEC_ID_AMR_NB ",GetErrorMessage(E_SYSTEM));\r
+\r
+       __pCodecCtx->sample_rate = DEFAULT_SAMPLE_RATE;
+       __pCodecCtx->channels = 1; // AMR is always mono channel
+
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Codec Open Failed for CODEC_ID_AMR_NB",GetErrorMessage(E_SYSTEM));\r
+
+       // AVCodecContext parameters
+       if (__pCodec->capabilities & CODEC_CAP_TRUNCATED)
+       {
+               __pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+       }
+
+       __pCodecCtx->debug_mv = 0; //set by user
+       __pCodecCtx->debug = 0; //set by user
+       __pCodecCtx->workaround_bugs = 1; //set by user
+       __pCodecCtx->lowres = 0; //set by user
+       __pCodecCtx->skip_frame = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_idct = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_loop_filter = AVDISCARD_DEFAULT; //set by user
+
+       __pOutBuf = new (std::nothrow) byte[DECODED_FRAME_SIZE];
+       SysTryCatch(NID_MEDIA, __pOutBuf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+
+       return r;
+
+CATCH:
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+               __pOutBuf = null;
+       }
+       return r;
+}
+
+result
+_AmrDecoder::Decode(const byte* pSrcBuf, int srcBufSize, int &srcBufUsed,
+                                       byte* pDstBuf, int dstBufSize, int &dstBufUsed)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVPacket inputPacket;
+       int outBufSize = DECODED_FRAME_SIZE;
+       int samples = 0;
+       bool hasHdr = false;
+       byte* pOutBuf = null;
+
+
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, (pSrcBuf != null && pDstBuf != null && srcBufSize > 0 && dstBufSize >= 0 ),
+                          r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+
+       av_init_packet(&inputPacket);
+       inputPacket.size = srcBufSize;
+       inputPacket.data = (uint8_t*) pSrcBuf;
+
+       // Check whether the buffer passed has the amr header
+       if (!__isHdrParsingDone)
+       {
+               int i = 0;
+               if ( pSrcBuf[i] == 0x23 && pSrcBuf[i+1] == 0x21 && pSrcBuf[i+2] == 0x41 &&
+                        pSrcBuf[i+3] == 0x4D && pSrcBuf[i+4] == 0x52 && pSrcBuf[i+5] == 0x0A)
+               {
+                       // The input buffer has the header
+                       inputPacket.size = srcBufSize - NB_HEADER_SIZE;
+                       inputPacket.data = (uint8_t*)( pSrcBuf + NB_HEADER_SIZE);
+                       hasHdr = true;
+               }
+               __isHdrParsingDone = true;
+       }
+       // Decoding the Audio  packet
+       pOutBuf = __pOutBuf;
+       res = avcodec_decode_audio3(__pCodecCtx, (int16_t*)pOutBuf, &outBufSize, &inputPacket);
+       SysTryCatch(NID_MEDIA, (res > 0 && outBufSize > 0), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));\r
+       if (__pCodecCtx->sample_fmt  == AV_SAMPLE_FMT_FLT)
+       {
+               if (!__pResampleContext)
+               {
+                       __pResampleContext =
+                               av_audio_resample_init(AUDIO_CHANNEL_TYPE_MONO, __pCodecCtx->channels,
+                                                                          DEFAULT_SAMPLE_RATE, __pCodecCtx->sample_rate,
+                                                                          AV_SAMPLE_FMT_S16, __pCodecCtx->sample_fmt,
+                                                                          0, 0, 0, 0);
+                       SysTryCatch(NID_MEDIA, __pResampleContext != null, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                                         "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));\r
+               }
+               SysTryCatch(NID_MEDIA, dstBufSize >= S16_FRAME_SIZE, r = E_OUT_OF_MEMORY,
+                                  E_OUT_OF_MEMORY, "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+
+               samples = audio_resample (__pResampleContext, (short *) pDstBuf, (short *)pOutBuf, outBufSize/4);
+               dstBufUsed = samples  * 2; // The decoded audio data size since each sample is 2 bytes
+               srcBufUsed = res; //Input bytes used
+               // Header bytes are also consumed
+               if (hasHdr)
+               {
+                       srcBufUsed += NB_HEADER_SIZE;
+               }
+               __isDecodeCalled = true;
+       }
+
+       return r;
+
+CATCH:
+
+       return r;
+}
+
+result
+_AmrDecoder::Probe(const byte* pSrcBuf, const int srcBufLength,
+                                  Tizen::Media::AudioSampleType& sampleType,
+                                  Tizen::Media::AudioChannelType& channelType, int& sampleRate)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVPacket inputPacket;
+       int outBufSize = DECODED_FRAME_SIZE;
+       byte* pOutBuf = null;
+
+
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, (pSrcBuf != null && srcBufLength > 0), r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+
+       av_init_packet(&inputPacket);
+
+       inputPacket.size = srcBufLength;
+       inputPacket.data = (uint8_t*) pSrcBuf;
+
+       if (!__isHdrParsingDone)
+       {
+               int i = 0;
+               if ( pSrcBuf[i] == 0x23 && pSrcBuf[i+1] == 0x21 && pSrcBuf[i+2] == 0x41 &&
+                        pSrcBuf[i+3] == 0x4D && pSrcBuf[i+4] == 0x52 && pSrcBuf[i+5] == 0x0A)
+               {
+                       // The input buffer has the header
+                       inputPacket.size = srcBufLength - NB_HEADER_SIZE;
+                       inputPacket.data = (uint8_t*)( pSrcBuf + NB_HEADER_SIZE);
+                       SysLog(NID_MEDIA, "Has AMR HEADER");
+               }
+       }
+       // Decoding the Audio  packet
+       pOutBuf = __pOutBuf;
+       res = avcodec_decode_audio3(__pCodecCtx, (int16_t*)pOutBuf, &outBufSize, &inputPacket);
+       SysTryCatch(NID_MEDIA, (res > 0 && outBufSize > 0), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));\r
+
+       channelType = AUDIO_CHANNEL_TYPE_MONO;
+       sampleType = AUDIO_TYPE_PCM_S16_LE;
+       sampleRate = DEFAULT_SAMPLE_RATE;
+       __isDecodeCalled = true;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AmrDecoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       avcodec_flush_buffers(__pCodecCtx);
+       __isDecodeCalled = false;
+       __isHdrParsingDone = false;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AmrDecoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, 0 < type, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, __isDecodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+               value = AUDIO_CHANNEL_TYPE_MONO;
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE:
+               value = AUDIO_TYPE_PCM_S16_LE;
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+               value = DEFAULT_SAMPLE_RATE;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AmrDecoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, 0 < type, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, type < MEDIA_PROPERTY_VIDEO_WIDTH || type >= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));\r
+       SysTryCatch(NID_MEDIA, __isDecodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_AmrDecoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pPropList = new  (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pPropList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE);
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE);
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE);
+       SetLastResult(r);
+       return pPropList;
+
+CATCH:
+       return null;
+}
+
+bool
+_AmrDecoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, (__pCodecCtx != null && __pCodec != null), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, (type == MEDIA_PROPERTY_AUDIO_SAMPLE_RATE || type == MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE ) ||
+                          (type == MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE  ), r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));\r
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+};
+};
diff --git a/src/FMedia_AmrDecoder.h b/src/FMedia_AmrDecoder.h
new file mode 100644 (file)
index 0000000..71aca0f
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file  FMedia_AmrDecoder.h
+ *  @brief This is the header file for the Tizen::Media::_AmrDecoder.
+ *
+ *  This header file contains the declarations of the Tizen::Media::_AmrDecoder.
+ */
+
+
+#ifndef _FMEDIA_INTERNAL_AMRDECODER_H_
+#define _FMEDIA_INTERNAL_AMRDECODER_H_
+
+#include "FMedia_IAudioDecoder.h"
+
+namespace Tizen { namespace Media
+{
+
+
+class _AmrDecoder
+       : public _IAudioDecoder
+{
+public:
+       _AmrDecoder(void);
+
+       virtual ~_AmrDecoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* srcBuf, const int length,
+                                                AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate);
+
+       virtual result Decode(const byte* srcBuf, int srcBufSize, int &srcBufUsed,
+                                                 byte* dstBuf, int dstBufSize, int& dstBufUsed);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+private:
+       static const int DECODED_FRAME_SIZE = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+       static const int S16_FRAME_SIZE = 320; //Decoded AMR framesize
+       static const int NB_HEADER_SIZE = 6;
+       static const int DEFAULT_SAMPLE_RATE = 8000; //AMR Sample rate
+
+       _AmrDecoder(const _AmrDecoder&);
+
+       _AmrDecoder& operator =(const _AmrDecoder&);
+
+private:
+       bool __isDecodeCalled;
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       ReSampleContext* __pResampleContext;
+       bool __isHdrParsingDone;
+       byte* __pOutBuf;
+};
+
+} } // Tizen::Media
+
+#endif // FMEDIA_INTERNAL_AMRDECODER_H_
diff --git a/src/FMedia_AmrEncoder.cpp b/src/FMedia_AmrEncoder.cpp
new file mode 100644 (file)
index 0000000..3427a8e
--- /dev/null
@@ -0,0 +1,214 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <unique_ptr.h>
+#include <interf_enc.h>
+#include <FBaseColHashMap.h>
+#include <FBaseInteger.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_AmrEncoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace Media
+{
+
+_IAudioEncoder*
+_AmrEncoder_CreateInstance(void)
+{
+       return new (std::nothrow) _AmrEncoder();
+}
+
+_AmrEncoder::_AmrEncoder(void)
+{
+       __pEnc = null;
+       __encBitrate = MR122;
+       __frameCount = 0;
+}
+
+_AmrEncoder::~_AmrEncoder(void)
+{
+       if (__pEnc != null)
+       {
+               Encoder_Interface_exit(__pEnc);
+               __pEnc = null;
+       }
+}
+
+result
+_AmrEncoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       Integer* pKey = null;
+       Integer* pValue = null;
+       int key = -1;
+       int value = -1;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc == null, E_INVALID_STATE, "already constructed");
+
+       if (pOption != null)
+       {
+               // The initialization values are given in the Hashmap
+               std::unique_ptr<IMapEnumerator> pMapEnum(pOption->GetMapEnumeratorN());
+               if (pMapEnum.get() != null)
+               {
+                       while (pMapEnum.get()->MoveNext() == E_SUCCESS)
+                       {
+                               pKey = static_cast<Integer*>(pMapEnum.get()->GetKey());
+                               pValue = static_cast<Integer*>(pMapEnum.get()->GetValue());
+
+                               if (pKey != null && pValue != null)
+                               {
+                                       key = pKey->ToInt();
+                                       value = pValue->ToInt();
+
+                                       switch (key)
+                                       {
+                                       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+                                               SysTryCatch(NID_MEDIA, value == AUDIO_CHANNEL_TYPE_MONO || value == AUDIO_CHANNEL_TYPE_STEREO,
+                                                                  r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Audio Channel Type is out of range :%d", GetErrorMessage(E_OUT_OF_RANGE), value);
+                                               break;
+
+                                       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+                                               SysTryCatch(NID_MEDIA, value == 8000, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Audio sampleRate is out of range :%d", GetErrorMessage(E_OUT_OF_RANGE), value);
+                                               break;
+
+                                       case MEDIA_PROPERTY_AUDIO_BIT_RATE:
+                                               SysTryCatch(NID_MEDIA, (value > 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Audio bitrate is out of range :%d", GetErrorMessage(E_OUT_OF_RANGE), value);
+                                               __encBitrate = GetBitrateMode(value);
+                                               SysTryCatch(NID_MEDIA, __encBitrate >= 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Audio bitrate is out of range %d %d", GetErrorMessage(E_OUT_OF_RANGE), value, __encBitrate);
+                                               break;
+
+                                       default:
+                                               break;
+                                       }
+                               }
+                       }
+
+               }
+       }
+       //intialising using opencore amr
+       __pEnc = Encoder_Interface_init(0);
+       SysTryCatch(NID_MEDIA, __pEnc != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] Encoder init failed", GetErrorMessage(E_SYSTEM));
+
+       return r;
+
+CATCH:
+
+       if (__pEnc != null)
+       {
+               Encoder_Interface_exit(__pEnc);
+               __pEnc = null;
+       }
+       return r;
+}
+
+result
+_AmrEncoder::Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       byte outBuf[DECODED_FRAME_SIZE];
+       memset(outBuf, 0, sizeof(outBuf));
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+
+       //Partial frame encoding is supported by the open core amr_nb library . So no need of checking sourcebuf length.
+       SysTryCatch(NID_MEDIA, srcBuf != null && dstBuf != null
+                          && srcBufLength > 0 && dstBufLength > 0,
+                          r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Invalid argument is used. 0x%x %d 0x%x %d",
+                          srcBuf, srcBufLength, dstBuf, dstBufLength);
+
+       // Encoding the Audio  packet using the amr open core
+       // Accomodating for destinationBuf less than encoded frame size.
+       if (dstBufLength >= DECODED_FRAME_SIZE )
+       {
+               res = Encoder_Interface_Encode(__pEnc, __encBitrate, (const short*)srcBuf, dstBuf, 0);
+       }
+       else
+       {
+               res = Encoder_Interface_Encode(__pEnc, __encBitrate, (const short*)srcBuf,(byte*) outBuf, 0);
+       }
+
+       SysTryCatch(NID_MEDIA, res > 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] Amr Encoding Failed:%d", GetErrorMessage(E_SYSTEM), res);
+       SysTryCatch(NID_MEDIA, res <= dstBufLength, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Amr Encoding Failed %d %d", GetErrorMessage(E_OUT_OF_MEMORY), res, dstBufLength);
+
+       if (dstBufLength < DECODED_FRAME_SIZE )
+       {
+               memcpy(dstBuf, outBuf, res);
+       }
+       srcBufLength = DECODED_FRAME_SIZE;
+       dstBufLength = res;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AmrEncoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+       return r;
+}
+
+Mode
+_AmrEncoder::GetBitrateMode(int bitrate)
+{
+       // make the correspondance between bitrate and mode
+       static struct _AmrBitRate
+       {
+               int  key;
+               Mode value;
+       } map[] = {
+               { 4750, MR475},
+               { 5150, MR515},
+               { 5900, MR59},
+               { 6700, MR67},
+               { 7400, MR74},
+               { 7950, MR795},
+               {10200, MR102},
+               {12200, MR122},
+       };
+       Mode mode = MR122;
+
+       for (unsigned int i = 0; i < sizeof(map)/sizeof(map[0]); i++)
+       {
+               if (map[i].key == bitrate)
+               {
+                       return map[i].value;
+               }
+       }
+
+       return mode;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_AmrEncoder.h b/src/FMedia_AmrEncoder.h
new file mode 100644 (file)
index 0000000..c7ea003
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_AmrEncoder.h
+ *  @brief  This is the header file for the _AmrEncoder.
+ *
+ *  This header file contains the declarations of the _AmrEncoder
+ */
+#ifndef FMEDIA_INTERNAL_AMRENCODER_H_
+#define FMEDIA_INTERNAL_AMRENCODER_H_
+
+#include "FMedia_IAudioEncoder.h"
+
+namespace Tizen { namespace Media
+{
+
+class _AmrEncoder
+       : public _IAudioEncoder
+{
+public:
+       _AmrEncoder(void);
+
+       virtual ~_AmrEncoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength);
+
+       virtual result Reset(void);
+
+private:
+       static const int INPUT_BUFFER_PADDING_SIZE = 8;
+       //Decoded AMR framesize
+       static const int DECODED_FRAME_SIZE = 320;
+       static const int SAMPLE_RATE_COUNT = 8 ;
+       //AMR Sample rate
+       static const int DEFAULT_SAMPLE_RATE = 8000;
+
+       _AmrEncoder(const _AmrEncoder&);
+
+       _AmrEncoder& operator =(const _AmrEncoder&);
+       Mode GetBitrateMode(int bitrate);
+
+private:
+       int __frameCount;
+       void *__pEnc;
+       Mode  __encBitrate;
+};
+
+};
+};
+
+
+#endif // FMEDIA_AMRENCODEROPENCORE_H_
diff --git a/src/FMedia_AudioDecoderImpl.cpp b/src/FMedia_AudioDecoderImpl.cpp
new file mode 100644 (file)
index 0000000..d9c0dcc
--- /dev/null
@@ -0,0 +1,201 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions andW
+// limitations under the License.
+//
+
+#include <FBaseColArrayListT.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColHashMapT.h>
+
+#include <FBaseSysLog.h>
+
+#include "FMedia_IAudioDecoder.h"
+#include "FMedia_CodecFactory.h"
+#include "FMedia_AudioDecoderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace Media
+{
+
+_AudioDecoderImpl::_AudioDecoderImpl(void)
+{
+       __pDec = null;
+}
+
+_AudioDecoderImpl::~_AudioDecoderImpl(void)
+{
+       if (__pDec != null)
+       {
+               delete __pDec;
+       }
+}
+
+result
+_AudioDecoderImpl::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
+{
+       _CodecFactory* pFactory = null;
+       result r = E_SUCCESS;
+
+       SysTryReturn(NID_MEDIA, __pDec == null, E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] Already Constructed");
+       SysAssertf(__pDec == null, " Already Constructed .");\r
+       \r
+
+       pFactory = _CodecFactory::GetInstance();
+       SysTryCatch(NID_MEDIA, pFactory != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] GetFactoryInstance Failed",GetErrorMessage(E_SYSTEM));\r
+       r = pFactory->CreateCodecInstance(type, __pDec);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                          "[%s] CreateCodecInstance failed:%d", GetErrorMessage(r), type);
+       r = __pDec->Construct(pOption);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] dec.Construct Failed", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       if (__pDec != null)
+       {
+               delete __pDec;
+               __pDec = null;
+       }
+       return r;
+}
+
+result
+_AudioDecoderImpl::Probe(const Tizen::Base::ByteBuffer& srcBuf, AudioSampleType& sampleType,
+                                                AudioChannelType& channelType, int& sampleRate)
+{
+       result r = E_SUCCESS;
+       const byte* pSrcBuf = null;
+       int srcBufSize = 0;
+
+       SysTryReturn(NID_MEDIA, __pDec != null, E_INVALID_STATE, E_INVALID_STATE,
+                               "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+
+       SysTryCatch(NID_MEDIA, srcBuf.GetPointer() != null, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] The input argument is invalid",GetErrorMessage(E_INVALID_ARG));\r
+
+       pSrcBuf = srcBuf.GetPointer() + srcBuf.GetPosition();
+       srcBufSize = srcBuf.GetRemaining();
+       SysTryCatch(NID_MEDIA, srcBufSize > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] The input argument is invalid",GetErrorMessage(E_INVALID_ARG));\r
+       r = __pDec->Probe(pSrcBuf, srcBufSize, sampleType, channelType, sampleRate);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Probe Failed", GetErrorMessage(r));
+
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AudioDecoderImpl::Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf)
+{
+       result r = E_SUCCESS;
+       const byte* pSrcBuf = null;
+       byte* pDstBuf = null;
+       int srcBufSize = 0;
+       int dstBufSize = 0;
+       int srcBufUsed = 0;
+       int dstBufUsed = 0;
+
+       SysTryReturn(NID_MEDIA, __pDec != null, E_INVALID_STATE, E_INVALID_STATE,
+                               "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+
+       SysTryCatch(NID_MEDIA, srcBuf.GetPointer() != null && dstBuf.GetPointer() != null,
+                          r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] srcBuf:0x%x dstBuf:0x%x", GetErrorMessage(E_INVALID_ARG), srcBuf.GetPointer(), dstBuf.GetPointer());\r
+       pSrcBuf = srcBuf.GetPointer() + srcBuf.GetPosition();
+       pDstBuf = (byte*)dstBuf.GetPointer() + dstBuf.GetPosition();
+       srcBufSize = srcBuf.GetRemaining();
+       dstBufSize = dstBuf.GetRemaining();
+       SysTryCatch(NID_MEDIA, srcBufSize > 0 && dstBufSize > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] srcSize:%d dstSize:%d", GetErrorMessage(E_INVALID_ARG), srcBufSize, dstBufSize);\r
+
+       r = __pDec->Decode(pSrcBuf, srcBufSize, srcBufUsed, pDstBuf, dstBufSize, dstBufUsed);
+
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] dec.Decode", GetErrorMessage(r));
+
+       r = srcBuf.SetPosition(srcBuf.GetPosition() + srcBufUsed);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] srcBuf overflow", GetErrorMessage(r));
+
+       r = dstBuf.SetPosition(dstBuf.GetPosition() + dstBufUsed);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] dstBuf overflow", GetErrorMessage(r));
+
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AudioDecoderImpl::Reset(void)
+{
+
+       SysTryReturn(NID_MEDIA, __pDec != null, E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] Not Constructed");
+       return __pDec->Reset();
+}
+
+result
+_AudioDecoderImpl::GetValue(MediaPropertyType key, int& value) const
+{
+       SysTryReturn(NID_MEDIA, __pDec != null, E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] Not Constructed");
+       return __pDec->GetValue(key, value);
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_AudioDecoderImpl::GetSupportedPropertyListN(void) const
+{
+
+       SysTryReturn(NID_MEDIA, __pDec != null, null, E_INVALID_STATE,
+                               "[E_INVALID_STATE] Not Constructed");
+       return __pDec->GetSupportedPropertyListN();
+}
+
+bool
+_AudioDecoderImpl::IsPropertySupported(MediaPropertyType key) const
+{
+       SysTryReturn(NID_MEDIA, __pDec != null, false, E_INVALID_STATE,
+                               "[E_INVALID_STATE] Not Constructed");
+       return  __pDec->IsPropertySupported(key);
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+_AudioDecoderImpl::GetSupportedCodecListN(void)
+{
+       _CodecFactory* pFactory = null;
+       Tizen::Base::Collection::IListT<CodecType>* pList = null;
+
+       pFactory = _CodecFactory::GetInstance();
+       SysTryReturn(NID_MEDIA, pFactory != null, null, E_OUT_OF_MEMORY, "[%s] Propagated.",
+                               GetErrorMessage(GetLastResult()));
+       pList = pFactory->GetSupportedAudioDecoderListN();
+       SysTryReturn(NID_MEDIA, pList != null, null, E_OUT_OF_MEMORY, "[%s] Propagated.",
+                               GetErrorMessage(GetLastResult()));
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_AudioDecoderImpl.h b/src/FMedia_AudioDecoderImpl.h
new file mode 100644 (file)
index 0000000..1310f57
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_AudioDecoderImpl.h
+ *  @brief  This is the header file for _AudioDecoderImpl class.
+ *
+ *  This header file contains the declarations of _AudioDecoderImpl class.
+ */
+#ifndef _FMEDIA_INTERNAL_AUDIODECODER_IMPL_H_
+#define _FMEDIA_INTERNAL_AUDIODECODER_IMPL_H_
+
+namespace Tizen { namespace Media
+{
+
+class _AudioDecoderImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * @see AudioDecoder
+        */
+       _AudioDecoderImpl(void);
+
+       /**
+        * @see AudioDecoder
+        */
+       virtual ~_AudioDecoderImpl(void);
+
+       /**
+        * @see AudioDecoder::Construct()
+        */
+       result Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption = null);
+
+public:
+       /**
+        * @see AudioDecoder::Probe()
+        */
+       result Probe(const Tizen::Base::ByteBuffer& srcBuf,
+                                AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate);
+
+       /**
+        * @see AudioDecoder::Decode()
+        */
+       result Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf);
+
+       /**
+        * @see AudioDecoder::Reset()
+        */
+       result Reset(void);
+
+       /**
+        * @see AudioDecoder::GetValud()
+        */
+       result GetValue(MediaPropertyType key, int& value) const;
+
+       /**
+        * @see AudioDecoder::GetSupportedPropertyListN()
+        */
+       Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       /**
+        * @see AudioDecoder::IsPropertySupported()
+        */
+       bool IsPropertySupported(MediaPropertyType key) const;
+
+       /**
+        * @see AudioDecoder::GetSupportedCodecListN()
+        */
+       static Tizen::Base::Collection::IListT<CodecType>* GetSupportedCodecListN(void);
+
+private:
+       _AudioDecoderImpl(const _AudioDecoderImpl& rhs);
+       _AudioDecoderImpl& operator =(const _AudioDecoderImpl& rhs);
+
+       class _IAudioDecoder* __pDec;
+};
+
+} } // Tizen::Media
+
+#endif // _FMEDIA_INTERNAL_AUDIODECODER_IMPL_H_
diff --git a/src/FMedia_AudioEncoderImpl.cpp b/src/FMedia_AudioEncoderImpl.cpp
new file mode 100644 (file)
index 0000000..16af53f
--- /dev/null
@@ -0,0 +1,167 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColHashMapT.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_IAudioEncoder.h"
+#include "FMedia_CodecFactory.h"
+#include "FMedia_AudioEncoderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace Media
+{
+
+_AudioEncoderImpl::_AudioEncoderImpl(void)
+{
+       __pEnc = null;
+}
+
+_AudioEncoderImpl::~_AudioEncoderImpl(void)
+{
+       if (__pEnc != null)
+       {
+               delete __pEnc;
+       }
+}
+
+result
+_AudioEncoderImpl::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
+{
+       _CodecFactory* pFactory = null;
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc == null, E_INVALID_STATE, "already constructed");
+       pFactory = _CodecFactory::GetInstance();
+       SysTryCatch(NID_MEDIA, pFactory != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] Failed to get Codec Factory Instance",GetErrorMessage(E_SYSTEM));\r
+       r = pFactory->CreateCodecInstance(type, __pEnc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] CodecFactory failed to create Codec Instance", GetErrorMessage(r));\r
+       r = __pEnc->Construct(pOption);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct __pEnc", GetErrorMessage(r));\r
+       return r;
+
+CATCH:
+       if (__pEnc != null)
+       {
+               delete __pEnc;
+               __pEnc = null;
+       }
+       return r;
+}
+
+result
+_AudioEncoderImpl::Encode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf)
+{
+       result r = E_INVALID_STATE;
+       const byte* pSrcByte = null;
+       byte* pDstByte = null;
+       int srcByteSize = 0;
+       int dstByteSize = 0;
+       int offset = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+       pSrcByte = srcBuf.GetPointer() + srcBuf.GetPosition();
+       pDstByte = (byte*) dstBuf.GetPointer() + dstBuf.GetPosition();
+       SysTryCatch(NID_MEDIA, pDstByte != null && pSrcByte != null, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. srcBuf:%x dstBuf:%d", GetErrorMessage(E_INVALID_ARG), pSrcByte, pDstByte);\r
+       srcByteSize = srcBuf.GetRemaining();
+       dstByteSize = dstBuf.GetRemaining();
+       SysTryCatch(NID_MEDIA, srcByteSize > 0 && dstByteSize > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. srcSize:%d dstSize:%d", GetErrorMessage(E_INVALID_ARG), srcByteSize, dstByteSize);\r
+
+       r = __pEnc->Encode(pSrcByte, srcByteSize, pDstByte, dstByteSize);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Audio Encoder encode failed", GetErrorMessage(r));\r
+
+       offset = srcBuf.GetPosition();
+       if (offset + srcByteSize > srcBuf.GetLimit())
+       {
+               srcBuf.SetPosition(srcBuf.GetLimit());
+       }
+       else
+       {
+               srcBuf.SetPosition(offset + srcByteSize);
+       }
+
+       offset = dstBuf.GetPosition();
+       if (offset + dstByteSize > dstBuf.GetLimit())
+       {
+               dstBuf.SetPosition(dstBuf.GetLimit());
+       }
+       else
+       {
+               dstBuf.SetPosition(offset + dstByteSize);
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AudioEncoderImpl::Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+       r = __pEnc->Encode(srcBuf, srcBufLength, dstBuf, dstBufLength);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Audio Encoder encode failed", GetErrorMessage(r));\r
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_AudioEncoderImpl::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+       r = __pEnc->Reset();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Audio Encoder reset failed", GetErrorMessage(r));\r
+       return r;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+_AudioEncoderImpl::GetSupportedCodecListN(void)
+{
+       _CodecFactory* pFactory = null;
+       Tizen::Base::Collection::IListT<CodecType>* pList = null;
+
+       pFactory = _CodecFactory::GetInstance();
+       SysTryReturn(NID_MEDIA, pFactory != null, null, E_OUT_OF_MEMORY, "[%s] Propagating.",\r
+                               GetErrorMessage(GetLastResult()));
+       pList = pFactory->GetSupportedAudioEncoderListN();
+       SysTryReturn(NID_MEDIA, pList != null, null, E_OUT_OF_MEMORY, "[%s] Propagating.",\r
+                               GetErrorMessage(GetLastResult()));
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_AudioEncoderImpl.h b/src/FMedia_AudioEncoderImpl.h
new file mode 100644 (file)
index 0000000..a0d5dac
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_AudioEncoderImpl.h
+ *  @brief  This is the header file for _AudioEncoderImpl class.
+ *
+ *  This header file contains the declarations of _AudioEncoderImpl class.
+ */
+#ifndef FMEDIA_INTERNAL_AUDIOENCODERIMPL_H_
+#define FMEDIA_INTERNAL_AUDIOENCODERIMPL_H_
+
+namespace Tizen { namespace Media
+{
+
+class _AudioEncoderImpl
+       : public Tizen::Base::Object
+{
+public:
+       _AudioEncoderImpl(void);
+
+       virtual ~_AudioEncoderImpl(void);
+
+       result Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption = null);
+
+       result Encode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf);
+
+       result Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength);
+
+       result Reset(void);
+
+       /**
+        * @see AudioEncoder::GetSupportedCodecListN()
+        */
+       static Tizen::Base::Collection::IListT<CodecType>* GetSupportedCodecListN(void);
+
+private:
+       _AudioEncoderImpl(const _AudioEncoderImpl& dec);
+       _AudioEncoderImpl& operator =(const _AudioEncoderImpl& dec);
+
+       class _IAudioEncoder* __pEnc;
+};
+
+};
+};
+
+#endif // FMEDIA_INTERNAL_AUDIOENCODERIMPL_H_
diff --git a/src/FMedia_AudioEqualizerImpl.cpp b/src/FMedia_AudioEqualizerImpl.cpp
new file mode 100644 (file)
index 0000000..144cf8b
--- /dev/null
@@ -0,0 +1,217 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include "FMedia_PlayerEvent.h"
+#include "FMedia_PlayerVideoEvent.h"
+#include "FMedia_PlayerEventTypes.h"
+#include "FMedia_PlayerVideoEventTypes.h"
+#include "FMedia_PlayerImpl.h"
+#include "FMedia_AudioEqualizerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace Media
+{
+
+_AudioEqualizerImpl::_AudioEqualizerImpl(void):__pPlayerImpl(null)
+{
+
+}
+
+_AudioEqualizerImpl::~_AudioEqualizerImpl(void)
+{
+
+}
+
+result
+_AudioEqualizerImpl::Construct(Player& player)
+{
+       result r = E_SUCCESS;
+       __pPlayerImpl = _PlayerImpl::GetInstance(&player);
+       SysAssertf(__pPlayerImpl != null, "Not yet Player::Construct() called! Player::Construct() should be called before use");
+       SysAssertf(__pPlayerImpl->__hPlayer !=  null, "Not yet Player handle assigned.");
+       __hPlayer = __pPlayerImpl->__hPlayer;
+       SysTryCatch(NID_MEDIA, GetBandCount() != 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION,
+                                                                               "[E_UNSUPPORTED_OPERATION] Failed to construct _AudioEqualizerImpl");
+       return r;
+
+CATCH:
+       __hPlayer = null;
+       return r;
+}
+
+int
+_AudioEqualizerImpl::GetBandCount(void) const
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+       int count = 0;
+
+       ret = player_audio_effect_get_equalizer_bands_count(__hPlayer, &count);
+       r = MapExceptionToResult(ret);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform GetBandCount operation.", GetErrorMessage(r));
+
+       return count;
+}
+
+result
+_AudioEqualizerImpl::GetBandLevelRange(int index, int& minValue, int& maxValue) const
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+
+       int count = 0;
+       count = GetBandCount();
+       SysTryReturn(NID_MEDIA, index >= 0 && index < count , E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] invalid argument is used. index = %d", index);
+       ret = player_audio_effect_get_equalizer_level_range(__hPlayer, &minValue, &maxValue);
+       r = MapExceptionToResult(ret);
+       return r;
+}
+
+result
+_AudioEqualizerImpl::SetBandLevel(int index, int level)
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+       int minValue = 0;
+       int maxValue = 0;
+
+       int count = 0;
+       count = GetBandCount();
+       SysTryReturn(NID_MEDIA, index >= 0 && index < count , E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] invalid argument is used. index = %d", index);
+       r = GetBandLevelRange(index, minValue, maxValue);
+       
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "%s error has been occurred in GetBandLevelRange", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, (level <= maxValue) && (level >= minValue), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                               "[E_OUT_OF_RANGE] Equalizer level %d is out of range.", level   );
+       ret = player_audio_effect_set_equalizer_band_level(__hPlayer, index, level);
+       r = MapExceptionToResult(ret);
+       return r;
+}
+
+result
+_AudioEqualizerImpl::SetAllBandsLevel(const Tizen::Base::Collection::IListT<int>* pLevels)
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+       std::unique_ptr<int[]> pArray;
+       int level = 0;
+
+       int totalBandCount = 0;
+       totalBandCount = GetBandCount();
+       
+       int listCount = 0;
+       listCount = pLevels->GetCount();
+       
+       SysTryReturn(NID_MEDIA, listCount == totalBandCount, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. pLevels");
+       
+       pArray.reset(new (std::nothrow) int[listCount]);
+       SysTryReturn(NID_MEDIA, pArray.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory Allocation Failed");
+               
+       for(int i=0; i<listCount; i++)
+       {
+               pLevels->GetAt(i,level);
+               (pArray.get())[i] = level;
+       }
+
+       ret = player_audio_effect_set_equalizer_all_bands(__hPlayer, pArray.get(), listCount);
+       r = MapExceptionToResult(ret);
+       return r;
+}
+
+result
+_AudioEqualizerImpl::GetBandLevel(int index, int& level) const
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+
+       int count = 0;
+       count = GetBandCount();
+       SysTryReturn(NID_MEDIA, index >= 0 && index < count , E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] Invalid argument is used. Index = %d", index);
+       ret = player_audio_effect_get_equalizer_band_level(__hPlayer, index, &level);
+       r = MapExceptionToResult(ret);
+       return r;
+
+}
+
+result
+_AudioEqualizerImpl::GetBandCenterFrequency(int index, int& frequency) const
+{
+       //Not supported by SLP presently
+       result r = E_SUCCESS;
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       int ret = PLAYER_ERROR_NONE;
+       ret = player_audio_effect_get_equalizer_band_frequency(__hPlayer, index, &frequency);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] player_audio_effect_get_equlizer_band_frequency", GetErrorMessage(r));
+       return r;
+}
+
+result
+_AudioEqualizerImpl::ResetAllToDefault(void)
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+       ret = player_audio_effect_equalizer_clear(__hPlayer);
+       r = MapExceptionToResult(ret);
+       return r;
+}
+
+result
+_AudioEqualizerImpl::MapExceptionToResult(int reason)
+{
+       switch (reason)
+       {
+               case PLAYER_ERROR_NONE:
+                       return E_SUCCESS;
+                       break;
+                       
+               case PLAYER_ERROR_OUT_OF_MEMORY:
+                       return E_OUT_OF_MEMORY;
+                       break;
+
+               case PLAYER_ERROR_INVALID_PARAMETER:
+                       return E_INVALID_ARG;
+                       break;
+
+               case PLAYER_ERROR_INVALID_STATE:
+               case PLAYER_ERROR_INVALID_OPERATION:            
+                       return E_INVALID_OPERATION;
+                       break;
+                       
+               default:
+                       return E_SYSTEM;
+                       break;
+       }
+}
+
+};
+};
+
diff --git a/src/FMedia_AudioEqualizerImpl.h b/src/FMedia_AudioEqualizerImpl.h
new file mode 100644 (file)
index 0000000..25f44b8
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_AudioEqualizerImpl.h
+ *  @brief  This is the header file for _AudioEqualizerImpl class.
+ *
+ *  This header file contains the declarations of _AudioEqualizerImpl class.
+ */
+#ifndef _FMEDIA_INTERNAL_AUDIO_EQUALIZER_H_
+#define _FMEDIA_INTERNAL_AUDIO_EQUALIZER_H_
+
+namespace Tizen { namespace Media
+{
+class _PlayerImpl;
+
+class _AudioEqualizerImpl
+       : public Tizen::Base::Object
+{
+public:
+       _AudioEqualizerImpl(void);
+
+       virtual ~_AudioEqualizerImpl(void);
+
+       result Construct(Player& player);
+
+       int GetBandCount(void) const;
+
+       result GetBandLevelRange(int index, int& minValue, int& maxValue) const;
+
+       result SetBandLevel(int index, int level);
+
+       result SetAllBandsLevel(const Tizen::Base::Collection::IListT<int>* pLevels);
+
+       result GetBandLevel(int index, int& level) const;
+
+       result GetBandCenterFrequency(int index, int& frequency) const;
+
+       result ResetAllToDefault(void);
+
+private:
+       static result MapExceptionToResult(int reason);
+       
+private:
+       _AudioEqualizerImpl(const _AudioEqualizerImpl& effect);
+       _AudioEqualizerImpl& operator =(const _AudioEqualizerImpl& effect);
+
+       _PlayerImpl* __pPlayerImpl;
+       player_h __hPlayer;
+};
+
+}}
+
+#endif // _FMEDIA_INTERNAL_AUDIO_EQUALIZER_H_
diff --git a/src/FMedia_AudioInEvent.cpp b/src/FMedia_AudioInEvent.cpp
new file mode 100644 (file)
index 0000000..0386367
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseRtThread.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include "FMedia_AudioInEvent.h"
+#include "FMedia_AudioInEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Media
+{
+
+class AudioIn;
+
+_AudioInEvent::_AudioInEvent(void)
+       :__pListener(null)
+{
+}
+
+_AudioInEvent::~_AudioInEvent(void)
+{
+}
+
+result
+_AudioInEvent::Construct(void)
+{
+       result r = E_SUCCESS;
+       __pListener = null;
+
+       r = _Event::Initialize();
+       SysTryReturnResult(NID_MEDIA, r == E_SUCCESS, E_SYSTEM, "Failed to construct an instance of AudioInEvent.");
+       return r;
+}
+
+
+void
+_AudioInEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       IAudioInEventListener *pAudioInEventListener = dynamic_cast<IAudioInEventListener*> (&listener);
+       SysTryReturn(NID_MEDIA, pAudioInEventListener, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Listener is null.");
+
+       __pListener = pAudioInEventListener;
+
+       const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
+
+       _AudioInEventArg *pArg = (_AudioInEventArg*) pTempArg;
+
+       switch (pArg->GetEventType())
+       {
+       case _AUDIOIN_EVENT_RECORDED_DATA:
+               pAudioInEventListener->OnAudioInBufferIsFilled(((_AudioInEventArg *) pArg)->GetData());
+               break;
+       case _AUDIOIN_EVENT_INTERRUPTED:
+               pAudioInEventListener->OnAudioInInterrupted();
+               break;
+       case _AUDIOIN_EVENT_AUDIO_FOCUS_CHANGED:
+               pAudioInEventListener->OnAudioInAudioFocusChanged();
+               break;
+       case _AUDIOIN_EVENT_RELEASED:
+               pAudioInEventListener->OnAudioInReleased();
+               break;
+
+       default:
+               break;
+       }
+}
+};
+};
diff --git a/src/FMedia_AudioInEvent.h b/src/FMedia_AudioInEvent.h
new file mode 100644 (file)
index 0000000..848753d
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_AudioInEvent.h
+// @brief                      This header file contains the declaration related to AudioIn class
+//
+//
+
+
+#ifndef _FMEDIA_INTERNAL_AUDIOIN_EVENT_H_
+#define _FMEDIA_INTERNAL_AUDIOIN_EVENT_H_
+
+#include <FBaseRtThread.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseRt_Event.h>
+#include <FMediaIAudioInEventListener.h>
+#include <FMediaAudioIn.h>
+
+namespace Tizen { namespace Media
+{
+
+
+class _AudioInEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+public:
+       _AudioInEvent(void);
+       ~_AudioInEvent(void);
+       result Construct(void);
+
+protected:
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+private:
+       _AudioInEvent(const _AudioInEvent& rhs);
+       _AudioInEvent& operator =(const _AudioInEvent& rhs);
+       IAudioInEventListener* __pListener;
+};     // _AudioInEvent
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioInEventArg.cpp b/src/FMedia_AudioInEventArg.cpp
new file mode 100644 (file)
index 0000000..f14fce9
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMedia_AudioInEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_AudioInEventTypeArg::_AudioInEventTypeArg(void)
+       : __audioInEventType(_AUDIOIN_EVENT_NONE)
+{
+
+}
+
+_AudioInEventTypeArg::~_AudioInEventTypeArg(void)
+{
+
+}
+
+void
+_AudioInEventTypeArg::SetEventType(_AudioInEventType eType)
+{
+       __audioInEventType = eType;
+}
+
+_AudioInEventType
+_AudioInEventTypeArg::GetEventType(void) const
+{
+       return __audioInEventType;
+}
+
+_AudioInEventArg::_AudioInEventArg(void)
+       : __pAudioInData(null)
+       , __boolFlag(false)
+{
+
+}
+
+_AudioInEventArg::~_AudioInEventArg(void)
+{
+
+}
+
+void
+_AudioInEventArg::SetData(Tizen::Base::ByteBuffer* data)
+{
+       __pAudioInData = data;
+}
+
+Tizen::Base::ByteBuffer*
+_AudioInEventArg::GetData(void) const
+{
+       return __pAudioInData;
+}
+
+void
+_AudioInEventArg::SetBoolFlag(bool boolFlag)
+{
+       __boolFlag = boolFlag;
+}
+
+bool
+_AudioInEventArg::GetBoolFlag(void) const
+{
+       return __boolFlag;
+}
+
+};
+};   // Tizen::Media
diff --git a/src/FMedia_AudioInEventArg.h b/src/FMedia_AudioInEventArg.h
new file mode 100644 (file)
index 0000000..cd16a80
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_AudioInEventArg.h
+// @brief                      This header file contains the declaration related to AudioIn class.
+//
+//
+
+
+#ifndef _FMEDIA_INTERNAL_AUDIOIN_EVENTARG_H_
+#define _FMEDIA_INTERNAL_AUDIOIN_EVENTARG_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaAudioTypes.h>
+
+namespace Tizen {namespace Media
+{
+
+class _AudioInImpl;
+
+enum _AudioInEventType
+{
+       _AUDIOIN_EVENT_NONE,                                                                    // Event_None
+       _AUDIOIN_EVENT_RECORDED_DATA,                                           // Recorded Event
+       _AUDIOIN_EVENT_INTERRUPTED,                                                     // event interrupted by the system
+       _AUDIOIN_EVENT_RELEASED,                                                                // event released by the system
+       _AUDIOIN_EVENT_STOP,                                                                    // event stop callback thread
+       _AUDIOIN_EVENT_AUDIO_FOCUS_CHANGED,                                     // Event to notify that Audio focus has changed
+       _AUDIOIN_EVENT_ERROR                                                                    // Error event
+};
+
+class _AudioInEventTypeArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+       _AudioInEventTypeArg(void);
+       virtual ~_AudioInEventTypeArg(void);
+       _AudioInEventType GetEventType(void) const;
+
+private:
+       void SetEventType(_AudioInEventType eType);
+
+private:
+       _AudioInEventTypeArg(const _AudioInEventTypeArg& rhs);
+       _AudioInEventTypeArg& operator =(const _AudioInEventTypeArg& rhs);
+
+       _AudioInEventType __audioInEventType;
+
+       friend class _AudioInImpl;
+
+};
+
+class _AudioInEventArg
+       : public _AudioInEventTypeArg
+{
+public:
+       _AudioInEventArg(void);
+       ~_AudioInEventArg(void);
+       Tizen::Base::ByteBuffer* GetData(void) const;
+       bool GetBoolFlag(void) const;
+
+private:
+       void SetData(Tizen::Base::ByteBuffer* data);
+       void SetBoolFlag(bool boolFlag);
+
+private:
+       Tizen::Base::ByteBuffer* __pAudioInData;
+       bool __boolFlag;
+       friend class _AudioInImpl;
+
+};     //_AudioInEventArg
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioInImpl.cpp b/src/FMedia_AudioInImpl.cpp
new file mode 100644 (file)
index 0000000..8bb632a
--- /dev/null
@@ -0,0 +1,604 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+#include "FMedia_AudioInImpl.h"
+#include "FMedia_AudioInEvent.h"
+#include "FMedia_AudioInEventArg.h"
+#include "FMedia_AudioManagerConvert.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+bool _AudioInImpl::__isConstructed = false;
+int _AudioInImpl::__runFlag = false;
+const int _AudioInImpl::_AUDIO_IN_OPTIMAL_SAMPLE_RATE = 44100;
+const int _AudioInImpl::_AUDIO_IN_MINIMUM_BUFFER_SIZE = 1024;
+const int _AudioInImpl::_AUDIO_IN_MAXIMUM_BUFFER_SIZE = 164112;
+const AudioChannelType _AudioInImpl::_AUDIO_IN_OPTIMAL_CHANNEL_TYPE = AUDIO_CHANNEL_TYPE_STEREO;
+const AudioSampleType _AudioInImpl::_AUDIO_IN_OPTIMAL_SAMPLE_TYPE = AUDIO_TYPE_PCM_S16_LE;
+
+_AudioInImpl::_AudioInImpl(void)
+       : __audioInState(AUDIOIN_STATE_ERROR)
+       , __pAudioInEventListener(null)
+       , __audioInHandle(null)
+       , __audioInOptimalBufferSize(0)
+       , __interruptFlag(false)
+{
+}
+
+_AudioInImpl::~_AudioInImpl(void)
+{
+       result r = E_SUCCESS;
+       __isConstructed = false;
+
+       if (__audioInState < AUDIOIN_STATE_UNPREPARED && __audioInState >= AUDIOIN_STATE_PREPARED)
+       {
+               if (__audioInState == AUDIOIN_STATE_RECORDING || __audioInState == AUDIOIN_STATE_STOPPED )
+               {
+                       r = this->Reset();
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               r = this->Unprepare();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       if (__pAudioInEvent.get() && __pAudioInEventListener)
+       {
+               __pAudioInEvent->RemoveListener(*__pAudioInEventListener);
+               __pAudioInEventListener = null;
+       }
+       return;
+
+CATCH:
+       return;
+}
+
+_AudioInImpl*
+_AudioInImpl::GetInstance(AudioIn* pAudioIn)
+{
+       if (pAudioIn != null)
+       {
+               return pAudioIn->__pAudioInImpl;
+       }
+
+       return null;
+}
+
+const _AudioInImpl*
+_AudioInImpl::GetInstance(const AudioIn* pAudioIn)
+{
+       if (pAudioIn != null)
+       {
+               return pAudioIn->__pAudioInImpl;
+       }
+
+       return null;
+}
+
+result
+_AudioInImpl::Construct(Tizen::Media::IAudioInEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, !__isConstructed, E_DEVICE_BUSY, "The input device is already in use");
+       __isConstructed = true;
+
+       //Setting up the Events
+       __pAudioInEvent.reset(new (std::nothrow) _AudioInEvent);
+       SysTryCatch(NID_MEDIA, __pAudioInEvent.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = __pAudioInEvent->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pAudioInEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pAudioInEventListener = &listener;
+
+       //BufferQueue
+       r = __bufferQueue.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       //Buffer Sync
+       __pBufferSync.reset(new (std::nothrow) Monitor);
+       SysTryCatch(NID_MEDIA, __pBufferSync.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(r));
+       r = __pBufferSync->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __audioInState = AUDIOIN_STATE_INITIALIZED;
+       return r;
+
+CATCH:
+       __isConstructed = false;
+       SetLastResult(r);
+       return r;
+}
+
+
+int
+_AudioInImpl::GetMaxBufferSize(void)
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __audioInState < AUDIOIN_STATE_UNPREPARED && __audioInState >= AUDIOIN_STATE_PREPARED, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioIn state is not proper.");
+       return _AUDIO_IN_MAXIMUM_BUFFER_SIZE;
+CATCH:
+       SetLastResult(r);
+       return -1;
+}
+
+
+int
+_AudioInImpl::GetMinBufferSize(void)
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __audioInState < AUDIOIN_STATE_UNPREPARED && __audioInState >= AUDIOIN_STATE_PREPARED, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioIn state is not proper.");
+       return _AUDIO_IN_MINIMUM_BUFFER_SIZE;
+CATCH:
+       SetLastResult(r);
+       return -1;
+}
+
+AudioChannelType
+_AudioInImpl::GetOptimizedChannelType(void)
+{
+       result r = E_SUCCESS;
+       SetLastResult(r);
+       return _AUDIO_IN_OPTIMAL_CHANNEL_TYPE;
+}
+
+
+int
+_AudioInImpl::GetOptimizedSampleRate(void)
+{
+       result r = E_SUCCESS;
+       SetLastResult(r);
+       return _AUDIO_IN_OPTIMAL_SAMPLE_RATE;
+}
+
+AudioSampleType
+_AudioInImpl::GetOptimizedSampleType(void)
+{
+       result r = E_SUCCESS;
+       SetLastResult(r);
+       return _AUDIO_IN_OPTIMAL_SAMPLE_TYPE;
+}
+
+AudioInState
+_AudioInImpl::GetState(void)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "The current state of AudioIn is %d", __audioInState);
+       SetLastResult(r);
+       return __audioInState;
+}
+
+result
+_AudioInImpl::Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+
+       SysTryReturnResult(NID_MEDIA, __audioInState == AUDIOIN_STATE_UNPREPARED || __audioInState == AUDIOIN_STATE_INITIALIZED, E_INVALID_STATE, "AudioIn state is not proper.");
+       SysTryReturnResult(NID_MEDIA, audioSampleType == AUDIO_TYPE_PCM_U8 || audioSampleType == AUDIO_TYPE_PCM_S16_LE, E_INVALID_ARG,
+                               "Invalid argument is used. Audio sample is type is not valid.");
+       SysTryReturnResult(NID_MEDIA, audioChannelType == AUDIO_CHANNEL_TYPE_MONO || audioChannelType == AUDIO_CHANNEL_TYPE_STEREO, E_INVALID_ARG,
+                               "Invalid argument is used. Audio channel type is not valid");
+       SysTryReturnResult(NID_MEDIA, audioSampleRate >= 8000 && audioSampleRate <= 48000, E_INVALID_ARG,
+                               "Invalid argument is used. Audio sample rate is not valid.");
+
+       ret = audio_in_create(audioSampleRate, _AudioManagerConvert::ConvertChannelTypeAudio(audioChannelType), _AudioManagerConvert::ConvertSampleTypeAudio(audioSampleType), &__audioInHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                       "[%s] Failed to perform audio_in_create operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_in_set_interrupted_cb(__audioInHandle, AudioIoInterrupted, this);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                       "[%s] Failed to perform audio_in_set_interrupted_cb operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_in_get_buffer_size(__audioInHandle, &__audioInOptimalBufferSize);
+       if (ret == AUDIO_IO_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "The optimal buffer size is %d", __audioInOptimalBufferSize);
+       }
+       else
+       {
+               r = MapExceptionToResult(ret);
+               SysLogException(NID_MEDIA, r, "[%s] Failed to perform audio_out_get_buffer_size operation with error code : 0x%x",GetErrorMessage(r), ret);
+       }
+
+       __audioInState = AUDIOIN_STATE_PREPARED;
+       return r;
+
+CATCH:
+       __audioInHandle = null;
+       SysLog(NID_MEDIA, "This function is failed in %s with error code : %x. And the value of __audioInOptimalBufferSize is %x\n", __FUNCTION__, r, __audioInOptimalBufferSize);
+       return r;
+}
+
+result
+_AudioInImpl::Reset(void)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_MEDIA, __audioInState <AUDIOIN_STATE_UNPREPARED && __audioInState> AUDIOIN_STATE_PREPARED, E_INVALID_STATE,
+                                               "AudioIn state is in an invalid state. the current state is %d.", __audioInState);
+       if (__audioInState == AUDIOIN_STATE_RECORDING )
+       {
+               Stop();
+       }
+       __bufferQueue.RemoveAll();
+       __audioInState = AUDIOIN_STATE_PREPARED;
+       return r;
+}
+
+result
+_AudioInImpl::Unprepare(void)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+       SysTryReturnResult(NID_MEDIA, __audioInState == AUDIOIN_STATE_PREPARED || __audioInState == AUDIOIN_STATE_STOPPED, E_INVALID_STATE,
+                               "AudioIn state is in an invalid state. the current state is  %d", __audioInState);
+       __bufferQueue.RemoveAll();
+       __audioInState = AUDIOIN_STATE_UNPREPARED;
+
+       if (__audioInHandle)
+       {
+               ret = audio_in_unset_interrupted_cb(__audioInHandle);
+               r = MapExceptionToResult(ret);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                                       "[%s] Failed to perform audio_in_unset_interrupted_cb operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+               ret = audio_in_destroy(__audioInHandle);
+               r = MapExceptionToResult(ret);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                                       "[%s] Failed to perform audio_in_destroy operation with error code : 0x%x", GetErrorMessage(r), ret);
+       }
+       __audioInHandle = null;
+       return r;
+CATCH:
+       __audioInState = AUDIOIN_STATE_INITIALIZED;
+       return r;
+}
+
+result
+_AudioInImpl::Start(void)
+{
+       result r = E_SUCCESS;
+       int ret = AUDIO_IO_ERROR_NONE;
+       SysTryReturnResult(NID_MEDIA, __audioInState == AUDIOIN_STATE_PREPARED || __audioInState == AUDIOIN_STATE_STOPPED, E_INVALID_STATE,
+                               "AudioIn state is in an invalid state");
+       SysTryCatch(NID_MEDIA, __bufferQueue.GetCount() > 0, r = E_SYSTEM, E_SYSTEM,
+                               "[E_SYSTEM] A system error has been occurred. There is no buffers queued.");
+
+       ret = audio_in_prepare(__audioInHandle);
+       r = MapExceptionToResult(ret);
+       SysTryReturnResult(NID_MEDIA, r != E_DEVICE_BUSY, E_DEVICE_BUSY, "AudioIn cannot Start, higher priority task at work.");
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_in_prepare operation with error code : %x", GetErrorMessage(r), ret);
+
+       __pWorkerThread.reset(new (std::nothrow) Thread);
+       SysTryCatch(NID_MEDIA, __pWorkerThread.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = __pWorkerThread->Construct(*this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, r, "[%s]  Propagating.", GetErrorMessage(r));
+
+       __runFlag = true;
+       r = __pWorkerThread->Start();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, r, "[%s]  Propagating.", GetErrorMessage(r));
+
+       __audioInState = AUDIOIN_STATE_RECORDING;
+       return r;
+CATCH:
+       if (__runFlag)
+       {
+               ret = audio_in_unprepare(__audioInHandle);
+               SysTryLog(NID_MEDIA, ret == AUDIO_IO_ERROR_NONE, "Failed to perform audio_in_unprepare operation with error code : %x", ret);
+       }
+       SetLastResult(r);
+       __audioInState = AUDIOIN_STATE_ERROR;
+       return r;
+}
+
+result
+_AudioInImpl::Stop(void)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_MEDIA, __audioInState == AUDIOIN_STATE_RECORDING, E_INVALID_STATE,
+                               "The state of AudioIn is in an invalied state. the current state is %d", __audioInState);
+       __runFlag = false;
+
+       if (__pWorkerThread.get())
+       {
+               r = __pBufferSync->Enter();
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  Propagating.", GetErrorMessage(r));
+               r = __pBufferSync->Notify();
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  Propagating.", GetErrorMessage(r));
+               r = __pBufferSync->Exit();
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  Propagating.", GetErrorMessage(r));
+               r = __pWorkerThread->Join();
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  Propagating.", GetErrorMessage(r));
+       }
+       else
+       {
+               SysLog(NID_MEDIA, "There is no thread to stop.");
+       }
+
+       __audioInState = AUDIOIN_STATE_STOPPED;
+       return r;
+}
+
+result
+_AudioInImpl::AddBuffer(const Tizen::Base::ByteBuffer* pByteBuffer)
+{
+       result r = E_SUCCESS;
+
+       TryReturn(__audioInState >= AUDIOIN_STATE_PREPARED && __audioInState < AUDIOIN_STATE_UNPREPARED, E_INVALID_STATE, "AudioIn state is not proper.");
+       SysTryReturnResult(NID_MEDIA, __audioInState >= AUDIOIN_STATE_PREPARED && __audioInState < AUDIOIN_STATE_UNPREPARED, E_INVALID_STATE, "AudioIn state is not proper.");
+       SysTryReturnResult(NID_MEDIA, (pByteBuffer->GetCapacity() >= _AUDIO_IN_MINIMUM_BUFFER_SIZE), E_INVALID_ARG,
+               "Invalid argument is used. The size of buffer is too small, the current size is %d. The size of buffer should be between %d and %d",
+               pByteBuffer->GetCapacity(), _AUDIO_IN_MINIMUM_BUFFER_SIZE, _AUDIO_IN_MAXIMUM_BUFFER_SIZE);
+       SysTryReturnResult(NID_MEDIA, _AUDIO_IN_MAXIMUM_BUFFER_SIZE >= pByteBuffer->GetCapacity(), E_OVERFLOW,
+               "Invalid argument is used. The size of buffer is too big, the current size is %d. The size of buffer should be between %d and %d", pByteBuffer->GetCapacity(), _AUDIO_IN_MINIMUM_BUFFER_SIZE, _AUDIO_IN_MAXIMUM_BUFFER_SIZE);
+
+       r = __pBufferSync->Enter();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  Propagating.", GetErrorMessage(r));
+
+       r = __bufferQueue.Enqueue((const ByteBuffer*) (pByteBuffer));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  Propagating.", GetErrorMessage(r));
+
+       r = __pBufferSync->Notify();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  Propagating.", GetErrorMessage(r));
+
+       r = __pBufferSync->Exit();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s]  Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+Tizen::Base::Object*
+_AudioInImpl::Run(void)
+{
+       ByteBuffer* pBuffer = null;
+       int buffer_size = 0;
+       unsigned char* pData = null;
+       unsigned char* pInitialPointer = null;
+       int ret = 0;
+       result r = E_SUCCESS;
+
+       while (__runFlag)
+       {
+               r = __pBufferSync->Enter();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+               if (__bufferQueue.Peek((const Tizen::Base::ByteBuffer * &)pBuffer) == E_UNDERFLOW)
+               {
+                       //wait
+                       __pBufferSync->Wait();
+                       if (!__runFlag)
+                       {
+                               r = __pBufferSync->Exit();
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+                               ret = audio_in_unprepare(__audioInHandle);
+                               SysTryLog(NID_MEDIA, ret == AUDIO_IO_ERROR_NONE, "Failed to perform audio_in_unprepare operation with error code : %x", ret);
+                               return this;
+                       }
+                       r = __bufferQueue.Peek((const Tizen::Base::ByteBuffer * &)pBuffer);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               r = __pBufferSync->Exit();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               buffer_size = pBuffer->GetCapacity();
+               pData = (unsigned char*) pBuffer->GetPointer();
+               SysTryCatch(NID_MEDIA, pData != null, r = E_INVALID_ARG, r, "Invalid argument is used. Data to read is null.");
+
+               if (__runFlag)
+               {
+                       ret = audio_in_read(__audioInHandle, (void*) pData, buffer_size);
+                       if (ret != buffer_size)
+                       {
+                               SysLog(NID_MEDIA, "The size of data read is smaller than buffer size");
+                       }
+                       else
+                       {
+                               __pBufferSync->Enter();
+                               r = __bufferQueue.Dequeue((const Tizen::Base::ByteBuffer * &)pBuffer);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+                               r = __pBufferSync->Exit();
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+                               pInitialPointer = (unsigned char*) pBuffer->GetPointer();
+                               if (pInitialPointer)
+                               {
+                                       pBuffer->SetPosition(pData - pInitialPointer);
+                               }
+                               SendBufferEndReachedEvent(pBuffer);
+                       }
+               }
+       }
+       ret = audio_in_unprepare(__audioInHandle);
+       SysTryLog(NID_MEDIA, ret == AUDIO_IO_ERROR_NONE, "Failed to perform audio_in_unprepare operation with error code : %x", ret);
+       SysLog(NID_MEDIA, "AudioIn thread is terminated.");
+       return null;
+CATCH:
+       ret = audio_in_unprepare(__audioInHandle);
+       SysTryLog(NID_MEDIA, ret == AUDIO_IO_ERROR_NONE, "Failed to perform audio_in_unprepare operation with error code : %x", ret);
+       return null;
+}
+
+void
+_AudioInImpl::AudioIoInterrupted(audio_io_interrupted_code_e code, void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       _AudioInImpl *pAudioInImpl = (_AudioInImpl *)pUserData;
+
+       switch (code)
+       {
+       case AUDIO_IO_INTERRUPTED_COMPLETED:
+               if (pAudioInImpl->__audioInState == AUDIOIN_STATE_STOPPED)
+               {
+                       if (!(pAudioInImpl->__interruptFlag))
+                       {
+                               pAudioInImpl->SendReleased();
+                       }
+                       pAudioInImpl->__interruptFlag = false;
+               }
+               break;
+       case AUDIO_IO_INTERRUPTED_BY_CALL:
+               pAudioInImpl->__interruptFlag = true;
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_EARJACK_UNPLUG:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_MEDIA:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_RESOURCE_CONFLICT:
+               //Intentional Fall through
+               if (pAudioInImpl->__audioInState == AUDIOIN_STATE_RECORDING)
+               {
+                       pAudioInImpl->SendAudioFocusChanged();
+               }
+               break;
+       case AUDIO_IO_INTERRUPTED_BY_ALARM:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_EMERGENCY:
+               if (pAudioInImpl->__audioInState == AUDIOIN_STATE_RECORDING)
+               {
+                       pAudioInImpl->SendInterrupted();
+               }
+               break;
+       default:
+               SysLog(NID_MEDIA, "Interrupt code obtained is wrong, the code is %d", code);
+               break;
+       }
+}
+
+result
+_AudioInImpl::SendBufferEndReachedEvent(Tizen::Base::ByteBuffer* pBuffer)
+{
+       _AudioInEventArg* pAudioInEventArg = null;
+
+       pAudioInEventArg = new (std::nothrow) _AudioInEventArg;
+       TryReturn(pAudioInEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pAudioInEventArg->SetData(pBuffer);
+
+       pAudioInEventArg->SetEventType(_AUDIOIN_EVENT_RECORDED_DATA);
+
+       __pAudioInEvent->FireAsync(*pAudioInEventArg);
+       return E_SUCCESS;
+}
+
+
+result
+_AudioInImpl::SendInterrupted(void)
+{
+       result r = E_SUCCESS;
+       _AudioInEventArg* pAudioInEventArg = null;
+       pAudioInEventArg = new (std::nothrow) _AudioInEventArg;
+       SysTryReturnResult(NID_MEDIA, pAudioInEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       this->Stop();
+       pAudioInEventArg->SetEventType(_AUDIOIN_EVENT_INTERRUPTED);
+       r = __pAudioInEvent->FireAsync(*pAudioInEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pAudioInEventArg;
+       return r;
+}
+
+result
+_AudioInImpl::SendAudioFocusChanged(void)
+{
+       result r = E_SUCCESS;
+       _AudioInEventArg* pAudioInEventArg = null;
+       pAudioInEventArg = new (std::nothrow) _AudioInEventArg;
+       SysTryReturnResult(NID_MEDIA, pAudioInEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       this->Stop();
+       pAudioInEventArg->SetEventType(_AUDIOIN_EVENT_AUDIO_FOCUS_CHANGED);
+       r = __pAudioInEvent->FireAsync(*pAudioInEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pAudioInEventArg;
+       return r;
+}
+
+result
+_AudioInImpl::SendReleased(void)
+{
+       result r = E_SUCCESS;
+       _AudioInEventArg* pAudioInEventArg = null;
+       pAudioInEventArg = new (std::nothrow) _AudioInEventArg;
+       SysTryReturnResult(NID_MEDIA, pAudioInEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       pAudioInEventArg->SetEventType(_AUDIOIN_EVENT_RELEASED);
+       r = __pAudioInEvent->FireAsync(*pAudioInEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pAudioInEventArg;
+       return r;
+}
+
+result
+_AudioInImpl::MapExceptionToResult(int reason)
+{
+       //All the fall through are intentional
+       switch (reason)
+       {
+       //Successful
+       case AUDIO_IO_ERROR_NONE:
+               return E_SUCCESS;
+               break;
+       //Out of memory
+       case AUDIO_IO_ERROR_OUT_OF_MEMORY:
+               return E_OUT_OF_MEMORY;
+               break;
+       //Invalid parameter
+       case AUDIO_IO_ERROR_INVALID_PARAMETER:
+               return E_INVALID_ARG;
+               break;
+       //Invalid operation
+       case AUDIO_IO_ERROR_INVALID_OPERATION:
+               return E_INVALID_OPERATION;
+               break;
+       //Device not opened
+       case AUDIO_IO_ERROR_DEVICE_NOT_OPENED:
+               return E_INVALID_STATE;
+               break;
+       //invalid buffer
+       case AUDIO_IO_ERROR_INVALID_BUFFER:
+               return E_INVALID_ARG;
+               break;
+       //Device not closed
+       case AUDIO_IO_ERROR_DEVICE_NOT_CLOSED:
+               return E_INVALID_STATE;
+               break;
+       //Sound policy error
+       case AUDIO_IO_ERROR_SOUND_POLICY:
+               return E_DEVICE_BUSY;
+               break;
+       default:
+               return E_SYSTEM;
+               break;
+       }
+}
+
+}} //Tizen::Media
diff --git a/src/FMedia_AudioInImpl.h b/src/FMedia_AudioInImpl.h
new file mode 100644 (file)
index 0000000..97188c7
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file               FMedia_AudioInImpl.h
+// @brief              This is the header file for the FMediaAudioInImpl.
+//
+// This header file contains the declarations of the FMediaAudioInImpl.
+//
+
+#ifndef _FMEDIA_INTERNAL_AUDIO_IN_IMPL_H_
+#define _FMEDIA_INTERNAL_AUDIO_IN_IMPL_H_
+
+#include <unique_ptr.h>
+#include <audio_io.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseRtIRunnable.h>
+#include <FBaseRtMonitor.h>
+#include <FBaseRtThread.h>
+#include <FBaseColQueueT.h>
+#include <FMediaAudioIn.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaIAudioInEventListener.h>
+
+namespace Tizen { namespace Media
+{
+
+class _AudioInEvent;
+class _AudioInImpl
+       : public Tizen::Base::Runtime::IRunnable
+       , public Tizen::Base::Object
+{
+public:
+       _AudioInImpl(void);
+       virtual ~_AudioInImpl(void);
+       result Construct(IAudioInEventListener& listener);
+       int GetMaxBufferSize(void);
+       int GetMinBufferSize(void);
+       int GetOptimizedSampleRate(void);
+       AudioChannelType GetOptimizedChannelType(void);
+       AudioSampleType GetOptimizedSampleType(void);
+       AudioInState GetState(void);
+       result Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate);
+       result Unprepare(void);
+       result Start(void);
+       result Stop(void);
+       result Reset(void);
+       result AddBuffer(const Tizen::Base::ByteBuffer* pByteBuffer);
+       //IRunnable Virtual Functions
+       Tizen::Base::Object* Run(void);
+       //sicne 3.0
+       static _AudioInImpl* GetInstance(AudioIn* pAudioIn);
+       static const _AudioInImpl* GetInstance(const AudioIn* pAudioIn);
+       static void AudioIoInterrupted(audio_io_interrupted_code_e code, void *pUserData);
+private:
+       _AudioInImpl(const _AudioInImpl& rhs);
+       _AudioInImpl& operator =(const _AudioInImpl& rhs);
+       result SendBufferEndReachedEvent(Tizen::Base::ByteBuffer* pbuffer);
+       result SendInterrupted(void);
+       result SendReleased(void);
+       result SendAudioFocusChanged();
+       result MapExceptionToResult(int reason);
+
+
+       std::unique_ptr<_AudioInEvent> __pAudioInEvent;
+       std::unique_ptr<Tizen::Base::Runtime::Thread> __pWorkerThread;
+       std::unique_ptr<Tizen::Base::Runtime::Monitor> __pBufferSync;
+       AudioInState __audioInState;
+       IAudioInEventListener* __pAudioInEventListener;
+       audio_in_h __audioInHandle;
+       Tizen::Base::Collection::QueueT <const Tizen::Base::ByteBuffer*> __bufferQueue;
+       int __audioInOptimalBufferSize;
+       bool __interruptFlag;
+
+       //static
+       static bool __isConstructed;
+       static int __runFlag;
+       static const int _AUDIO_IN_OPTIMAL_SAMPLE_RATE;
+       static const int _AUDIO_IN_MINIMUM_BUFFER_SIZE;
+       static const int _AUDIO_IN_MAXIMUM_BUFFER_SIZE;
+       static const AudioChannelType _AUDIO_IN_OPTIMAL_CHANNEL_TYPE;
+       static const AudioSampleType _AUDIO_IN_OPTIMAL_SAMPLE_TYPE;
+};  //end of _AudioInImpl
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioManagerConvert.cpp b/src/FMedia_AudioManagerConvert.cpp
new file mode 100644 (file)
index 0000000..b92e635
--- /dev/null
@@ -0,0 +1,228 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License)
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <sound_manager.h>
+#include <FBaseSysLog.h>
+#include "FMedia_AudioManagerConvert.h"
+
+namespace Tizen{
+namespace Media{
+
+
+
+audio_channel_e
+_AudioManagerConvert::ConvertChannelType(AudioChannelType audioChannelType)
+{
+       switch (audioChannelType)
+       {
+       case AUDIO_CHANNEL_TYPE_MONO:
+               return AUDIO_CHANNEL_MONO;
+               break;
+
+       case AUDIO_CHANNEL_TYPE_STEREO:
+               return AUDIO_CHANNEL_STEREO;
+               break;
+
+       default:
+               return AUDIO_CHANNEL_STEREO;
+               break;
+       }
+       // defautl stereo
+}
+
+audio_sample_type_e
+_AudioManagerConvert::ConvertSampleType(AudioSampleType audioSampleType)
+{
+       switch (audioSampleType)
+       {
+       case AUDIO_TYPE_PCM_U8:
+               return AUDIO_SAMPLE_TYPE_U8;
+               break;
+
+       case AUDIO_TYPE_PCM_S16_LE:
+               return AUDIO_SAMPLE_TYPE_S16_LE;
+               break;
+
+       default:
+               return AUDIO_SAMPLE_TYPE_S16_LE;
+               break;
+       }
+
+       // default S16 LE
+}
+
+
+audio_channel_e
+_AudioManagerConvert::ConvertChannelTypeAudio(AudioChannelType audioChannelType)
+{
+       switch (audioChannelType)
+       {
+       case AUDIO_CHANNEL_TYPE_MONO:
+               return AUDIO_CHANNEL_MONO;
+               break;
+
+       case AUDIO_CHANNEL_TYPE_STEREO:
+               return AUDIO_CHANNEL_STEREO;
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_UNSUPPORTED_FORMAT, "Audio channel type is invalid.");
+               return AUDIO_CHANNEL_MONO;
+               break;
+       }
+}
+
+audio_sample_type_e
+_AudioManagerConvert::ConvertSampleTypeAudio(AudioSampleType audioSampleType)
+{
+       switch (audioSampleType)
+       {
+       case AUDIO_TYPE_PCM_U8:
+               return AUDIO_SAMPLE_TYPE_U8;
+               break;
+
+       case AUDIO_TYPE_PCM_S16_LE:
+               return AUDIO_SAMPLE_TYPE_S16_LE;
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_UNSUPPORTED_FORMAT, "Audio sample type is invalid.");
+               return AUDIO_SAMPLE_TYPE_S16_LE;
+               break;
+
+       }
+}
+
+result
+_AudioManagerConvert::CovertSoundManagerError2Result(int error)
+{
+       switch (error)
+       {
+       case SOUND_MANAGER_ERROR_NONE:
+               return E_SUCCESS;
+       case SOUND_MANAGER_ERROR_OUT_OF_MEMORY:
+               return E_OUT_OF_MEMORY;
+       case SOUND_MANAGER_ERROR_INVALID_PARAMETER:
+               return E_INVALID_ARG;
+       case SOUND_MANAGER_ERROR_INVALID_OPERATION:
+               return E_INVALID_OPERATION;
+       case SOUND_MANAGER_ERROR_NO_PLAYING_SOUND:
+               return E_SYSTEM;
+       default:
+               return E_SYSTEM;
+       }
+}
+
+sound_session_type_e
+_AudioManagerConvert::ConvertAudioSession2SoundSession(AudioSessionMode audioSessionType)
+{
+       switch (audioSessionType)
+       {
+       case AUDIO_SESSION_MODE_SHARED:
+               return SOUND_SESSION_TYPE_SHARE;
+       case AUDIO_SESSION_MODE_EXCLUSIVE:
+               return SOUND_SESSION_TYPE_EXCLUSIVE;
+       case AUDIO_SESSION_MODE_EMERGENCY:
+               return SOUND_SESSION_TYPE_EXCLUSIVE;
+       default:
+               return SOUND_SESSION_TYPE_SHARE;
+       }
+}
+
+AudioSessionMode
+_AudioManagerConvert::ConvertSoundSession2AudioSession(sound_session_type_e soundSession)
+{
+       switch (soundSession)
+       {
+       case SOUND_SESSION_TYPE_SHARE:
+               return AUDIO_SESSION_MODE_SHARED;
+       case SOUND_SESSION_TYPE_EXCLUSIVE:
+               return AUDIO_SESSION_MODE_EXCLUSIVE;
+       case SOUND_SESSION_TYPE_EMERGENCY:
+               return AUDIO_SESSION_MODE_EMERGENCY;
+       default:
+               return AUDIO_SESSION_MODE_SHARED;
+       }
+}
+
+sound_call_session_mode_e
+_AudioManagerConvert::ConvertVoipMode2CallMode(VoipAudioSessionMode voipSessionMode)
+{
+       switch (voipSessionMode)
+       {
+       case VOIP_AUDIO_SESSION_MODE_VOICE:
+               return SOUND_CALL_SESSION_MODE_VOICE;
+       case VOIP_AUDIO_SESSION_MODE_RINGTONE:
+               return SOUND_CALL_SESSION_MODE_RINGTONE;
+       case VOIP_AUDIO_SESSION_MODE_MEDIA:
+               return SOUND_CALL_SESSION_MODE_MEDIA;
+       case VOIP_AUDIO_SESSION_MODE_NONE:
+               return SOUND_CALL_SESSION_MODE_VOICE;
+       default:
+               return SOUND_CALL_SESSION_MODE_VOICE;
+       }
+}
+
+VoipAudioSessionMode
+_AudioManagerConvert::ConvertCallSessionMode2VoipMode(sound_call_session_mode_e soundSessionMode)
+{
+       switch (soundSessionMode)
+       {
+       case SOUND_CALL_SESSION_MODE_VOICE:
+               return VOIP_AUDIO_SESSION_MODE_VOICE;
+       case SOUND_CALL_SESSION_MODE_RINGTONE:
+               return VOIP_AUDIO_SESSION_MODE_RINGTONE;
+       case SOUND_CALL_SESSION_MODE_MEDIA:
+               return VOIP_AUDIO_SESSION_MODE_MEDIA;
+       default:
+               return VOIP_AUDIO_SESSION_MODE_NONE;
+       }
+}
+
+sound_type_e
+_AudioManagerConvert::ConvertAudioStreamType2SoundType(AudioStreamType type)
+{
+       switch (type)
+       {
+       case AUDIO_STREAM_TYPE_NO_SOUND:
+               return SOUND_TYPE_MEDIA;
+               break;
+       case AUDIO_STREAM_TYPE_SYSTEM:
+               return SOUND_TYPE_SYSTEM;
+               break;
+       case AUDIO_STREAM_TYPE_NOTIFICATION:
+               return SOUND_TYPE_NOTIFICATION;
+               break;
+       case AUDIO_STREAM_TYPE_ALARM:
+               return SOUND_TYPE_ALARM;
+               break;
+       case AUDIO_STREAM_TYPE_RINGTONE:
+               return SOUND_TYPE_RINGTONE;
+               break;
+       case AUDIO_STREAM_TYPE_MEDIA:
+               return SOUND_TYPE_MEDIA;
+               break;
+       case AUDIO_STREAM_TYPE_CALL:
+               return SOUND_TYPE_CALL;
+               break;
+       default:
+               return SOUND_TYPE_MEDIA;
+               break;
+       }
+}
+
+};
+};     //Tizen::Media
diff --git a/src/FMedia_AudioManagerConvert.h b/src/FMedia_AudioManagerConvert.h
new file mode 100644 (file)
index 0000000..3022b63
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License)
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef _FMEDIA_AUDIO_MANAGER_CONVERT_H_
+#define _FMEDIA_AUDIO_MANAGER_CONVERT_H_
+
+#include <FBase.h>
+#include <audio_io.h>
+#include <sound_manager.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaAudioTypes.h>
+
+namespace Tizen{
+namespace Media{
+
+class _AudioManagerConvert
+{
+public :
+       static audio_channel_e ConvertChannelType(AudioChannelType audioChannelType);
+       static audio_sample_type_e ConvertSampleType(AudioSampleType audioSampleType);
+       static audio_sample_type_e ConvertSampleTypeAudio(AudioSampleType audioSampleType);
+       static audio_channel_e  ConvertChannelTypeAudio(AudioChannelType audioChannelType);
+       static result CovertSoundManagerError2Result(int error);
+       static sound_session_type_e ConvertAudioSession2SoundSession(AudioSessionMode audioSessionType);
+       static AudioSessionMode ConvertSoundSession2AudioSession(sound_session_type_e soundSession);
+       static sound_call_session_mode_e ConvertVoipMode2CallMode(VoipAudioSessionMode voipSessionMode);
+       static VoipAudioSessionMode ConvertCallSessionMode2VoipMode(sound_call_session_mode_e soundSessionMode);
+       static sound_type_e ConvertAudioStreamType2SoundType(AudioStreamType type);
+
+private :
+       _AudioManagerConvert(void);
+       ~_AudioManagerConvert(void);
+
+       _AudioManagerConvert(const _AudioManagerConvert& rhs);
+       _AudioManagerConvert& operator =(const _AudioManagerConvert& rhs);
+
+};
+
+}}     //Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioOutEvent.cpp b/src/FMedia_AudioOutEvent.cpp
new file mode 100644 (file)
index 0000000..2923ed1
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+
+#include "FMedia_AudioOutEvent.h"
+#include "FMedia_AudioOutEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_AudioOutEvent::_AudioOutEvent(void)
+       : __pAudioOutSrc(null)
+       , __pListener(null)
+{
+}
+
+_AudioOutEvent::~_AudioOutEvent(void)
+{
+       __pListener = null;
+}
+
+result
+_AudioOutEvent::Construct(AudioOut* src)
+{
+       __pAudioOutSrc = src;
+       result r = E_SUCCESS;
+
+       r = _Event::Initialize();
+       SysTryReturn(NID_MEDIA, E_SUCCESS == r, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       __pListener = null;
+       return r;
+}
+
+void
+_AudioOutEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       IAudioOutEventListener* pAudioOutEventListener = dynamic_cast<IAudioOutEventListener*> (&listener);
+       SysTryReturn(NID_MEDIA, pAudioOutEventListener, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Listener is null.");
+
+       __pListener = pAudioOutEventListener;
+       const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
+       _AudioOutEventTypeArg* pArg = (_AudioOutEventTypeArg*) pTempArg;
+
+       switch (pArg->GetEventType())
+       {
+       case _AUDIOOUT_EVENT_DATA_END_REACHED:
+               pAudioOutEventListener->OnAudioOutBufferEndReached(*__pAudioOutSrc);
+               break;
+       case _AUDIOOUT_EVENT_INTERRUPTED:
+               pAudioOutEventListener->OnAudioOutInterrupted(*__pAudioOutSrc);
+               break;
+       case _AUDIOOUT_EVENT_RELEASED:
+               pAudioOutEventListener->OnAudioOutReleased(*__pAudioOutSrc);
+               break;
+       case _AUDIOOUT_EVENT_AUDIO_FOCUS_CHANGED:
+               pAudioOutEventListener->OnAudioOutAudioFocusChanged(*__pAudioOutSrc);
+               break;
+       default:
+               break;
+
+       }
+}
+};
+};
diff --git a/src/FMedia_AudioOutEvent.h b/src/FMedia_AudioOutEvent.h
new file mode 100644 (file)
index 0000000..63f2802
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_AudioOutEvent.h
+// @brief                      This header file contains the declaration related to AudioOut class.
+//
+
+
+#ifndef _FMEDIA_INTERNAL_AUDIOOUT_EVENT_H_
+#define _FMEDIA_INTERNAL_AUDIOOUT_EVENT_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseRt_Event.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaIAudioOutEventListener.h>
+#include <FMediaAudioOut.h>
+
+namespace Tizen { namespace Media
+{
+
+class _AudioOutEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+public:
+       _AudioOutEvent(void);
+       ~_AudioOutEvent(void);
+       result Construct(Tizen::Media::AudioOut* src);
+
+protected:
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+       _AudioOutEvent(const _AudioOutEvent& rhs);
+       _AudioOutEvent& operator =(const _AudioOutEvent& rhs);
+
+       AudioOut* __pAudioOutSrc;
+       IAudioOutEventListener* __pListener;
+
+};     //_AudioOutEvent
+
+}}//Tizen::Media
+
+
+#endif
diff --git a/src/FMedia_AudioOutEventArg.cpp b/src/FMedia_AudioOutEventArg.cpp
new file mode 100644 (file)
index 0000000..7bb2251
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMedia_AudioOutEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_AudioOutEventTypeArg::_AudioOutEventTypeArg(void)
+       : __audioOutEventType(_AUDIOOUT_EVENT_NONE)
+{
+
+}
+
+_AudioOutEventTypeArg::~_AudioOutEventTypeArg(void)
+{
+
+}
+
+void
+_AudioOutEventTypeArg::SetEventType(_AudioOutEventType eType)
+{
+       __audioOutEventType = eType;
+}
+
+_AudioOutEventType
+_AudioOutEventTypeArg::GetEventType(void) const
+{
+       return __audioOutEventType;
+}
+
+_AudioOutEventArg::_AudioOutEventArg(void)
+       : __boolFlag(false)
+{
+
+}
+
+_AudioOutEventArg::~_AudioOutEventArg(void)
+{
+
+}
+
+void
+_AudioOutEventArg::SetBoolFlag(bool boolFlag)
+{
+       __boolFlag = boolFlag;
+}
+
+bool
+_AudioOutEventArg::GetBoolFlag(void) const
+{
+       return __boolFlag;
+}
+
+};
+};   // Tizen::Media
diff --git a/src/FMedia_AudioOutEventArg.h b/src/FMedia_AudioOutEventArg.h
new file mode 100644 (file)
index 0000000..ceeeadb
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_AudioOutEventArg.h
+// @brief                      This header file contains the declaration related to AudioOut class.
+//
+//
+
+#ifndef _FMEDIA_INTERNAL_AUDIOOUT_EVENTARG_H_
+#define _FMEDIA_INTERNAL_AUDIOOUT_EVENTARG_H_
+
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaAudioTypes.h>
+
+namespace Tizen {namespace Media
+{
+
+class _AudioOutImpl;
+
+enum _AudioOutEventType
+{
+       _AUDIOOUT_EVENT_NONE,                                           // Event_None
+       _AUDIOOUT_EVENT_DATA_END_REACHED,                       // Recorded Event
+       _AUDIOOUT_EVENT_INTERRUPTED,                                    // event interrupted by the system
+       _AUDIOOUT_EVENT_RELEASED,                                       // event released by the system
+       _AUDIOOUT_EVENT_AUDIO_FOCUS_CHANGED,                    // event notifying that audio foucs has changed
+       _AUDIOOUT_EVENT_ERROR,                                          // Error event
+};
+
+class _AudioOutEventTypeArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+       _AudioOutEventTypeArg(void);
+       virtual ~_AudioOutEventTypeArg(void);
+       _AudioOutEventType GetEventType(void) const;
+
+private:
+       void SetEventType(_AudioOutEventType eType);
+
+private:
+       _AudioOutEventTypeArg(const _AudioOutEventTypeArg& rhs);
+       _AudioOutEventTypeArg& operator =(const _AudioOutEventTypeArg& rhs);
+
+       _AudioOutEventType __audioOutEventType;
+
+       friend class _AudioOutImpl;
+
+};     //_AudioOutEventTypeArg
+
+class _AudioOutEventArg
+       : _AudioOutEventTypeArg
+{
+public:
+       _AudioOutEventArg(void);
+       ~_AudioOutEventArg(void);
+       bool GetBoolFlag(void) const;
+
+private:
+       void SetBoolFlag(bool boolFlag);
+
+private:
+       bool __boolFlag;
+       friend class _AudioOutImpl;
+
+};     //_AudioOutEventArg
+
+}} // Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioOutImpl.cpp b/src/FMedia_AudioOutImpl.cpp
new file mode 100644 (file)
index 0000000..4768a3e
--- /dev/null
@@ -0,0 +1,760 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FMediaCapability.h>
+#include <FBaseSysLog.h>
+#include "FMedia_AudioOutEvent.h"
+#include "FMedia_AudioOutImpl.h"
+#include "FMedia_AudioOutEventArg.h"
+#include "FMedia_AudioManagerConvert.h"
+
+
+#define attribute_deprecated
+
+#ifdef __cplusplus
+#define __STDC_CONSTANT_MACROS
+#ifdef _STDINT_H
+#undef _STDINT_H
+#endif
+#include <stdint.h>
+#endif
+
+extern "C"
+{
+#include <stdlib.h>
+#include <libswscale/swscale.h>
+}
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+int _AudioOutImpl::instanceCount = 0;
+int _AudioOutImpl::maxInstanceCount = 0;
+AudioChannelType _AudioOutImpl::audioOutOptimalChannelType = AUDIO_CHANNEL_TYPE_STEREO;
+AudioSampleType _AudioOutImpl::audioOutOptimalSampleType = AUDIO_TYPE_PCM_S16_LE;
+int _AudioOutImpl::audioOutOptimalSampleRate = 44100;
+int _AudioOutImpl::audioOutMinimumBufferSize = 2048;
+int _AudioOutImpl::audioOutMaximumBufferSize = 164112;
+
+std::unique_ptr<Tizen::Base::Runtime::Mutex> _AudioOutImpl::__pInstanceMutex;
+bool _AudioOutImpl::__isInstanceMutexInitialized = false;
+
+_AudioOutImpl::_AudioOutImpl(void)
+       : __pAudioOut(null)
+       , __pAudioOutEventListener(null)
+       , __audioOutState(AUDIOOUT_STATE_ERROR)
+       , __volume(-1)
+       , __volume256(-1)
+       , __presentSampleType(AUDIO_TYPE_NONE)
+       , __presentSampleRate(0)
+       , __audioOutHandle(null)
+       , __audioOutOptimalBufferSize(0)
+       , __stop(false)
+       , __interruptFlag(false)
+{
+}
+
+
+_AudioOutImpl::~_AudioOutImpl(void)
+{
+       if (__audioOutState < AUDIOOUT_STATE_UNPREPARED && __audioOutState >= AUDIOOUT_STATE_PREPARED)
+       {
+               if (__audioOutState == AUDIOOUT_STATE_PLAYING )
+               {
+                       this->Stop();
+               }
+               this->Reset();
+               this->UnPrepare();
+       }
+       __pAudioOut = null;
+       if (__pAudioOutEvent.get() && __pAudioOutEventListener)
+       {
+               __pAudioOutEvent->RemoveListener(*__pAudioOutEventListener);
+       }
+
+       if ((__audioOutState == AUDIOOUT_STATE_INITIALIZED ) || __audioOutState == AUDIOOUT_STATE_UNPREPARED )
+       {
+               __pInstanceMutex->Acquire();
+               instanceCount--;
+               __pInstanceMutex->Release();
+       }
+}
+
+void
+_AudioOutImpl::InitInstanceMutex(void)
+{
+       result r = E_SUCCESS;
+       __pInstanceMutex.reset(new (std::nothrow) Tizen::Base::Runtime::Mutex);
+       SysTryReturn(NID_MEDIA, __pInstanceMutex.get() != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] no memory to create instance Mutex");
+       r = __pInstanceMutex->Create("FMEDIA_AUDIOOUT_N");
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Mutex::Create failed.");
+       __isInstanceMutexInitialized  = true;
+}
+
+_AudioOutImpl*
+_AudioOutImpl::GetInstance(AudioOut* pAudioOut)
+{
+       if (pAudioOut != null)
+       {
+               return pAudioOut->__pAudioOutImpl;
+       }
+
+       return null;
+}
+
+const _AudioOutImpl*
+_AudioOutImpl::GetInstance(const AudioOut* pAudioOut)
+{
+       if (pAudioOut != null)
+       {
+               return pAudioOut->__pAudioOutImpl;
+       }
+
+       return null;
+}
+
+result
+_AudioOutImpl::Construct(const Tizen::Media::AudioOut* pAudioOut, Tizen::Media::IAudioOutEventListener& listener)
+{
+       result r = E_SUCCESS;
+       __pAudioOut = const_cast <AudioOut*>(pAudioOut);
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (!__isInstanceMutexInitialized)
+       {
+               pthread_once(&onceBlock, InitInstanceMutex);
+       }
+       SysTryCatch(NID_MEDIA, __isInstanceMutexInitialized == true, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation for Instance Mutex failed");
+
+       if (!maxInstanceCount)
+       {
+               r = MediaCapability::GetValue(AUDIOOUT_COUNT_MAX, maxInstanceCount);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryCatch(NID_MEDIA, maxInstanceCount > 0, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       SysTryCatch(NID_MEDIA, instanceCount < maxInstanceCount, r = E_RESOURCE_UNAVAILABLE, E_RESOURCE_UNAVAILABLE, "[E_RESOURCE_UNAVAILABLE] The number of instances exceeds the available number of instances. The current number of instance is %d", instanceCount);
+
+       //Setting up the Events
+       __pAudioOutEvent.reset(new (std::nothrow) _AudioOutEvent);
+       SysTryReturnResult(NID_MEDIA, __pAudioOutEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
+       r = __pAudioOutEvent->Construct(__pAudioOut);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       r = __pAudioOutEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       //BufferQueue
+       r = __bufferQueue.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       //Buffer Sync
+       __pBufferSync.reset( new (std::nothrow) Monitor);
+       SysTryCatch(NID_MEDIA, __pBufferSync.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = __pBufferSync->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __volume = 50;
+       __volume256 = (__volume << 8) / 100;
+
+       __pInstanceMutex->Acquire();
+       instanceCount++;
+       __pInstanceMutex->Release();
+
+       __audioOutState = AUDIOOUT_STATE_INITIALIZED;
+       return E_SUCCESS;
+
+CATCH:
+       __pAudioOut = null;
+       SetLastResult(r);
+       return r;
+}
+
+int
+_AudioOutImpl::GetMaxBufferSize(void)
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __audioOutState < AUDIOOUT_STATE_UNPREPARED && __audioOutState >= AUDIOOUT_STATE_PREPARED,
+               r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The state of this instance is in an invalid state.");
+       return audioOutMaximumBufferSize;
+CATCH:
+       SetLastResult(r);
+       return -1;
+}
+
+int
+_AudioOutImpl::GetMinBufferSize(void)
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __audioOutState < AUDIOOUT_STATE_UNPREPARED && __audioOutState >= AUDIOOUT_STATE_PREPARED,
+               r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The state of this instance is in an invalid state.");
+       return audioOutMinimumBufferSize;
+CATCH:
+       SetLastResult(r);
+       return -1;
+}
+
+AudioChannelType
+_AudioOutImpl::GetOptimizedChannelType(void)
+{
+       return audioOutOptimalChannelType;
+}
+
+int
+_AudioOutImpl::GetOptimizedSampleRate(void)
+{
+       result r = E_SUCCESS;
+       SetLastResult(r);
+       return audioOutOptimalSampleRate;
+}
+
+AudioSampleType
+_AudioOutImpl::GetOptimizedSampleType(void)
+{
+       return audioOutOptimalSampleType;
+}
+
+AudioOutState
+_AudioOutImpl::GetState(void)
+{
+       result r = E_SUCCESS;
+       SetLastResult(r);
+       SysLog(NID_MEDIA, "The current state of this instance is %d", __audioOutState);
+       return __audioOutState;
+}
+
+int
+_AudioOutImpl::GetVolume(void) const
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __audioOutState < AUDIOOUT_STATE_UNPREPARED && __audioOutState >= AUDIOOUT_STATE_PREPARED,
+       r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The state of this instance is in an invalid state.");
+       return __volume;
+CATCH:
+       SetLastResult(r);
+       return -1;
+}
+
+result
+_AudioOutImpl::SetVolume(int& volume)
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __audioOutState < AUDIOOUT_STATE_UNPREPARED && __audioOutState >= AUDIOOUT_STATE_PREPARED,
+               r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The state of this instance is in an invalid state.");
+       __volume = volume;
+       __volume256 = (__volume << 8) / 100;
+CATCH:
+       return r;
+
+}
+
+result
+_AudioOutImpl::Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+
+       SysTryReturnResult(NID_MEDIA, __audioOutState == AUDIOOUT_STATE_UNPREPARED || __audioOutState == AUDIOOUT_STATE_INITIALIZED,
+               E_INVALID_STATE, "The state of this instance is in an invalid state.");
+       SysTryReturnResult(NID_MEDIA, audioSampleType >= AUDIO_TYPE_PCM_U8 && audioSampleType < AUDIO_TYPE_PCM_S16_BE, E_UNSUPPORTED_FORMAT,
+               "Audio sample type is not valid.");
+       SysTryReturnResult(NID_MEDIA, audioChannelType == AUDIO_CHANNEL_TYPE_MONO || audioChannelType == AUDIO_CHANNEL_TYPE_STEREO, E_INVALID_ARG,
+               "Invalid argument is used. Audio channel type is not valid");
+       SysTryReturnResult(NID_MEDIA, audioSampleRate >= 8000 && audioSampleRate <= 48000, E_INVALID_ARG,
+               "Invalid argument is used. Audio sample rate is not valid.");
+
+       ret = audio_out_create(audioSampleRate, _AudioManagerConvert::ConvertChannelType(audioChannelType), _AudioManagerConvert::ConvertSampleType(audioSampleType), SOUND_TYPE_MEDIA, &__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_create operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_set_interrupted_cb(__audioOutHandle, AudioIoInterrupted, this);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Failed to perform audio_out_set_interrupted_cb operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_get_buffer_size(__audioOutHandle, &__audioOutOptimalBufferSize);
+       if (ret == AUDIO_IO_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "The optimal buffer size is %d", __audioOutOptimalBufferSize);
+       }
+       else
+       {
+               r = MapExceptionToResult(ret);
+               SysLogException(NID_MEDIA, r, "[%s] Failed to perform audio_out_get_buffer_size operation with error code : %x", GetErrorMessage(r), ret);
+       }
+
+       __audioOutOptimalBufferSize = 1024;
+       __presentSampleType = audioSampleType;
+       __presentSampleRate = audioSampleRate;
+
+       __audioOutState = AUDIOOUT_STATE_PREPARED;
+       return r;
+CATCH:
+       __audioOutHandle = null;
+       return r;
+}
+
+result
+_AudioOutImpl::Prepare(AudioStreamType audioStreamType, AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+
+       SysTryReturnResult(NID_MEDIA, __audioOutState == AUDIOOUT_STATE_UNPREPARED || __audioOutState == AUDIOOUT_STATE_INITIALIZED,
+               E_INVALID_STATE, "The state of this instance is in an invalid state.");
+       SysTryReturnResult(NID_MEDIA, audioSampleType >= AUDIO_TYPE_PCM_U8 && audioSampleType < AUDIO_TYPE_PCM_S16_BE, E_UNSUPPORTED_FORMAT,
+               "Audio sample type is not valid.");
+       SysTryReturnResult(NID_MEDIA, audioChannelType == AUDIO_CHANNEL_TYPE_MONO || audioChannelType == AUDIO_CHANNEL_TYPE_STEREO, E_INVALID_ARG,
+               "Invalid argument is used. Audio channel type is not valid");
+       SysTryReturnResult(NID_MEDIA, audioSampleRate >= 8000 && audioSampleRate <= 48000, E_INVALID_ARG,
+               "Invalid argument is used. Audio sample rate is not valid.");
+
+       ret = audio_out_create(audioSampleRate, _AudioManagerConvert::ConvertChannelType(audioChannelType), _AudioManagerConvert::ConvertSampleType(audioSampleType), _AudioManagerConvert::ConvertAudioStreamType2SoundType(audioStreamType), &__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_create operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_prepare(__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_prepare operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_set_interrupted_cb(__audioOutHandle, AudioIoInterrupted, this);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_set_interrupted_cb operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_get_buffer_size(__audioOutHandle, &__audioOutOptimalBufferSize);
+       if (ret == AUDIO_IO_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "The optimal buffer size is %d", __audioOutOptimalBufferSize);
+       }
+       else
+       {
+               r = MapExceptionToResult(ret);
+               SysLogException(NID_MEDIA, r, "[%s] Failed to perform audio_out_get_buffer_size operation with error code : %x", GetErrorMessage(r), ret);
+       }
+
+       __audioOutOptimalBufferSize = 1024;
+       __presentSampleType = audioSampleType;
+       __presentSampleRate = audioSampleRate;
+
+       __audioOutState = AUDIOOUT_STATE_PREPARED;
+       return r;
+CATCH:
+       __audioOutHandle = null;
+       return r;
+}
+
+result
+_AudioOutImpl::Reset(void)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_MEDIA, __audioOutState <AUDIOOUT_STATE_UNPREPARED && __audioOutState> AUDIOOUT_STATE_PREPARED, E_INVALID_STATE,
+               "The state of this instance is in an invalid state. the current state is %d.", __audioOutState);
+       if (__audioOutState == AUDIOOUT_STATE_PLAYING )
+       {
+               Stop();
+       }
+       __bufferQueue.RemoveAll();
+       __audioOutState = AUDIOOUT_STATE_PREPARED;
+       return r;
+}
+
+result
+_AudioOutImpl::UnPrepare(void)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+
+       SysTryReturnResult(NID_MEDIA, __audioOutState == AUDIOOUT_STATE_PREPARED || __audioOutState == AUDIOOUT_STATE_STOPPED, E_INVALID_STATE,
+               "The state of this instance is in an invalid state. the current state is %d", __audioOutState);
+       __bufferQueue.RemoveAll();
+
+       ret = audio_out_unprepare(__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_prepare operation with error code : %x", GetErrorMessage(r), ret);
+
+       SysTryCatch(NID_MEDIA, __audioOutHandle, r = E_SYSTEM, E_SYSTEM, "__audioout Handle is NULL");
+
+       ret = audio_out_unset_interrupted_cb(__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_unset_interrupted_cb operation with error code : %x", GetErrorMessage(r), ret);
+
+       ret = audio_out_destroy(__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_destroy operation with error code : %d", GetErrorMessage(r), ret);
+       __audioOutHandle = null;
+
+       __audioOutState = AUDIOOUT_STATE_UNPREPARED;
+       return r;
+CATCH:
+       return r;
+}
+
+result
+_AudioOutImpl::Start(void)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+       SysTryReturnResult(NID_MEDIA, __audioOutState == AUDIOOUT_STATE_PREPARED || __audioOutState == AUDIOOUT_STATE_STOPPED, E_INVALID_STATE,
+               "The state of this instance is in an invalid state.");
+
+       ret = audio_out_prepare(__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryReturnResult(NID_MEDIA, r != E_DEVICE_BUSY, E_DEVICE_BUSY, "AudioOut cannot Start, higher priority task at work.");
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Failed to perform audio_out_prepare operation with error code :  0x%x", GetErrorMessage(r), ret);
+
+       __stop = false;
+       __pWorkerThread.reset(new (std::nothrow) Thread);
+       SysTryReturnResult(NID_MEDIA, __pWorkerThread.get() != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       r = __pWorkerThread->Construct(*this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       r = __pWorkerThread->Start();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       __audioOutState = AUDIOOUT_STATE_PLAYING;
+       return r;
+CATCH:
+       SetLastResult(r);
+       return r;
+}
+
+result
+_AudioOutImpl::Stop(void)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_MEDIA, __audioOutState == AUDIOOUT_STATE_PLAYING, E_INVALID_STATE,
+               "The state of this instance is in an invalid state. The current state is %d", __audioOutState);
+       if (__pWorkerThread.get())
+       {
+               __stop = true;
+               __pBufferSync->Notify();
+               r = __pWorkerThread->Join();
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else
+       {
+               SysLog(NID_MEDIA, "Thread is null.");
+       }
+       __audioOutState = AUDIOOUT_STATE_STOPPED;
+       return r;
+}
+
+result
+_AudioOutImpl::WriteBuffer(const Tizen::Base::ByteBuffer& userData)
+{
+       result r = E_SUCCESS;
+       int size = userData.GetLimit();
+       SysTryReturnResult(NID_MEDIA, __audioOutState >= AUDIOOUT_STATE_PREPARED && __audioOutState < AUDIOOUT_STATE_UNPREPARED, E_INVALID_STATE,
+               "The state of this instance is in an invalid state.");
+       SysTryReturnResult(NID_MEDIA, (size >= audioOutMinimumBufferSize), E_INVALID_ARG,
+               "Invalid argument is used. The size of buffer is too small, the current size of buffer is %d. It should be between %d and %d",
+                       audioOutMinimumBufferSize, size, audioOutMaximumBufferSize);
+       SysTryReturnResult(NID_MEDIA, audioOutMaximumBufferSize >= size, E_OVERFLOW, "The size of buffer size is too big, the current size is %d. It should be between %d and %d", audioOutMinimumBufferSize, size, audioOutMaximumBufferSize);
+
+       __pBufferSync->Enter();
+       r = __bufferQueue.Enqueue(&const_cast <ByteBuffer&>(userData));
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       __pBufferSync->Notify();
+       __pBufferSync->Exit();
+       return r;
+CATCH:
+       __pBufferSync->Exit();
+       return r;
+}
+
+Tizen::Base::Object*
+_AudioOutImpl::Run(void)
+{
+       ByteBuffer* pBuffer = null;
+       int buffer_size = 0;
+       unsigned char* pData = NULL;
+       result r = E_SUCCESS;
+       int ret = 0;
+       bool isSuccesful = true;
+       while (!__stop)
+       {
+               if (isSuccesful)
+               {
+                       __pBufferSync->Enter();
+                       if ( __bufferQueue.Peek(pBuffer) == E_UNDERFLOW)
+                       {
+                               //wait
+                               __pBufferSync->Wait();
+                               if (__stop)
+                               {
+                                       __pBufferSync->Exit();
+                                       return this;
+                               }
+                               __bufferQueue.Peek(pBuffer);
+                       }
+                       __pBufferSync->Exit();
+
+                       SysTryCatch(NID_MEDIA, pBuffer, r = E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] Invalid argument is used. The buffer to write is null.");
+
+                       if ((__volume >= 0) && (__volume < 100))
+                       {
+                               PreProcess(pBuffer);
+                       }
+                       isSuccesful = false;
+               }
+
+               buffer_size = pBuffer->GetLimit();
+               pData = (unsigned char*) pBuffer->GetPointer();
+               SysTryCatch(NID_MEDIA, pData, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The data to write is null");
+               if (!__stop)
+               {
+                       ret = audio_out_write(__audioOutHandle, (void*) pData, buffer_size);
+                       if (ret != buffer_size)
+                       {
+                               SysLog(NID_MEDIA, "The size of actual written data is %d", ret);
+                       }
+                       else
+                       {
+                               isSuccesful = true;
+                               if (!__stop)
+                               {
+                                       __pBufferSync->Enter();
+                                       __bufferQueue.Dequeue(pBuffer);
+                                       __pBufferSync->Exit();
+                                       pBuffer = NULL;
+                                       SendBufferEndReachedEvent();
+
+                               }
+                       }
+               }
+       }
+       return this;
+CATCH:
+       return this;
+}
+
+void
+_AudioOutImpl::AudioIoInterrupted(audio_io_interrupted_code_e code, void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The value of pUserData is null.");
+       _AudioOutImpl *pAudioOutImpl = (_AudioOutImpl *)pUserData;
+
+       switch(code)
+       {
+       case AUDIO_IO_INTERRUPTED_COMPLETED:
+               if (pAudioOutImpl->__audioOutState == AUDIOOUT_STATE_STOPPED)
+               {
+                       if (!(pAudioOutImpl->__interruptFlag))
+                       {
+                               pAudioOutImpl->SendReleased();
+                       }
+                       pAudioOutImpl->__interruptFlag = false;
+               }
+               break;
+       case AUDIO_IO_INTERRUPTED_BY_CALL:
+               pAudioOutImpl->__interruptFlag = true;
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_EARJACK_UNPLUG:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_MEDIA:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_RESOURCE_CONFLICT:
+               if (pAudioOutImpl->__audioOutState == AUDIOOUT_STATE_PLAYING)
+               {
+                       pAudioOutImpl->SendAudioFocusChanged();
+               }
+               break;
+       case AUDIO_IO_INTERRUPTED_BY_ALARM:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_EMERGENCY:
+               if (pAudioOutImpl->__audioOutState == AUDIOOUT_STATE_PLAYING)
+               {
+                       pAudioOutImpl->SendInterrupted();
+               }
+               break;
+       default:
+               SysLog(NID_MEDIA, "Interrupt code obtained is wrong - %d", code);
+               break;
+       }
+}
+
+result
+_AudioOutImpl::SendBufferEndReachedEvent(void)
+{
+       result r = E_SUCCESS;
+       _AudioOutEventArg* pAudioOutEventArg = null;
+       pAudioOutEventArg = new (std::nothrow) _AudioOutEventArg;
+       SysTryReturnResult(NID_MEDIA, pAudioOutEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pAudioOutEventArg->SetEventType(_AUDIOOUT_EVENT_DATA_END_REACHED);
+       r = __pAudioOutEvent->FireAsync(*pAudioOutEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pAudioOutEventArg;
+       return r;
+}
+
+result
+_AudioOutImpl::SendInterrupted()
+{
+       result r = E_SUCCESS;
+       _AudioOutEventArg* pAudioOutEventArg = null;
+       pAudioOutEventArg = new (std::nothrow) _AudioOutEventArg;
+       SysTryReturnResult(NID_MEDIA, pAudioOutEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       this->Stop();
+       pAudioOutEventArg->SetEventType(_AUDIOOUT_EVENT_INTERRUPTED);
+       r = __pAudioOutEvent->FireAsync(*pAudioOutEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pAudioOutEventArg;
+       return r;
+}
+
+result
+_AudioOutImpl::SendAudioFocusChanged()
+{
+       result r = E_SUCCESS;
+       _AudioOutEventArg* pAudioOutEventArg = null;
+       pAudioOutEventArg = new (std::nothrow) _AudioOutEventArg;
+       SysTryReturnResult(NID_MEDIA, pAudioOutEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       this->Stop();
+       pAudioOutEventArg->SetEventType(_AUDIOOUT_EVENT_AUDIO_FOCUS_CHANGED);
+       r = __pAudioOutEvent->FireAsync(*pAudioOutEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pAudioOutEventArg;
+       return r;
+}
+
+result
+_AudioOutImpl::SendReleased()
+{
+       result r = E_SUCCESS;
+       _AudioOutEventArg* pAudioOutEventArg = null;
+       pAudioOutEventArg = new (std::nothrow) _AudioOutEventArg;
+       SysTryReturnResult(NID_MEDIA, pAudioOutEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       pAudioOutEventArg->SetEventType(_AUDIOOUT_EVENT_RELEASED);
+       r = __pAudioOutEvent->FireAsync(*pAudioOutEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pAudioOutEventArg;
+       return r;
+}
+
+void
+_AudioOutImpl::ScaleDownVolume(unsigned char* pDataBuffer, int bytes)
+{
+       switch (__presentSampleType)
+       {
+       case AUDIO_TYPE_PCM_U8:
+       {
+               unsigned char* pData = pDataBuffer;
+               int noOfSamples = bytes;
+               for (int i = 0; i < noOfSamples; i++)
+               {
+                       int v = (((*pData - 128) * __volume256 + 128) >> 8) + 128;
+                       *pData++ = av_clip_uint8(v);
+               }
+       }
+       break;
+
+       case AUDIO_TYPE_PCM_S16_LE:
+       {
+               short* pData = (short*) pDataBuffer;
+               int noOfSamples = bytes >> 1;
+               for (int i = 0; i < noOfSamples; i++)
+               {
+                       int v = ((*pData) * __volume256 + 128) >> 8;
+                       *pData++ = av_clip_int16(v);
+               }
+       }
+       break;
+
+       default:
+               break;
+       }
+}
+
+void
+_AudioOutImpl::PreProcess(ByteBuffer* pBuffer)
+{
+       unsigned char* pDataBuffer = null;
+       int bytes = 0;
+       if (pBuffer->GetLimit() > 0)
+       {
+               pDataBuffer = (unsigned char*) pBuffer->GetPointer();
+               if (!pDataBuffer)
+               {
+                       return;
+               }
+               bytes = pBuffer->GetLimit();
+       }
+       else
+       {
+               return;
+       }
+       if ((__volume256 < 256) && (__volume256 >= 0))
+       {
+               ScaleDownVolume(pDataBuffer, bytes);
+       }
+}
+
+result
+_AudioOutImpl::MapExceptionToResult(int reason)
+{
+       //All the fall through are intentional
+       switch (reason)
+       {
+       //Successful
+       case AUDIO_IO_ERROR_NONE:
+               return E_SUCCESS;
+               break;
+       //Out of memory
+       case AUDIO_IO_ERROR_OUT_OF_MEMORY:
+               return E_OUT_OF_MEMORY;
+               break;
+       //Invalid parameter
+       case AUDIO_IO_ERROR_INVALID_PARAMETER:
+               return E_INVALID_ARG;
+               break;
+       //Invalid operation
+       case AUDIO_IO_ERROR_INVALID_OPERATION:
+               return E_INVALID_OPERATION;
+               break;
+       //Deviced not opened
+       case AUDIO_IO_ERROR_DEVICE_NOT_OPENED:
+               return E_INVALID_STATE;
+               break;
+       //Invalid Buffer
+       case AUDIO_IO_ERROR_INVALID_BUFFER:
+               return E_INVALID_ARG;
+               break;
+       //Device not Closed
+       case AUDIO_IO_ERROR_DEVICE_NOT_CLOSED:
+               return E_INVALID_STATE;
+               break;
+       //Sound policy error
+       case AUDIO_IO_ERROR_SOUND_POLICY:
+               return E_DEVICE_BUSY;
+               break;
+       default:
+               return E_SYSTEM;
+               break;
+       }
+}
+
+}}  //Tizen::Media
diff --git a/src/FMedia_AudioRecorderEvent.cpp b/src/FMedia_AudioRecorderEvent.cpp
new file mode 100755 (executable)
index 0000000..5ccc81c
--- /dev/null
@@ -0,0 +1,149 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_AudioRecorderEvent.cpp
+ * @brief                      This file contains the event processing for AudioRecorder
+ */
+
+#include <unique_ptr.h>
+#include <FMediaIAudioRecorderEventListener.h>
+#include <FBaseSysLog.h>
+#include "FMedia_AudioRecorderEvent.h"
+#include "FMedia_RecorderEventArg.h"
+#include "FMedia_AudioRecorderImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+_AudioRecorderEvent::_AudioRecorderEvent(void)
+       : __pAudioRecorderImpl(null)
+{
+
+}
+
+_AudioRecorderEvent::~_AudioRecorderEvent(void)
+{
+
+}
+
+result
+_AudioRecorderEvent::Construct(_AudioRecorderImpl& audioRecorderImpl)
+{
+       result r = E_SUCCESS;
+
+       __pAudioRecorderImpl = &audioRecorderImpl;
+       r = _Event::Initialize();
+       return r;
+}
+
+result
+_AudioRecorderEvent::SendEvent(_RecorderEventType event, RecorderErrorReason err, result res)
+{
+       result r = E_SUCCESS;
+       std::unique_ptr <_RecorderEventArg> pRecorderEventArg (new (std::nothrow) _RecorderEventArg());
+       SysTryReturn(NID_MEDIA, pRecorderEventArg.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pRecorderEventArg->SetEventType(event);
+       pRecorderEventArg->SetResult(res);
+       pRecorderEventArg->SetError(err);
+       r = FireAsync(*(pRecorderEventArg.get()));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       // In case of success, event argument should be released for Base::Event to use the argument continuously.
+       pRecorderEventArg.release();
+       return r;
+}
+
+void
+_AudioRecorderEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       IAudioRecorderEventListener* pAudioRecorderEventListener = dynamic_cast <IAudioRecorderEventListener*>(&listener);
+       SysTryReturn(NID_MEDIA, pAudioRecorderEventListener != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
+
+       Tizen::Base::Runtime::IEventArg* pTtempArg = const_cast <Tizen::Base::Runtime::IEventArg*>(&arg);
+       _RecorderEventArg* pArg = dynamic_cast <_RecorderEventArg*>(pTtempArg);
+       SysTryReturn(NID_MEDIA, pArg != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
+
+       switch (pArg->GetEventType())
+       {
+       case _RECORDER_EVENT_ERROR:
+       {
+               __pAudioRecorderImpl->SetState(RECORDER_STATE_ERROR);
+               pAudioRecorderEventListener->OnAudioRecorderErrorOccurred(pArg->GetError());
+       }
+       break;
+
+       case _RECORDER_EVENT_RECORDING_STARTED:
+       {
+               __pAudioRecorderImpl->SetState(RECORDER_STATE_RECORDING);
+               pAudioRecorderEventListener->OnAudioRecorderStarted(pArg->GetResult());
+       }
+       break;
+
+       case _RECORDER_EVENT_STOPPED:
+       {
+               __pAudioRecorderImpl->SetState(RECORDER_STATE_STOPPED);
+               pAudioRecorderEventListener->OnAudioRecorderStopped(pArg->GetResult());
+       }
+       break;
+
+       case _RECORDER_EVENT_CANCELED:
+       {
+               __pAudioRecorderImpl->SetState(RECORDER_STATE_STOPPED);
+               pAudioRecorderEventListener->OnAudioRecorderCanceled(pArg->GetResult());
+       }
+       break;
+
+       case _RECORDER_EVENT_ENDOF_FILESIZE:
+       {
+               __pAudioRecorderImpl->SetState(RECORDER_STATE_ENDOF_FILE);
+               pAudioRecorderEventListener->OnAudioRecorderEndReached(RECORDING_ENDOF_MAX_TIME);
+       }
+       break;
+
+       case _RECORDER_EVENT_ENDOF_RECTIME:
+       {
+               __pAudioRecorderImpl->SetState(RECORDER_STATE_ENDOF_FILE);
+               pAudioRecorderEventListener->OnAudioRecorderEndReached(RECORDING_ENDOF_MAX_TIME);
+       }
+       break;
+
+       case _RECORDER_EVENT_PAUSED:
+       {
+               __pAudioRecorderImpl->SetState(RECORDER_STATE_PAUSED);
+               pAudioRecorderEventListener->OnAudioRecorderPaused(pArg->GetResult());
+       }
+       break;
+
+       case _RECORDER_EVENT_CLOSED:
+       {
+               __pAudioRecorderImpl->SetState(RECORDER_STATE_CLOSED);
+               pAudioRecorderEventListener->OnAudioRecorderClosed(pArg->GetResult());
+       }
+       break;
+
+       default:
+               break;
+
+       }
+}
+
+}}
+
diff --git a/src/FMedia_AudioRecorderEvent.h b/src/FMedia_AudioRecorderEvent.h
new file mode 100755 (executable)
index 0000000..9e2a7f2
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_AudioRecorderEvent.h
+ * @brief                      This file contains the declaration of event processing for AudioRecorder
+ */
+
+#ifndef _FMEDIA_INTERNAL_AUDIORECORDER_EVENT_H_
+#define _FMEDIA_INTERNAL_AUDIORECORDER_EVENT_H_
+
+#include <FBaseRt_Event.h>
+#include <FMediaRecorderTypes.h>
+#include "FMedia_RecorderTypes.h"
+
+namespace Tizen { namespace Media
+{
+
+class _AudioRecorderImpl;
+
+/**
+ *     @brief  This class provides the Recorder event.
+ *
+ *     This class is the Recorder event, which can notify to the listeners which derives IAudioRecorderEventListener.
+ *     This event is fired upon receipt of notification from subsystem.
+ *     For instances, when the presentation of playback reaches the end of media file, IAudioRecorderEventListener::OnEndOfFileSize is invoked.
+ *
+ *     @see    AudioRecorder, __AudioRecorderEventArg, IAudioRecorderEventListener
+ */
+class _AudioRecorderEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       /**
+        *      The constructor.
+        */
+       _AudioRecorderEvent(void);
+
+       /**
+        *      The destructor.
+        */
+       ~_AudioRecorderEvent(void);
+
+       /**
+        * Initializes a new instance of this class
+        *      @param[in]      audioRecorderImpl       The _AudioRecorderImpl object
+        *
+        */
+       result Construct(_AudioRecorderImpl& audioRecorderImpl);
+
+       /**
+        *      Sends event synchronously.
+        *
+        *      @return         The error code.
+        *      @param[in]      event                                   The event type.
+        *      @param[in]      err                                             The error reason
+        *      @param[in]      res                                             The result of the event
+        *      @exception      E_SUCCESS                                                    - This method is successful.
+        *      @exception      E_OUT_OF_MEMORY                                  - Failed to allocate the required/requested memory.
+        *      @exception      E_INVALID_STATE                 - This instance is in an invalid state for this method.
+        *      @exception      E_INVALID_ARG                                - The argument passed to a method contains an invalid value.
+        */
+       result SendEvent(_RecorderEventType event, RecorderErrorReason err, result res);
+
+protected:
+       /**
+        *      Finds out and invokes the method of listener corresponding to the specified event argument.
+        *
+        *      @param[in]      listener                                               An event listener to be invoked. This must be an instance of ICameraEventListener.
+        *      @param[in]      arg                                                           An argument to be fired.
+        *      @exception      E_SUCCESS                                                    - This method is successful.
+        *      @exception      E_OUT_OF_MEMORY                                  - Failed to allocate the required/requested memory.
+        *      @exception      E_INVALID_STATE                 - This instance is in an invalid state for this method.
+        *      @exception      E_INVALID_ARG                                - The argument passed to a method contains an invalid value.
+        */
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+       _AudioRecorderEvent(const _AudioRecorderEvent& rhs);
+       _AudioRecorderEvent& operator =(const _AudioRecorderEvent& rhs);
+
+       _AudioRecorderImpl* __pAudioRecorderImpl;
+
+};
+
+}}
+
+#endif
diff --git a/src/FMedia_AudioRecorderImpl.cpp b/src/FMedia_AudioRecorderImpl.cpp
new file mode 100755 (executable)
index 0000000..637c143
--- /dev/null
@@ -0,0 +1,1181 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                FMedia_AudioRecorderImpl.cpp
+ * @brief               This file contains the implementation of the _AudioRecorder_Impl class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBase_StringConverter.h>
+#include <FMediaAudioRecorder.h>
+#include "FMedia_MediaUtil.h"
+#include "FMedia_AudioRecorderImpl.h"
+#include "FMedia_AudioRecorderEvent.h"
+#include "FMedia_RecorderUtil.h"
+#include "FMedia_CapabilityImpl.h"
+#include "FMedia_RecorderCapability.h"
+#include "FMedia_RecorderManager.h"
+#include "FMedia_CamPtrUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Media
+{
+static const int _RELOAD_FORMAT = 0x1;
+static const int _RELOAD_QUALITY = 0x1 << 1;
+static const int _RELOAD_MAX_TIME = 0x1 << 2;
+static const int _RELOAD_INIT = 0x1 << 3;
+
+typedef int (*_AudioRecorderFunc )(_RecorderHandle mmHandle);
+
+typedef struct
+{
+       recorder_state_e prevState;
+       recorder_state_e postState;
+       _RecorderStateChangeReason reason;
+       _AudioRecorderFunc  pFunc;
+       RecorderState state;
+}_AudioCommandStateTable;
+
+static const _AudioCommandStateTable _AUDIO_COMMAND_STATE[] =
+{
+       {::RECORDER_STATE_CREATED, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, recorder_prepare, (RecorderState)-1 },
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL, recorder_start, RECORDER_STATE_STARTING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_PAUSED, _RECORDER_STATE_REASON_NORMAL, recorder_pause, RECORDER_STATE_PAUSING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, recorder_commit, RECORDER_STATE_STOPPING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_CANCEL, recorder_cancel, RECORDER_STATE_STOPPING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_SIZE_REACHED, recorder_commit, RECORDER_STATE_RECORDING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_TIME_REACHED, recorder_commit, RECORDER_STATE_RECORDING },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL, recorder_start, RECORDER_STATE_STARTING },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, recorder_commit, RECORDER_STATE_STOPPING },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_CANCEL, recorder_cancel, RECORDER_STATE_STOPPING },
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_CREATED, _RECORDER_STATE_REASON_NORMAL, recorder_unprepare, RECORDER_STATE_CLOSING },
+};
+
+typedef struct
+{
+       recorder_state_e prevState;
+       recorder_state_e postState;
+       _RecorderStateChangeReason reason;
+       _RecorderEventType event;
+       RecorderErrorReason error;
+}_AudioCallbackEventTable;
+
+static const _AudioCallbackEventTable _AUDIO_CALLBACK_EVENT[] =
+{
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_RECORDING_STARTED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_PAUSED, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_PAUSED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_STOPPED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_CANCEL, _RECORDER_EVENT_CANCELED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_SIZE_REACHED, _RECORDER_EVENT_ENDOF_FILESIZE, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_TIME_REACHED, _RECORDER_EVENT_ENDOF_RECTIME, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_OUT_OF_STORAGE, _RECORDER_EVENT_ERROR, RECORDER_ERROR_OUT_OF_STORAGE },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_RECORDING_STARTED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_STOPPED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_CREATED, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_CLOSED, RECORDER_ERROR_NONE },
+};
+
+bool _AudioRecorderImpl::__isUsed = false;
+
+_AudioRecorderImpl::_AudioRecorderImpl(void)
+       : __pAudioRecorderEvent(null)
+       , __pAudioRecorderEventListener(null)
+       , __pRecorderManager(null)
+       , __isConstructed(false)
+       , __state(RECORDER_STATE_INITIALIZED)
+       , __recTime(-1)
+       , __recSize(-1)
+       , __maxTime(DEFAULT_AUDIORECORDING_TIME)
+       , __format(AUDIORECORDING_FORMAT_AMR)
+       , __audioCodec(CODEC_AMR_NB)
+       , __container(MEDIA_CONTAINER_AMR)
+       , __quality(RECORDING_QUALITY_MEDIUM)
+       , __mute(false)
+       , __handle(MM_INVALID_HANDLE)
+       ,__stateChangeReason(_RECORDER_STATE_REASON_NORMAL)
+{
+
+}
+
+_AudioRecorderImpl::~_AudioRecorderImpl(void)
+{
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               int err = ::RECORDER_ERROR_NONE;
+               err = recorder_unset_state_changed_cb(__handle);
+               err = recorder_unset_audio_stream_cb(__handle);
+               err = recorder_unset_recording_limit_reached_cb(__handle);
+               err = recorder_unset_error_cb(__handle);
+               err = recorder_unset_recording_status_cb(__handle);
+               err = recorder_unset_interrupted_cb(__handle);
+               __handle = MM_INVALID_HANDLE;
+       }
+
+       if (__pAudioRecorderEvent != null)
+       {
+               delete __pAudioRecorderEvent;
+       }
+
+       if (__pRecorderManager != null)
+       {
+               _RecorderManager::Release(_RECORDER_DEVICE_AUDIO);
+       }
+
+       if (__isConstructed)
+       {
+               __isUsed = false;
+       }
+
+       SysLog(NID_MEDIA, "Destroyed");
+}
+
+result
+_AudioRecorderImpl::Construct(IAudioRecorderEventListener& listener)
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+       SysLog(NID_MEDIA, "Starting Audio Recorder construct.");
+
+       SysTryReturn(NID_MEDIA, !__isUsed, E_DEVICE_BUSY, E_DEVICE_BUSY,
+                               "[E_DEVICE_BUSY] _AudioRecorderImpl is now being used.");
+       SysTryReturn(NID_MEDIA, !__isConstructed, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. A device is already constructed.");
+
+       //Create Event
+       __pAudioRecorderEvent = new (std::nothrow) _AudioRecorderEvent();
+       SysTryReturn(NID_MEDIA, __pAudioRecorderEvent !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       r = __pAudioRecorderEvent->Construct(*this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pAudioRecorderEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       __pAudioRecorderEventListener = &listener;
+
+       __pRecorderManager = _RecorderManager::AddInstance(_RECORDER_DEVICE_AUDIO);
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, __pRecorderManager != null, , r, "[%s] audio recorder creation failed");
+
+       __handle = __pRecorderManager->GetHandle();
+
+       err = recorder_set_state_changed_cb(__handle, StateChangedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set message callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_audio_stream_cb(__handle, AudioStreamCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set audio stream callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_recording_status_cb(__handle, RecordingStatusCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set recording status callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_recording_limit_reached_cb(__handle, LimitReachedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_error_cb(__handle, ErrorCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_interrupted_cb(__handle, InterruptedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       // Initial configuration. This is needed for the period after Construct() and before CreateAudioFile()
+       r = ReloadConfiguration(_RELOAD_FORMAT | _RELOAD_QUALITY | _RELOAD_MAX_TIME);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder reload configuration failed", GetErrorMessage(r));
+
+       SetState(RECORDER_STATE_INITIALIZED);
+       __isConstructed = true;
+       __isUsed = true;
+       return r;
+
+CATCH:
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               err = recorder_unset_state_changed_cb(__handle);
+               err = recorder_unset_audio_stream_cb(__handle);
+               err = recorder_unset_recording_limit_reached_cb(__handle);
+               err = recorder_unset_error_cb(__handle);
+               err = recorder_unset_recording_status_cb(__handle);
+               err = recorder_unset_interrupted_cb(__handle);
+               err = recorder_destroy(__handle);
+               __handle = MM_INVALID_HANDLE;
+       }
+
+       if (__pAudioRecorderEventListener != null)
+       {
+               __pAudioRecorderEvent->RemoveListener(*__pAudioRecorderEventListener);
+               __pAudioRecorderEventListener = null;
+       }
+
+       if (__pAudioRecorderEvent != null)
+       {
+               delete __pAudioRecorderEvent;
+               __pAudioRecorderEvent = null;
+       }
+
+       return r;
+}
+
+result
+_AudioRecorderImpl::CreateAudioFile(const Tizen::Base::String& mediaLocalPath, bool overwrite)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       int err = ::RECORDER_ERROR_NONE;
+       SysLog(NID_MEDIA, "Creating audio file.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED || state == RECORDER_STATE_CLOSED, E_INVALID_STATE,
+                               E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.",
+                               state);
+
+       std::unique_ptr<char[]> pFileName (_StringConverter::CopyToCharArrayN(mediaLocalPath));
+       SysTryCatch(NID_MEDIA, pFileName.get() != null, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Propagating.", GetErrorMessage(E_INVALID_ARG));
+       SysLog(NID_MEDIA, "File Path : %s\n, overwrite:%d", pFileName.get(), overwrite);
+
+       r = _RecorderUtil::PrepareFile(mediaLocalPath, overwrite);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder prepare file failed. mediaLocalPath:%s, overwirte:%d",
+                          GetErrorMessage(r), pFileName.get(), overwrite);
+
+       err = recorder_set_filename(__handle, pFileName.get());
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set attribute failed. mediaLocalPath:%s", GetErrorMessage(r), pFileName.get());
+
+       SetState(RECORDER_STATE_OPENED);
+
+       // re-configuration for new recorder handle
+       r = ReloadConfiguration(_RELOAD_FORMAT | _RELOAD_QUALITY | _RELOAD_MAX_TIME | _RELOAD_INIT);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder reload configuration failed", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       SetState(state);
+       return r;
+}
+
+result
+_AudioRecorderImpl::Close(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Audio recorder close.");
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_OPENED || state == RECORDER_STATE_STOPPED
+               || state == RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_ERROR
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.",
+               state);
+
+       r = ChangeStateTo(::RECORDER_STATE_CREATED, _RECORDER_STATE_REASON_NORMAL);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+_AudioRecorderImpl::Record(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       recorder_state_e mmState = ::RECORDER_STATE_NONE;
+       SysLog(NID_MEDIA, "Start audio recorder");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_OPENED || state == RECORDER_STATE_PAUSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.",
+                               state);
+
+       mmState = GetMmState();
+       switch (mmState)
+       {
+       case ::RECORDER_STATE_CREATED:
+       {
+               r = ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder init failed.", GetErrorMessage(r));
+               r = ChangeStateTo(::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder start failed.", GetErrorMessage(r));
+       }
+               break;
+
+       case ::RECORDER_STATE_READY:
+       {
+               r = ChangeStateTo(::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder start failed.", GetErrorMessage(r));
+       }
+               break;
+
+       case ::RECORDER_STATE_PAUSED:
+       {
+               r = ChangeStateTo(::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder resume failed.", GetErrorMessage(r));
+       }
+               break;
+
+       default:
+               break;
+       }
+
+       return r;
+
+CATCH:
+       switch (mmState)
+       {
+       case ::RECORDER_STATE_READY:
+       {
+               ChangeStateTo(::RECORDER_STATE_CREATED, _RECORDER_STATE_REASON_NORMAL);
+       }
+               break;
+
+       case ::RECORDER_STATE_PAUSED:
+       {
+               ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL);
+               ChangeStateTo(::RECORDER_STATE_CREATED, _RECORDER_STATE_REASON_NORMAL);
+       }
+               break;
+
+       default:
+               break;
+       }
+
+       return r;
+}
+
+result
+_AudioRecorderImpl::Stop(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Stop audio recorder");
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_RECORDING || state == RECORDER_STATE_PAUSING || state == RECORDER_STATE_PAUSED
+               || state == RECORDER_STATE_STARTING
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.",
+               state);
+
+       r = ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] audio recorder record stop failed.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+_AudioRecorderImpl::Pause(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Pause audio recorder");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_RECORDING, E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.",
+                               state);
+
+       r = ChangeStateTo(::RECORDER_STATE_PAUSED, _RECORDER_STATE_REASON_NORMAL);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] audio recorder pause failed.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+_AudioRecorderImpl::Cancel(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Cancle audio recorder");
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_RECORDING || state == RECORDER_STATE_PAUSING || state == RECORDER_STATE_PAUSED
+               || state == RECORDER_STATE_STARTING, E_INVALID_STATE, E_INVALID_STATE,
+               "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.", state);
+
+       r = ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_CANCEL);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] audio recorder cancel failed.", GetErrorMessage(r));
+
+       return r;
+}
+
+RecorderState
+_AudioRecorderImpl::GetState(void) const
+{
+       return __state;
+}
+
+long
+_AudioRecorderImpl::GetRecordingTime(void) const
+{
+       return __recTime;
+}
+
+long
+_AudioRecorderImpl::GetRecordingSize(void) const
+{
+       return __recSize;
+}
+
+result
+_AudioRecorderImpl::SetMaxRecordingTime(long msTime)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       int err = ::RECORDER_ERROR_NONE;
+       int secTime = MEDIA_INVALID_VALUE;
+       SysLog(NID_MEDIA, "Enter. msTime:%d", msTime);
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.",
+               state);
+
+       SysTryReturn(NID_MEDIA, msTime > 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] msTime:%d must be greater than 0.",
+                               msTime);
+
+       // msec max time is not possible to set
+       secTime = msTime > 1000 ? ((msTime+500)  / 1000) : 1;
+       err = recorder_attr_set_time_limit(__handle, secTime);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set attribute failed. msTime:%ls", GetErrorMessage(r), msTime);
+
+       // For reload and Get the exact value
+       __maxTime = msTime;
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+long
+_AudioRecorderImpl::GetMaxRecordingTime(void) const
+{
+       return __maxTime;
+}
+
+result
+_AudioRecorderImpl::SetFormat(AudioRecordingFormat format)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       CodecType codec = CODEC_NONE;
+       MediaContainerType container = MEDIA_CONTAINER_NONE;
+       int err = ::RECORDER_ERROR_NONE;
+       recorder_audio_codec_e attrCodec = ::RECORDER_AUDIO_CODEC_AMR;
+       recorder_file_format_e attrFormat = ::RECORDER_FILE_FORMAT_AMR;
+       SysLog(NID_MEDIA, "Enter. format:%d", format);
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_INITIALIZED || state == RECORDER_STATE_OPENED || state ==
+               RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.",
+               state);
+
+       SysTryReturn(NID_MEDIA, (format >= AUDIORECORDING_FORMAT_DEFAULT && format <= AUDIORECORDING_FORMAT_WAVE)
+                          , E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] The format(%d) was wrong.", format);
+
+       GetMediaType(format, codec, container);
+       SysLog(NID_MEDIA, "format:%d, codec:0x%x, container:0x%x", format, codec, container);
+
+       r = _RecorderUtil::GetMmAudioCodec(codec, attrCodec);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. audio codec:0x%x", GetErrorMessage(r), codec);
+
+       err = recorder_set_audio_encoder(__handle, attrCodec);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Audio codec set  failed. codec:0x%x", GetErrorMessage(r), codec);
+
+       r = _RecorderUtil::GetMmFileFormat(container, attrFormat);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. container:0x%x", GetErrorMessage(r), container);
+
+       err = recorder_set_file_format(__handle, attrFormat);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] setting file format failed for container:0x%x", GetErrorMessage(r), container);
+
+       __format = format;
+       __audioCodec = codec;
+       __container = container;
+
+       // Call the dependency function.
+       r = ReloadConfiguration(_RELOAD_QUALITY);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder reload configuration failed. format:%d", GetErrorMessage(
+                                  r), format);
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+AudioRecordingFormat
+_AudioRecorderImpl::GetFormat(void) const
+{
+       return __format;
+}
+
+result
+_AudioRecorderImpl::SetFormat(CodecType audioCodec, MediaContainerType container)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       bool supported = false;
+       int err = ::RECORDER_ERROR_NONE;
+       recorder_audio_codec_e attrCodec = ::RECORDER_AUDIO_CODEC_AMR;
+       recorder_file_format_e attrFormat = ::RECORDER_FILE_FORMAT_AMR;
+       SysLog(NID_MEDIA, "Enter. audioCodec:0x%x, container:0x%x", audioCodec, container);
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_INITIALIZED || state == RECORDER_STATE_OPENED || state ==
+               RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.",
+               state);
+
+       std::unique_ptr <IListT<CodecType>, _ListPtrUtil::Remover> pAudioCodecListT (GetSupportedCodecListN(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pAudioCodecListT.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryReturn(NID_MEDIA, pAudioCodecListT->Contains(audioCodec), E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC,
+               "[E_UNSUPPORTED_CODEC]This AudioCodec(%d) is not supported in the device.\n", audioCodec);
+
+       std::unique_ptr <IListT<MediaContainerType>, _ListPtrUtil::Remover> pContainerCodecListT (GetSupportedContainerListN(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pContainerCodecListT.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryReturn(NID_MEDIA, pContainerCodecListT->Contains(container), E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+               "[E_UNSUPPORTED_FORMAT]This Container(%d) is not supported in the device.\n", container);
+
+       supported = _RecorderUtil::CheckFormat(audioCodec, CODEC_NONE, container);
+       SysTryCatch(NID_MEDIA, supported, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[E_UNSUPPORTED_FORMAT] audio recorder check foramt failed. audioCodec:0x%x, videoCodec:0x%x, container:0x%x",
+                          audioCodec, CODEC_NONE, container);
+
+       r = _RecorderUtil::GetMmAudioCodec(audioCodec, attrCodec);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. audio codec:0x%x", GetErrorMessage(r), audioCodec);
+
+       err = recorder_set_audio_encoder(__handle, attrCodec);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Audio codec set  failed. codec:0x%x", GetErrorMessage(r), audioCodec);
+
+       r = _RecorderUtil::GetMmFileFormat(container, attrFormat);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. container:0x%x", GetErrorMessage(r), container);
+
+       err = recorder_set_file_format(__handle, attrFormat);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] setting file format failed for container:0x%x", GetErrorMessage(r), container);
+
+       __audioCodec = audioCodec;
+       __container = container;
+
+       // Call the dependency function.
+       r = ReloadConfiguration(_RELOAD_QUALITY);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder reload configuration failed. audioCodec:0x%x, container:0x%x",
+                          GetErrorMessage(r), audioCodec, container);
+
+CATCH:
+       return r;
+}
+
+void
+_AudioRecorderImpl::GetFormat(CodecType& audioCodec, MediaContainerType& container) const
+{
+       audioCodec = __audioCodec;
+       container = __container;
+}
+
+Tizen::Base::Collection::ArrayListT <CodecType>*
+_AudioRecorderImpl::GetSupportedCodecListN(void) const
+{
+       result r = E_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+       SysLog(NID_MEDIA, "Get supported codec list of audio recorder");
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pIntegerList (_RecorderCapability::GetListN(_AROP_AUDIO_ENCODER, itemType), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list is wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list is empty.");
+
+       std::unique_ptr <ArrayListT<CodecType>, _ListPtrUtil::Remover> pAudioCodecList (new (std::nothrow) ArrayListT<CodecType>(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pAudioCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pAudioCodecList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object(%d) instance is not available.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's format is invalid.", i);
+
+               r = pAudioCodecList->Add((CodecType)pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "Pixel format : %d was added.", pInteger->ToInt());
+       }
+
+       return pAudioCodecList.release();
+
+CATCH:
+       return null;
+}
+
+Tizen::Base::Collection::ArrayListT <MediaContainerType>*
+_AudioRecorderImpl::GetSupportedContainerListN(void) const
+{
+       result r = E_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+       SysLog(NID_MEDIA, "get supported container list of audio recorder");
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pIntegerList (_RecorderCapability::GetListN(_AROP_FILE_FORMAT, itemType), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list is wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list is empty.");
+
+       std::unique_ptr <ArrayListT<MediaContainerType>, _ListPtrUtil::Remover> pContainerList (new (std::nothrow) ArrayListT<MediaContainerType>(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pContainerList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pContainerList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object(%d) instance is not available.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's format is invalid.", i);
+
+               r = pContainerList->Add((MediaContainerType)pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "Pixel format : %d was added.", pInteger->ToInt());
+       }
+
+       return pContainerList.release();
+
+CATCH:
+       return null;
+}
+
+result
+_AudioRecorderImpl::SetQuality(RecordingQuality quality)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       CodecType audioCodec = CODEC_NONE;
+       MediaContainerType container = MEDIA_CONTAINER_NONE;
+       int err = ::RECORDER_ERROR_NONE;
+       int attrSamplerate = 0;
+       int attrChannel = 0;
+       int attrBitrate = 0;
+       SysLog(NID_MEDIA, "Enter. quality:%d", quality);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, r, "[E_INVALID_STATE] AudioRecorder is in an invalid state. AudioRecorder state is %d.", state);
+
+       SysTryReturn(NID_MEDIA, (quality >= RECORDING_QUALITY_LOW && quality <= RECORDING_QUALITY_HIGH)
+                          , E_INVALID_ARG, r, "[E_INVALID_ARG] Invalid argument(quality) is used. quality(%d) is wrong.", quality);
+
+       GetFormat(audioCodec, container);
+
+       r = _RecorderUtil::GetMmAudioQuality(audioCodec, quality, attrSamplerate, attrChannel, attrBitrate);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. audiocodec:0x%x, quality:%d", GetErrorMessage(r), container, quality);
+
+       err = recorder_attr_set_audio_samplerate(__handle, attrSamplerate);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Sampling-rate set  failed. attr:%d", GetErrorMessage(r), attrSamplerate);
+
+       err = recorder_attr_set_audio_channel(__handle, attrChannel);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Channel set  failed. attr:%d", GetErrorMessage(r), attrChannel);
+
+       err = recorder_attr_set_audio_encoder_bitrate(__handle, attrBitrate);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Bitrate set  failed. attr:%d", GetErrorMessage(r), attrBitrate);
+
+       // For keeping the quality of each format. SetQuality will be called again after SetFormat() is changing the format.
+       __quality = quality;
+
+CATCH:
+       return r;
+}
+
+RecordingQuality
+_AudioRecorderImpl::GetQuality(void) const
+{
+       return __quality;
+}
+
+result
+_AudioRecorderImpl::SetMute(bool mute)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       int err = ::RECORDER_ERROR_NONE;
+       SysLog(NID_MEDIA, "Enter. mute:%d", mute);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                               || state == RECORDER_STATE_STOPPED || state == RECORDER_STATE_PAUSED || state == RECORDER_STATE_RECORDING
+                          , E_INVALID_STATE, r, "[E_INVALID_STATE] state:%d, AudioRecorder is in an invalid state. AudioRecorder state is %d.", state);
+
+       err = recorder_attr_set_mute(__handle, mute);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set mute failed", GetErrorMessage(r));
+
+       __mute = mute;
+       return r;
+
+CATCH:
+       return r;
+}
+
+bool
+_AudioRecorderImpl::IsMuted(void) const
+{
+       return __mute;
+}
+
+result
+_AudioRecorderImpl::ConvertResult(int err) const
+{
+       result r = E_SYSTEM;
+       if (err != ::RECORDER_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "MM Err:0x%x", err);
+       }
+
+       // Global error
+       if (err == ::RECORDER_ERROR_NONE)
+       {
+               r = E_SUCCESS;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_PARAMETER)
+       {
+               r = E_INVALID_ARG;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_STATE)
+       {
+               r = E_INVALID_STATE;
+       }
+       else if (err == ::RECORDER_ERROR_OUT_OF_MEMORY)
+       {
+               r = E_OUT_OF_MEMORY;
+       }
+       else if (err == ::RECORDER_ERROR_DEVICE)
+       {
+               r = E_DEVICE_FAILED;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_OPERATION
+               || err == ::RECORDER_ERROR_SECURITY_RESTRICTED)
+       {
+               r = E_SYSTEM;
+       }
+       else if (err == ::RECORDER_ERROR_SOUND_POLICY)
+       {
+               r = E_DEVICE_BUSY;
+       }
+       else
+       {
+               r = E_UNKNOWN;
+       }
+
+       return r;
+}
+
+void
+_AudioRecorderImpl::SetState(RecorderState state)
+{
+       __state = state;
+}
+
+void
+_AudioRecorderImpl::SetRecordingTime(long recTime)
+{
+       __recTime = recTime;
+}
+
+void
+_AudioRecorderImpl::SetRecordingSize(long recSize)
+{
+       __recSize = recSize;
+}
+
+void
+_AudioRecorderImpl::GetMediaType(AudioRecordingFormat format, CodecType& codec, MediaContainerType& container) const
+{
+       switch (format)
+       {
+       case AUDIORECORDING_FORMAT_DEFAULT:
+               //fall through
+       case AUDIORECORDING_FORMAT_AMR:
+       {
+               codec = CODEC_AMR_NB;
+               container = MEDIA_CONTAINER_AMR;
+       }
+               break;
+
+       case AUDIORECORDING_FORMAT_WAVE:
+       {
+               codec = CODEC_LPCM;
+               container = MEDIA_CONTAINER_WAV;
+       }
+               break;
+
+       default:
+       {
+               codec = CODEC_NONE;
+               container = MEDIA_CONTAINER_NONE;
+       }
+               break;
+       }
+}
+
+void
+_AudioRecorderImpl::GetMediaType(MediaContainerType container, AudioRecordingFormat& format) const
+{
+       switch (container)
+       {
+       case MEDIA_CONTAINER_AMR:
+       {
+               format = AUDIORECORDING_FORMAT_AMR;
+       }
+               break;
+
+       case MEDIA_CONTAINER_WAV:
+       {
+               format = AUDIORECORDING_FORMAT_WAVE;
+       }
+               break;
+
+       default:
+       {
+               format = AUDIORECORDING_FORMAT_DEFAULT;
+       }
+               break;
+       }
+}
+
+result
+_AudioRecorderImpl::ReloadConfiguration(int reload)
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+
+       SysLog(NID_MEDIA, "Enter. reload:0x%x", reload);
+
+       if (reload & _RELOAD_FORMAT)
+       {
+               recorder_audio_codec_e attrCodec = ::RECORDER_AUDIO_CODEC_AMR;
+               r = _RecorderUtil::GetMmAudioCodec(__audioCodec, attrCodec);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. audio codec:0x%x", GetErrorMessage(r), __audioCodec);
+
+               err = recorder_set_audio_encoder(__handle, attrCodec);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Audio codec set  failed. codec:0x%x", GetErrorMessage(r), __audioCodec);
+
+               recorder_file_format_e attrFormat = ::RECORDER_FILE_FORMAT_AMR;
+               r = _RecorderUtil::GetMmFileFormat(__container, attrFormat);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. container:0x%x", GetErrorMessage(r), __container);
+
+               err = recorder_set_file_format(__handle, attrFormat);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] setting file format failed for container:0x%x", GetErrorMessage(r), __container);
+       }
+       if (reload & _RELOAD_QUALITY)
+       {
+               int attrSamplerate = 0;
+               int attrChannel = 0;
+               int attrBitrate = 0;
+               r = _RecorderUtil::GetMmAudioQuality(__audioCodec, __quality, attrSamplerate, attrChannel, attrBitrate);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. audiocodec:0x%x, quality:%d", GetErrorMessage(r), __container, __quality);
+
+               err = recorder_attr_set_audio_samplerate(__handle, attrSamplerate);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Sampling-rate set     failed. attr:%d", GetErrorMessage(r), attrSamplerate);
+
+               err = recorder_attr_set_audio_channel(__handle, attrChannel);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Channel set  failed. attr:%d", GetErrorMessage(r), attrChannel);
+
+               err = recorder_attr_set_audio_encoder_bitrate(__handle, attrBitrate);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Bitrate set  failed. attr:%d", GetErrorMessage(r), attrBitrate);
+       }
+       if (reload & _RELOAD_MAX_TIME)
+       {
+               int secTime = 0;
+               secTime = __maxTime > 1000 ? ((__maxTime+500)  / 1000) : 1;
+               err = recorder_attr_set_time_limit(__handle, secTime);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_INIT)
+       {
+               __recTime = 0;
+               __recSize = 0;
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+
+recorder_state_e
+_AudioRecorderImpl::GetMmState(void) const
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+       recorder_state_e mmState = ::RECORDER_STATE_NONE;
+
+       err = recorder_get_state(__handle, &mmState);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return mmState;
+
+CATCH:
+       return ::RECORDER_STATE_NONE;
+}
+
+result
+_AudioRecorderImpl::ChangeStateTo(recorder_state_e mmDestState, _RecorderStateChangeReason reason)
+{
+       result r = E_SUCCESS;
+       int tableTotalCount = 0;
+       int i = 0;
+       int err = MM_SUCCESS;
+       recorder_state_e preState = ::RECORDER_STATE_NONE;
+       recorder_state_e postState = ::RECORDER_STATE_NONE;
+
+       preState = GetMmState();
+       tableTotalCount = sizeof(_AUDIO_COMMAND_STATE) / sizeof(_AUDIO_COMMAND_STATE[0]);
+       SysLog(NID_MEDIA, " PreState:%d, mmDestState:%d, tableTotalCount:%d", preState, mmDestState, tableTotalCount);
+
+       for (i = 0; i < tableTotalCount; i++)
+       {
+               if (preState == _AUDIO_COMMAND_STATE[i].prevState && mmDestState == _AUDIO_COMMAND_STATE[i].postState && reason ==
+                       _AUDIO_COMMAND_STATE[i].reason)
+               {
+                       if (_AUDIO_COMMAND_STATE[i].pFunc != null)
+                       {
+                               SysLog(NID_MEDIA,
+                                                       "Exist the matching state field. loop i:%d, current state:%d, mmDestState:%d, reason:%d", i,
+                                                       preState, mmDestState, reason);
+                               err = _AUDIO_COMMAND_STATE[i].pFunc(__handle);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
+
+                               // Check whether the retuned states are destinationed states.
+                               postState = GetMmState();
+                               SysTryCatch(NID_MEDIA, mmDestState == postState, r = E_INVALID_STATE, E_INVALID_STATE,
+                                                  "[E_INVALID_STATE] recorder_state_e of C-API is in an invalid state. result postState:%d is different from the desired state:%d", postState,
+                                                  mmDestState);
+                               SysLog(NID_MEDIA, "[E_SUCCESS] Found. result postState:%d, param mmDestState:%d", postState, mmDestState);
+
+                               __stateChangeReason = reason;           //for distinguish between stop and cancel and end reach.
+                       }
+
+                       if (_AUDIO_COMMAND_STATE[i].state >= RECORDER_STATE_INITIALIZED && _AUDIO_COMMAND_STATE[i].state <= RECORDER_STATE_ERROR)
+                       {
+                               SysLog(NID_MEDIA, "State set to %d", _AUDIO_COMMAND_STATE[i].state);
+                               SetState(_AUDIO_COMMAND_STATE[i].state);
+                       }
+                       break;
+               }
+
+       }
+       SysTryCatch(NID_MEDIA, i != tableTotalCount, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Not found. ");
+       return r;
+
+CATCH:
+       SysLog(NID_MEDIA, "[%s] Real preState:%d, param mmDestState:%d", GetErrorMessage(r), preState, mmDestState);
+       return r;
+}
+
+_RecorderStateChangeReason
+_AudioRecorderImpl::GetStateChangeReason(void) const
+{
+       return __stateChangeReason;
+}
+
+_AudioRecorderEvent*
+_AudioRecorderImpl::GetEvent(void) const
+{
+       return __pAudioRecorderEvent;
+}
+
+void
+_AudioRecorderImpl::StateChangedCb(recorder_state_e previous, recorder_state_e current, bool byPolicy, void* pUserData)
+{
+       result r = E_SUCCESS;
+       _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>( pUserData);
+       int tableTotalCount = 0;
+       int i = 0;
+       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+       SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
+
+       tableTotalCount = sizeof(_AUDIO_CALLBACK_EVENT) / sizeof(_AUDIO_CALLBACK_EVENT[0]);
+
+       for (i = 0; i < tableTotalCount; i++)
+       {
+               if (previous == _AUDIO_CALLBACK_EVENT[i].prevState && current == _AUDIO_CALLBACK_EVENT[i].postState && pObj->GetStateChangeReason() == _AUDIO_CALLBACK_EVENT[i].reason)
+               {
+                       r = pObj->GetEvent()->SendEvent(_AUDIO_CALLBACK_EVENT[i].event, _AUDIO_CALLBACK_EVENT[i].error, E_SUCCESS);
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
+                       break;
+               }
+       }
+       SysTryReturn(NID_MEDIA, i != tableTotalCount, , E_INVALID_STATE, "[E_INVALID_STATE] Not found. ");
+}
+
+void
+_AudioRecorderImpl::RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData)
+{
+       _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+
+       SysLog(NID_MEDIA, " FileSize:%llu,elapsedTime:%llu",fileSize,elapsedTime);
+
+       pObj->SetRecordingTime((long)elapsedTime);
+       pObj->SetRecordingSize((long)fileSize);
+}
+
+void
+_AudioRecorderImpl::AudioStreamCb(void* pStream, int size, audio_sample_type_e format, int channel, unsigned int timeStamp, void *pUserData)
+{
+       _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+       SysTryReturn(NID_MEDIA, pStream != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. Stream data is null.");
+
+//     SysLog(NID_MEDIA, "Size:%d, format:%d, channel:%d, timeStamp:%u", size, format, channel, timeStamp);
+}
+
+void
+_AudioRecorderImpl::LimitReachedCb(recorder_recording_limit_type_e type, void *pUserData)
+{
+       result r = E_SUCCESS;
+       _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+
+       SysLog(NID_MEDIA, "Type:%d", type);
+
+       switch (type)
+       {
+       case ::RECORDER_RECORDING_LIMIT_TIME:
+       {
+               r = pObj->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_TIME_REACHED);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+               break;
+
+       case ::RECORDER_RECORDING_LIMIT_SIZE:
+       {
+               r = pObj->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_SIZE_REACHED);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+               break;
+
+       case ::RECORDER_RECORDING_LIMIT_FREE_SPACE:
+       {
+               r = pObj->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_OUT_OF_STORAGE);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = pObj->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_OUT_OF_STORAGE, E_STORAGE_FULL);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+               break;
+
+       default:
+               break;
+       }
+
+CATCH:
+       return;
+}
+
+void
+_AudioRecorderImpl::ErrorCb(recorder_error_e error, recorder_state_e state, void *pUserData)
+{
+       result r = E_SUCCESS;
+       _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+
+       SysLog(NID_MEDIA, "Error:%d, state:%d", error, state);
+
+       r = pObj->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_DEVICE_FAILED, E_SUCCESS);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return;
+}
+
+void
+_AudioRecorderImpl::InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData)
+{
+       _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] pObj _AudioRecorderImpl is not available. pObj is null.");
+
+       SysLog(NID_MEDIA, "Policy:%d, previous:%d, current:%d", policy, previous, current);
+}
+
+bool
+_AudioRecorderImpl::IsAlive(void)
+{
+       return __isUsed;
+}
+
+_AudioRecorderImpl*
+_AudioRecorderImpl::GetInstance(AudioRecorder *pAudioRecorder)
+{
+       if ( pAudioRecorder !=null )
+       {
+               return pAudioRecorder->__pImpl;
+       }
+       return null;
+}
+
+const _AudioRecorderImpl*
+_AudioRecorderImpl::GetInstance(const AudioRecorder *pAudioRecorder)
+{
+       if ( pAudioRecorder !=null )
+       {
+               return pAudioRecorder->__pImpl;
+       }
+       return null;
+}
+
+}}   // Tizen::Media
diff --git a/src/FMedia_AudioRecorderImpl.h b/src/FMedia_AudioRecorderImpl.h
new file mode 100755 (executable)
index 0000000..7a95998
--- /dev/null
@@ -0,0 +1,595 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMedia_AudioRecorderImpl.h
+ * @brief              This header file contains the declaration of the _AudioRecorder_Impl class.
+ */
+
+#ifndef _FMEDIA_INTERNAL_AUDIORECORDER_IMPL_H_
+#define _FMEDIA_INTERNAL_AUDIORECORDER_IMPL_H_
+
+#include <FBaseColArrayListT.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioRecorderTypes.h>
+#include "FMedia_RecorderTypes.h"
+#include "FMedia_RecorderTypes.h"
+
+namespace Tizen { namespace Media
+{
+class AudioRecorder;
+class IAudioRecorderEventListener;
+class _AudioRecorderEvent;
+class _RecorderManager;
+
+/**
+ * @class      _AudioRecorderImpl
+ * @brief      This class records the audio data into a file.
+ */
+
+class _AudioRecorderImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
+        *              initialize this instance.
+        * @see         Construct()
+        */
+       _AudioRecorderImpl(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are released by this method. This method should be called in the same thread in
+        * which the Construct() method is called.
+        *
+        * @see     Construct()
+        */
+       virtual ~_AudioRecorderImpl(void);
+
+
+public:
+       /**
+       * Initializes this instance of %_AudioRecorderImpl with the specified listener.
+       *
+       * @return               An error code
+       * @param[in]    listener                        An event listener instance
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE     This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_DEVICE_BUSY           The device cannot be approached because of other operations.
+       */
+       result Construct(IAudioRecorderEventListener& listener);
+
+       /**
+       * Creates an audio file for the recording.
+       *
+       * @return               An error code
+       * @param[in]    destMediaPath                   The file destination to write @n
+       *                                                                               The available paths start with prefixes retrieved from the functions such as: @n
+       *                                                                               Tizen::App::App::GetInstance()->GetAppRootPath() @n
+       *                                                                               Tizen::System::Environment::GetMediaPath() @n
+       *                                                                               Tizen::System::Environment::GetExternalStoragePath()
+       * @param[in]    overwrite                   Set to @c true to overwrite a file if it already exists, @n
+       *                                                                               else @c false
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_RESOURCE_UNAVAILABLE  The required path is unavailable.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_FILE_ALREADY_EXIST    The specified file already exists.
+       * @exception    E_STORAGE_FULL                  The storage is full.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see Close()
+       */
+       result CreateAudioFile(const Tizen::Base::String& destMediaPath, bool overwrite);
+
+       /**
+       * Closes a file.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  CreateAudioFile()
+       * @remarks      This method is synchronous.
+       */
+       result Close(void);
+
+       /**
+       * Starts recording or resumes a recording after Pause() is called.
+       *
+       * @return           An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  Stop(), Pause()
+       */
+       result Record(void);
+
+       /**
+       * Stops a recording.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  Record(), Pause()
+       */
+       result Stop(void);
+
+       /**
+       * Pauses a recording. @n
+       * To resume a recording after this method is called, the Record() method must be called.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  Record(), Stop()
+       */
+       result Pause(void);
+
+       /**
+       * Cancels a recording operation without saving the data.
+       *
+       * @return           An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks      If this method is called, the state is changed to ::RECORDER_STATE_STOPPING. @n
+       *                       After IAudioRecorderEventListener::OnAudioRecorderCanceled() is called, the state is changed
+       *                       to ::RECORDER_STATE_STOPPED.
+       * @see          Record(), Stop()
+       */
+       result Cancel(void);
+
+       /**
+       * Gets the state of an audio recorder.
+       *
+       * @return           The current state of an audio recorder
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  CreateAudioFile(), Close(), Record(), Stop(), Pause()
+       */
+       RecorderState GetState(void) const;
+
+       /**
+       * Gets the current recording time.
+       *
+       * @return           The value indicating the current recording time in milliseconds, @n
+       *                               else @c -1 if the recording has not started as yet
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       long GetRecordingTime(void) const;
+
+       /**
+       * Gets the current recording size.
+       *
+       * @return               The value indicating the current recording size in bytes, @n
+       *                               else @c -1 if the recording has not started as yet
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       long GetRecordingSize(void) const;
+
+       /**
+       * Sets the recording time limit for a file in milliseconds.
+       *
+       * @return               An error code
+       * @param[in]    msTime          The maximum recording time in milliseconds @n
+       *                                                       The time must be greater than @c 0.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                  The specified time is out of range.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The default time is @c 60 seconds.
+       * @see                  GetMaxRecordingTime()
+       */
+       result SetMaxRecordingTime(long msTime);
+
+       /**
+       * Gets the recording time limit of a file in milliseconds.
+       *
+       * @return               A @c long value indicating the maximum recording time in milliseconds
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetMaxRecordingTime()
+       */
+       long GetMaxRecordingTime(void) const;
+
+       /**
+       * Sets the audio format of an audio recorder. @n
+       * Initially, the default format is set using the internal configuration.
+       *
+       * @return               An error code
+       * @param[in]    format          The audio format to set @n
+       *                                                       ::AUDIORECORDING_FORMAT_DEFAULT sets the system's default recording format.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @see                  GetFormat()
+       */
+       result SetFormat(AudioRecordingFormat format);
+
+       /**
+       * Gets the audio recording format of an audio recorder.
+       *
+       * @return               The audio recording format, @n
+       *               else default format if SetFormat() is not called before calling this method
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetFormat()
+       */
+       AudioRecordingFormat GetFormat(void) const;
+
+       /**
+       * Sets the audio codec and the container of an audio recorder. @n
+       * Initially, the default codec and the container format are set using the internal configuration.
+       *
+       * @return               An error code
+       * @param[in]    audioCodec                              The audio codec to set
+       * @param[in]    container                               The media container to set
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified container format is not supported.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              If the specified container does not support the specified codec, E_UNSUPPORTED_FORMAT may be thrown.
+       * @see                  GetFormat( CodecType& audioCodec, MediaContainerType& container ) const
+       */
+       result SetFormat(CodecType audioCodec, MediaContainerType container);
+
+       /**
+       * Gets the audio codec and container of an audio recorder.
+       *
+       * @return               An error code
+       * @param[out]   audioCodec                      The retrieved audio codec
+       * @param[out]   container                       The retrieved container
+       * @remarks              If SetFormat(CodecType audioCodec, MediaContainerType container) is not called before calling
+       *                               this method, the default codec and container are retrieved.
+       * @see                  SetFormat( CodecType audioCodec, MediaContainerType container )
+       */
+       void GetFormat(CodecType& audioCodec, MediaContainerType& container) const;
+
+       /**
+       * Gets a list of the supported audio codecs. @n
+       * Each list's item has a ::CodecType value.
+       *
+       * @return       A list of supported audio codecs, @n
+       *                               else @c null if no codec is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *               The return value must be released by the caller.
+       * @see                  SetFormat(CodecType audioCodec, MediaContainerType container), GetFormat(CodecType&
+       *                               audioCodec, MediaContainerType& container) const
+       */
+       Tizen::Base::Collection::ArrayListT <CodecType>* GetSupportedCodecListN(void) const;
+
+       /**
+       * Gets a list of the supported containers. @n
+       * Each list's item has a ::MediaContainerType value.
+       *
+       * @return       A list of supported container list, @n
+       *                               else @c null if no container is supported or if an exception occurs
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *               The return value must be released by the caller.
+       * @see                  SetFormat(CodecType audioCodec, MediaContainerType container), GetFormat(CodecType&
+       *                               audioCodec, MediaContainerType& container) const
+       */
+       Tizen::Base::Collection::ArrayListT <MediaContainerType>* GetSupportedContainerListN(void) const;
+
+       /**
+       * Sets the audio recording quality of the audio recorder.
+       *
+       * @return               An error code
+       * @param[in]    quality                         The audio recording quality of the audio recorder @n
+       *                                                                       The default value is ::RECORDING_QUALITY_MEDIUM.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c quality is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @see                  GetQuality()
+       */
+       result SetQuality(RecordingQuality quality);
+
+       /**
+       * Gets the audio recording quality of the audio recorder.
+       *
+       * @return               The current audio recording quality of the audio recorder
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetQuality()
+       */
+       RecordingQuality GetQuality(void) const;
+
+       /**
+       * Enables or disables the mute state of an audio recorder.
+       *
+       * @return               An error code
+       * @param[in]    mute                The mute state @n
+       *                                                                       By default, the mute state is disabled.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+       * @remarks              The audio recording continues even though the audio recorder is in the mute state.
+       * @see                  IsMuted()
+       */
+       result SetMute(bool mute);
+
+       /**
+       * Checks whether the mute state is enabled for an audio recorder.
+       *
+       * @return               @c true if the audio recorder is not recording any sound, @n
+       *                               else @c false
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetMute()
+       */
+       bool IsMuted(void) const;
+
+       /**
+       * Sets the state.
+       *
+       * @param[in]    state           new _AudioRecorder's state
+       */
+       void SetState(RecorderState state);
+
+       /**
+       * Sets the recording time
+       *
+       * @param[in]    recTime             recording time in milliseconds
+       */
+       void SetRecordingTime(long recTime);
+
+       /**
+       * Sets the recording size
+       *
+       * @param[in]    recSize             recording size in bytes
+       */
+       void SetRecordingSize(long recSize);
+
+       /**
+       * Gets the new media type from the old type.
+       *
+       * @param[in]    format          recording type
+       * @param[out]   codec           codec type matching the input format
+       * @param[out]   container       container type matching the input format
+       *
+       */
+       void GetMediaType(AudioRecordingFormat format, CodecType& codec, MediaContainerType& container) const;
+
+       /**
+       * Gets the old media type from the new type.
+       *
+       * @param[in]    container       container type
+       * @param[out]   format          format type  matching the input container
+       *
+       */
+       void GetMediaType(MediaContainerType container, AudioRecordingFormat& format) const;
+
+       /**
+       * Gets the recorder's state.
+       *
+       * @return           The state
+       *
+       */
+       recorder_state_e GetMmState(void) const;
+
+       /**
+       * Get the event processing object.
+       *
+       * @return       The event processing object.
+       * @remarks      This event is working synchronously.
+       */
+       _AudioRecorderEvent* GetEvent(void) const;
+
+       /**
+       * Message callback function
+       *
+       * @param[in]    previous         Previous recorder state
+       * @param[in]    current         Current recorder state
+       * @param[in]    byPolicy                true if the state is changed by policy, otherewise false
+       * @param[in]    pUserData               User data
+        */
+       static void StateChangedCb(recorder_state_e previous, recorder_state_e current, bool byPolicy, void* pUserData);
+
+       /**
+       * Recording Status callback function
+       *
+       * @param[in]    elapsedTime      recording time elapsed
+       * @param[in]    fileSize         size of file written
+       * @param[in]    pUserData        User data
+        */
+       static void RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData);
+
+       /**
+       * Audio stream callback function
+       *
+       * @param[in]    pStream          Stream data
+       * @param[in]    format          Sample format
+       * @param[in]    channel         Sample channel
+       * @param[in]    timeStampl      The time stamp
+       * @param[in]    pUserData               User data
+        */
+       static void AudioStreamCb(void* pStream, int size, audio_sample_type_e format, int channel, unsigned int timeStamp, void *pUserData);
+
+       /**
+       * Limit reached callback function
+       *
+       * @param[in]    type          Limit reached reason
+       * @param[in]    pUserData               User data
+        */
+       static void LimitReachedCb(recorder_recording_limit_type_e type, void *pUserData);
+
+       /**
+       * Message callback function
+       *
+       * @param[in]    error                   Error reason
+       * @param[in]    state           Error state
+       * @param[in]    pUserData               User data
+        */
+       static void ErrorCb(recorder_error_e error, recorder_state_e state, void *pUserData);
+
+       /**
+       * Message callback function
+       *
+       * @param[in]    policy          The policy which occurs the interruption
+       * @param[in]    previous                Previous recorder state
+       * @param[in]    current         Current recorder state
+       * @param[in]    pUserData               User data
+        */
+       static void InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData);
+
+       /**
+        * Function check fo this object is alive.
+        *
+        * @return              true if the object is alive, otherwise false.
+        */
+       static bool IsAlive(void);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return              The pointer to %_AudioRecorderImpl
+        * @param[in]   pAudioRecorder          The %AudioRecorder pointer
+        */
+       static _AudioRecorderImpl* GetInstance(AudioRecorder *pAudioRecorder);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return              The pointer to %_AudioRecorderImpl
+        * @param[in]   pAudioRecorder          The %AudioRecorder pointer
+        */
+       static const _AudioRecorderImpl* GetInstance(const AudioRecorder *pAudioRecorder);
+
+private:
+       /**
+       * Converts the error from recorder to Result.
+       *
+       * @return       An error code
+       * @param[in]    err             recorder error
+       */
+       result ConvertResult(int err) const;
+
+       /**
+       * Transfer the state.
+       *
+       * @return       An error code
+       * @param[in]    mmDestState             recorder's destinationed state
+       * @param[in]    reason           state changed reason
+       * @remarks      This method makes the recorder's state change. @n
+       *                       Sometimes, acccording to this, Recorder's state is changed.
+       */
+       result ChangeStateTo(recorder_state_e mmDestState, _RecorderStateChangeReason reason);
+
+       /**
+       * Checks the operation is for completing.
+       *
+       * @return               The state change reason
+       * @remarks      If the Cancel() is called, this value is false, because the Record() is not completed.
+       */
+       _RecorderStateChangeReason GetStateChangeReason(void) const;
+
+       /**
+       * Re-load configuration.
+       *
+       * @return       An error code
+       * @param[in]    reload                  reload configuration field
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @remarks      Multiple configuration field can be set using reloadConf parameter appending.
+       */
+       result ReloadConfiguration(int reload);
+
+       _AudioRecorderImpl(const _AudioRecorderImpl&);
+       _AudioRecorderImpl& operator =(const _AudioRecorderImpl& _AudioRecorderImpl);
+
+       _AudioRecorderEvent* __pAudioRecorderEvent;
+       IAudioRecorderEventListener* __pAudioRecorderEventListener;
+       _RecorderManager* __pRecorderManager;
+       bool __isConstructed;
+       RecorderState __state;
+       long __recTime;
+       long __recSize;
+       long __maxTime;
+       AudioRecordingFormat __format;
+       CodecType __audioCodec;
+       MediaContainerType __container;
+       RecordingQuality __quality;
+       bool __mute;
+       _RecorderHandle __handle;
+       _RecorderStateChangeReason __stateChangeReason;
+       static bool __isUsed;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioRouteEvent.cpp b/src/FMedia_AudioRouteEvent.cpp
new file mode 100644 (file)
index 0000000..6d9ea0c
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseRtThread.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include "FMedia_AudioRouteEvent.h"
+#include "FMedia_AudioRouteEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Media
+{
+
+_AudioRouteEvent::_AudioRouteEvent(void)
+       :__pListener(null)
+{
+}
+
+_AudioRouteEvent::~_AudioRouteEvent(void)
+{
+}
+
+result
+_AudioRouteEvent::Construct(void)
+{
+       result r = E_SUCCESS;
+       __pListener = null;
+
+       r = _Event::Initialize();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+
+void
+_AudioRouteEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       IAudioRouteEventListener *pAudioRouteEventListener = dynamic_cast<IAudioRouteEventListener*> (&listener);
+       SysTryReturn(NID_MEDIA, pAudioRouteEventListener, , E_SYSTEM,
+               "[E_SYSTEM] A system error has been occurred. The value of pAudioRouteEventListener is null.");
+
+       __pListener = pAudioRouteEventListener;
+
+       const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
+       AudioRouteInfo routeInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
+
+       _AudioRouteEventArg *pArg = (_AudioRouteEventArg*) pTempArg;
+       switch (pArg->GetEventType())
+       {
+       case _AUDIO_ROUTE_EVENT_ADDED:
+               ((_AudioRouteEventArg *) pArg)->GetAudioRouteInfo(routeInfo);
+               SysLog(NID_MEDIA, "Input Device is %d, Output device is %d", routeInfo.GetInputAudioDevice(), routeInfo.GetOutputAudioDevice());
+               pAudioRouteEventListener->OnAudioRouteAdded(routeInfo);
+               break;
+       case _AUDIO_ROUTE_EVENT_REMOVED:
+               ((_AudioRouteEventArg *) pArg)->GetAudioRouteInfo(routeInfo);
+               SysLog(NID_MEDIA, "Input Device is %d, Output device is %d ", routeInfo.GetInputAudioDevice(), routeInfo.GetOutputAudioDevice());
+               pAudioRouteEventListener->OnAudioRouteRemoved(routeInfo);
+               break;
+       case _AUDIO_ROUTE_EVENT_ACTIVE_CHANGED:
+               ((_AudioRouteEventArg *) pArg)->GetAudioRouteInfo(routeInfo);
+               SysLog(NID_MEDIA, "Input Device is %d, Output device is %d ", routeInfo.GetInputAudioDevice(), routeInfo.GetOutputAudioDevice());
+               pAudioRouteEventListener->OnActiveAudioRouteChanged(routeInfo);
+               break;
+       default:
+               SysTryLog(NID_MEDIA, false, "Event type is wrong.");
+               break;
+       }
+}
+};
+};
diff --git a/src/FMedia_AudioRouteEvent.h b/src/FMedia_AudioRouteEvent.h
new file mode 100644 (file)
index 0000000..bc8b568
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_AudioInEvent.h
+// @brief                      This header file contains the declaration related to AudioIn class
+//
+//
+
+
+#ifndef _FMEDIA_INTERNAL_AVAILABLE_ROUTE_EVENT_H
+#define _FMEDIA_INTERNAL_AVAILABLE_ROUTE_EVENT_H
+
+#include <FBaseRtThread.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseRt_Event.h>
+#include <FMediaIAudioRouteEventListener.h>
+
+namespace Tizen { namespace Media
+{
+
+
+class _AudioRouteEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+public:
+       _AudioRouteEvent(void);
+       ~_AudioRouteEvent(void);
+       result Construct(void);
+
+protected:
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+private:
+       _AudioRouteEvent(const _AudioRouteEvent& rhs);
+       _AudioRouteEvent& operator =(const _AudioRouteEvent& rhs);
+       IAudioRouteEventListener* __pListener;
+};     // _AudioRouteEvent
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioRouteEventArg.cpp b/src/FMedia_AudioRouteEventArg.cpp
new file mode 100644 (file)
index 0000000..ebaa248
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMedia_AudioRouteEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_AudioRouteEventTypeArg::_AudioRouteEventTypeArg(void)
+       : __audioRouteEventType(_AUDIO_ROUTE_EVENT_NONE)
+{
+
+}
+
+_AudioRouteEventTypeArg::~_AudioRouteEventTypeArg(void)
+{
+
+}
+
+void
+_AudioRouteEventTypeArg::SetEventType(_AudioRouteEventType eType)
+{
+       __audioRouteEventType = eType;
+}
+
+_AudioRouteEventType
+_AudioRouteEventTypeArg::GetEventType(void) const
+{
+       return __audioRouteEventType;
+}
+
+_AudioRouteEventArg::_AudioRouteEventArg(void)
+       : __route(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE)
+{
+
+}
+
+_AudioRouteEventArg::~_AudioRouteEventArg(void)
+{
+
+}
+
+void
+_AudioRouteEventArg::GetAudioRouteInfo(AudioRouteInfo& route)
+{
+       route = __route;
+}
+void
+_AudioRouteEventArg::SetAudioRouteInfo(AudioRouteInfo& route)
+{
+       __route = route;
+}
+
+};
+};   // Tizen::Media
diff --git a/src/FMedia_AudioRouteEventArg.h b/src/FMedia_AudioRouteEventArg.h
new file mode 100644 (file)
index 0000000..c1eb028
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_AudioRouteEventArg.h
+// @brief                      This header file contains the declaration related to _AudioRouteImpl class.
+//
+//
+
+
+#ifndef _FMEDIA_INTERNAL_AVAILABLE_ROUTE_EVENT_ARG_H_
+#define _FMEDIA_INTERNAL_AVAILABLE_ROUTE_EVENT_ARG_H_
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaAudioRouteInfo.h>
+
+namespace Tizen {namespace Media
+{
+
+class _AudioRouteImpl;
+
+enum _AudioRouteEventType
+{
+       _AUDIO_ROUTE_EVENT_NONE // Event_None
+       , _AUDIO_ROUTE_EVENT_ADDED// Available Path changed
+       , _AUDIO_ROUTE_EVENT_REMOVED// Available Path changed
+       , _AUDIO_ROUTE_EVENT_ACTIVE_CHANGED// Available Path changed
+};
+
+class _AudioRouteEventTypeArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+       _AudioRouteEventTypeArg(void);
+       virtual ~_AudioRouteEventTypeArg(void);
+       _AudioRouteEventType GetEventType(void) const;
+private:
+       void SetEventType(_AudioRouteEventType eType);
+       _AudioRouteEventTypeArg(const _AudioRouteEventTypeArg& rhs);
+       _AudioRouteEventTypeArg& operator =(const _AudioRouteEventTypeArg& rhs);
+       _AudioRouteEventType __audioRouteEventType;
+       friend class _AudioRouteManagerImpl;
+};     //_AudioRouteEventTypeArg
+
+class _AudioRouteEventArg
+       : public _AudioRouteEventTypeArg
+{
+public:
+       _AudioRouteEventArg(void);
+       ~_AudioRouteEventArg(void);
+       void GetAudioRouteInfo(AudioRouteInfo & route);
+private:
+       void SetAudioRouteInfo(AudioRouteInfo& route);
+       AudioRouteInfo __route;
+       friend class _AudioRouteManagerImpl;
+};     //_AudioRouteEventArg
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioRouteInfoImpl.cpp b/src/FMedia_AudioRouteInfoImpl.cpp
new file mode 100644 (file)
index 0000000..90fede3
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+#include <FBaseSysLog.h>
+#include "FMedia_AudioRouteInfoImpl.h"
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+_AudioRouteInfoImpl::_AudioRouteInfoImpl(InputAudioDevice in, OutputAudioDevice out)
+       : __in(in)
+       , __out(out)
+{
+}
+
+_AudioRouteInfoImpl::~_AudioRouteInfoImpl()
+{
+}
+
+_AudioRouteInfoImpl::_AudioRouteInfoImpl(const _AudioRouteInfoImpl& rhs)
+{
+       __in = rhs.__in;
+       __out = rhs.__out;
+}
+
+void
+_AudioRouteInfoImpl::SetInputAudioDevice(InputAudioDevice in)
+{
+       __in = in;
+}
+
+void
+_AudioRouteInfoImpl::SetOutputAudioDevice(OutputAudioDevice out)
+{
+       __out = out;
+}
+
+InputAudioDevice
+_AudioRouteInfoImpl::GetInputAudioDevice(void) const
+{
+       return __in;
+}
+
+OutputAudioDevice
+_AudioRouteInfoImpl::GetOutputAudioDevice(void) const
+{
+       return __out;
+}
+
+_AudioRouteInfoImpl&
+_AudioRouteInfoImpl::operator =(const _AudioRouteInfoImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+       this->__in = rhs.__in;
+       this->__out = rhs.__out;
+
+       return *this;
+}
+
+bool
+_AudioRouteInfoImpl::Equals(const Object& obj) const
+{
+       const _AudioRouteInfoImpl *pRhs = dynamic_cast<const _AudioRouteInfoImpl *>(&obj);
+       if (pRhs == null)
+       {
+               return false;
+       }
+       return ((__in == pRhs->__in) && (__out == pRhs->__out));
+
+}
+
+int
+_AudioRouteInfoImpl::GetHashCode(void) const
+{
+       return __in + __out;
+}
+
+};
+};
diff --git a/src/FMedia_AudioRouteInfoImpl.h b/src/FMedia_AudioRouteInfoImpl.h
new file mode 100644 (file)
index 0000000..4070727
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef _FMEDIA_INTERNAL_AUDIO_ROUTE_INFO_IMPL_H_
+#define _FMEDIA_INTERNAL_AUDIO_ROUTE_INFO_IMPL_H_
+
+#include <FMediaAudioManagerTypes.h>
+
+namespace Tizen { namespace Media
+{
+class _AudioRouteInfoImpl
+       :public Tizen::Base::Object
+{
+public:
+       _AudioRouteInfoImpl(InputAudioDevice in, OutputAudioDevice out);
+       virtual ~_AudioRouteInfoImpl(void);
+       void SetInputAudioDevice(InputAudioDevice in);
+       void SetOutputAudioDevice(OutputAudioDevice out);
+       InputAudioDevice GetInputAudioDevice(void) const;
+       OutputAudioDevice GetOutputAudioDevice(void) const;
+       _AudioRouteInfoImpl(const _AudioRouteInfoImpl& rhs);
+       _AudioRouteInfoImpl& operator =(const _AudioRouteInfoImpl& rhs);
+       virtual bool Equals(const Object& obj) const;
+       virtual int GetHashCode(void) const;
+private:
+       InputAudioDevice __in;
+       OutputAudioDevice __out;
+};
+}
+}
+#endif
diff --git a/src/FMedia_AudioRouteManagerImpl.cpp b/src/FMedia_AudioRouteManagerImpl.cpp
new file mode 100644 (file)
index 0000000..3873314
--- /dev/null
@@ -0,0 +1,484 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License)
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <iostream>
+#include <pthread.h>
+#include <sound_manager.h>
+#include <FBaseCol.h>
+#include <FBaseRt.h>
+#include <FBaseSysLog.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaIAudioRouteEventListener.h>
+#include "FMedia_AudioManagerConvert.h"
+#include "FMedia_AudioRouteManagerImpl.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_AudioRouteManagerImpl* _AudioRouteManagerImpl::__pAudioRouteImpl = null;
+
+_AudioRouteManagerImpl::_AudioRouteManagerImpl(void)
+       : __pListener(null)
+       , __pSingleAudioRouteListner(null)
+{
+
+}
+
+_AudioRouteManagerImpl::~_AudioRouteManagerImpl(void)
+{
+       __pSingleAudioRouteListner = null;
+       sound_manager_unset_available_route_changed_cb();
+       sound_manager_unset_active_device_changed_cb();
+}
+
+void
+_AudioRouteManagerImpl::InitAudioRouteManagerImpl(void)
+{
+       static _AudioRouteManagerImpl instance;
+       __pAudioRouteImpl = &instance;
+}
+
+_AudioRouteManagerImpl*
+_AudioRouteManagerImpl::GetInstance(void)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (__pAudioRouteImpl == null)
+       {
+               pthread_once(&onceBlock, InitAudioRouteManagerImpl);
+               r = __pAudioRouteImpl->Construct();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, ,r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return __pAudioRouteImpl;
+CATCH:
+       __pAudioRouteImpl = null;
+       return null;
+}
+
+result
+_AudioRouteManagerImpl::Construct(void)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+
+       __pAudioRouteEvent.reset(new (std::nothrow) _AudioRouteEvent);
+       SysTryCatch(NID_MEDIA, __pAudioRouteEvent.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = __pAudioRouteEvent->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS , , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ret = sound_manager_set_available_route_changed_cb(SoundAvailableRouteChangedCallback, this);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Failed to perform sound_manager_set_available_route_changed_cb operation with error code : %x", GetErrorMessage(r), ret);
+
+       ret = sound_manager_set_active_device_changed_cb(SoundActiveDeviceChangedCallback, this);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Failed to perform sound_manager_set_active_device_changed_cb operation with error code : %x", GetErrorMessage(r), ret);
+       return r;
+CATCH:
+       return r;
+}
+
+bool
+_AudioRouteManagerImpl::SoundAvailableRouteCallback(sound_route_e route, void* pUserData)
+{
+       AudioRouteInfo* pAudioDevice = null;
+       pAudioDevice = new (std::nothrow) AudioRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
+       SysTryReturn(NID_MEDIA, pAudioDevice != null, false, E_OUT_OF_MEMORY, " [E_OUT_OF_MEMORY] Memory allocation failed.");
+       IList* pAudioDeviceList = null;
+       pAudioDeviceList = (IList *)pUserData;
+       if ((sound_device_out_e)route < SOUND_DEVICE_OUT_SPEAKER)
+       //route returned is an Input device
+       {
+               pAudioDevice->SetInputAudioDevice((ConvertSoundIn2InputAudio((unsigned int)route)));
+       }
+       else if (route & (route - 1))
+       // route returned is a combination of output and output
+       // if it is a power of 2 then its a output device only
+       {
+               ConvertRoute2AudioDevice((unsigned int)route, *pAudioDevice);
+       }
+       else
+       // route returned is a output device
+       {
+               pAudioDevice->SetOutputAudioDevice((ConvertSoundOut2OutputAudio((unsigned int)route)));
+       }
+       pAudioDeviceList->Add(*pAudioDevice);
+       return true;
+}
+
+void
+_AudioRouteManagerImpl::SoundAvailableRouteChangedCallback(sound_route_e route, bool available, void* pUserData)
+{
+       result r = E_SUCCESS;
+       AudioRouteInfo audioRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
+       _AudioRouteManagerImpl* pAudioRouteImpl = (_AudioRouteManagerImpl *)pUserData;
+       SysTryReturn(NID_MEDIA, pAudioRouteImpl, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The value of pUserData is null.");
+
+       if ((sound_device_out_e)route < SOUND_DEVICE_OUT_SPEAKER)
+       {
+               audioRouteInfo.SetInputAudioDevice((ConvertSoundIn2InputAudio((unsigned int)route)));
+       }
+       else if (route & (route - 1))
+       {
+               ConvertRoute2AudioDevice((unsigned int)route, audioRouteInfo);
+       }
+       else
+       {
+               audioRouteInfo.SetOutputAudioDevice((ConvertSoundOut2OutputAudio((unsigned int)route)));
+       }
+       SysLog(NID_MEDIA, "Input device is %d, Output device is %d and Available is %d", audioRouteInfo.GetInputAudioDevice(), audioRouteInfo.GetOutputAudioDevice(), available);
+
+       _AudioRouteEventArg* pRouteEventArg = new (std::nothrow) _AudioRouteEventArg;
+       SysTryReturn(NID_MEDIA, pRouteEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       if (available)
+       {
+               pRouteEventArg->SetEventType(_AUDIO_ROUTE_EVENT_ADDED);
+       }
+       else
+       {
+               pRouteEventArg->SetEventType(_AUDIO_ROUTE_EVENT_REMOVED);
+       }
+       pRouteEventArg->SetAudioRouteInfo(audioRouteInfo);
+       r = pAudioRouteImpl->__pAudioRouteEvent->FireAsync(*pRouteEventArg);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform FireAsync operation.", GetErrorMessage(r));
+}
+
+void
+_AudioRouteManagerImpl::SoundActiveDeviceChangedCallback(sound_device_in_e in, sound_device_out_e out, void* pUserData)
+{
+       result r = E_SUCCESS;
+       AudioRouteInfo audioRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
+
+       _AudioRouteManagerImpl* pAudioRouteImpl = (_AudioRouteManagerImpl *)pUserData;
+       SysTryReturn(NID_MEDIA, pAudioRouteImpl, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The value of pUserData is null.");
+
+       audioRouteInfo.SetInputAudioDevice(ConvertSoundIn2InputAudio((unsigned int)in));
+       audioRouteInfo.SetOutputAudioDevice(ConvertSoundOut2OutputAudio((unsigned int)out));
+
+       _AudioRouteEventArg* pRouteEventArg = new (std::nothrow) _AudioRouteEventArg;
+       SysTryReturn(NID_MEDIA, pRouteEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       pRouteEventArg->SetEventType(_AUDIO_ROUTE_EVENT_ACTIVE_CHANGED);
+       pRouteEventArg->SetAudioRouteInfo(audioRouteInfo);
+       r = pAudioRouteImpl->__pAudioRouteEvent->FireAsync(*pRouteEventArg);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s]FireAsync failed", GetErrorMessage(r));
+}
+
+result
+_AudioRouteManagerImpl::SetAudioRouteEventListener(IAudioRouteEventListener* pListener)
+{
+       result r = E_SUCCESS;
+       SysTryReturn(NID_MEDIA, __pAudioRouteEvent != null, E_INVALID_OPERATION, E_INVALID_OPERATION,
+               "[E_INVALID_OPERATION] A error has been occurred. The value of __pAudioRouteEvent is null.");
+       if (__pSingleAudioRouteListner != null)
+       {
+               r = __pAudioRouteEvent->RemoveListener(*__pSingleAudioRouteListner);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] RemoveListener() failed", GetErrorMessage(r));
+               __pSingleAudioRouteListner = null;
+       }
+       if (pListener != null)
+       {
+               __pSingleAudioRouteListner = pListener;
+               return __pAudioRouteEvent->AddListener(*pListener);
+       }
+       return r;
+}
+
+
+String
+_AudioRouteManagerImpl::GetActiveBluetoothA2dpName(void)
+{
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       result r = E_SUCCESS;
+       bool isConnected = false;
+       char* pBtName = null;
+       ret = sound_manager_get_a2dp_status(&isConnected, &pBtName);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Failed to perform sound_manager_get_a2dp_status operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       if (isConnected == true)
+       {
+               if (pBtName != null)
+               {
+                       String stBtName(pBtName);
+                       free(pBtName);
+                       return stBtName;
+               }
+       }
+       else
+       {
+               SetLastResult(E_INVALID_OPERATION);
+               return String("");
+       }
+CATCH:
+       return String("");
+}
+
+AudioStreamType
+_AudioRouteManagerImpl::GetActiveAudioStreamType(void)
+{
+       result r = E_SUCCESS;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       sound_type_e soundType = SOUND_TYPE_SYSTEM;
+       AudioStreamType audioStreamType = AUDIO_STREAM_TYPE_NO_SOUND;
+       ret = sound_manager_get_current_sound_type(&soundType);
+       SysTryCatch(NID_MEDIA, ret != SOUND_MANAGER_ERROR_NO_PLAYING_SOUND, , E_SYSTEM,
+                       "[E_SYSTEM] A system error has been occurred. Failed to perform sound_manager_get_current_sound_type operation with error code : 0x%x", ret);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Failed to perform sound_manager_get_a2dp_status operation with error code : 0x%x", GetErrorMessage(r), ret);
+
+       switch (soundType)
+       {
+       case SOUND_TYPE_SYSTEM:
+               audioStreamType = AUDIO_STREAM_TYPE_SYSTEM;
+               break;
+       case SOUND_TYPE_NOTIFICATION:
+               audioStreamType = AUDIO_STREAM_TYPE_NOTIFICATION;
+               break;
+       case SOUND_TYPE_ALARM:
+               audioStreamType = AUDIO_STREAM_TYPE_ALARM;
+               break;
+       case SOUND_TYPE_RINGTONE:
+               audioStreamType = AUDIO_STREAM_TYPE_RINGTONE;
+               break;
+       case SOUND_TYPE_MEDIA:
+               audioStreamType = AUDIO_STREAM_TYPE_MEDIA;
+               break;
+       case SOUND_TYPE_CALL:
+               audioStreamType = AUDIO_STREAM_TYPE_CALL;
+               break;
+       default:
+               audioStreamType = AUDIO_STREAM_TYPE_NO_SOUND;
+               break;
+       }
+CATCH:
+       return audioStreamType;
+}
+
+Tizen::Base::Collection::IList*
+_AudioRouteManagerImpl::GetAvailableAudioRouteListN()
+{
+       result r = E_SUCCESS;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       IList* pAudioDeviceList = null;
+       pAudioDeviceList = new (std::nothrow) ArrayList();
+       SysTryReturn(NID_MEDIA, pAudioDeviceList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       ret = sound_manager_foreach_available_route(SoundAvailableRouteCallback, pAudioDeviceList);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform sound_manager_call_session_destroy operation.", GetErrorMessage(r));
+       return pAudioDeviceList;
+CATCH:
+       pAudioDeviceList->RemoveAll();
+       delete pAudioDeviceList;
+       pAudioDeviceList = null;
+       return null;
+}
+
+bool
+_AudioRouteManagerImpl::IsAudioRouteAvailable(const AudioRouteInfo& device)
+{
+       unsigned int route = 0;
+       if (device.GetInputAudioDevice() == INPUT_AUDIO_DEVICE_NONE)
+       {
+               route = ConvertOutputAudio2SoundOut(device.GetOutputAudioDevice());
+       }
+       else if (device.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_NONE)
+       {
+               route = ConvertInputAudio2SoundIn(device.GetInputAudioDevice());
+       }
+       else
+       {
+               route = ConvertAudioDevice2Route(device);
+       }
+       if (route == 0)
+       {
+               SetLastResult(E_INVALID_ARG);
+               return false;
+       }
+
+       return sound_manager_is_route_available((sound_route_e)route);
+}
+
+result
+_AudioRouteManagerImpl::SetActiveAudioRoute(const AudioRouteInfo& device)
+{
+       result r = E_SUCCESS;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       unsigned int route = 0;
+       if (device.GetInputAudioDevice() == INPUT_AUDIO_DEVICE_NONE)
+       {
+               route = ConvertOutputAudio2SoundOut(device.GetOutputAudioDevice());
+       }
+       else if (device.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_NONE)
+       {
+               route = ConvertInputAudio2SoundIn(device.GetInputAudioDevice());
+       }
+       else
+       {
+               route = ConvertAudioDevice2Route(device);
+       }
+       SysTryReturn(NID_MEDIA, route != 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The value of device is wrong");
+       bool routeAvailable = sound_manager_is_route_available((sound_route_e)route);
+       SysTryReturn(NID_MEDIA, routeAvailable == true, E_INVALID_OPERATION, E_INVALID_OPERATION,
+               "[E_INVALID_OPERATION] Failed to perform sound_manager_is_route_available operation.");
+       ret = sound_manager_set_active_route((sound_route_e)route);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform sound_manager_set_active_route operation with error code : 0x%x", GetErrorMessage(r), ret);
+       return E_SUCCESS;
+}
+
+AudioRouteInfo
+_AudioRouteManagerImpl::GetActiveAudioRoute(void)
+{
+       result r = E_SUCCESS;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       sound_device_in_e in = SOUND_DEVICE_IN_MIC;
+       sound_device_out_e out = SOUND_DEVICE_OUT_SPEAKER;
+       ret = sound_manager_get_active_device(&in, &out);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, AudioRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE),
+                       r, "[%s] Failed to perform sound_manager_get_active_device operation with error code : 0x%x", GetErrorMessage(r), ret);
+       return AudioRouteInfo(ConvertSoundIn2InputAudio((unsigned int)in), ConvertSoundOut2OutputAudio((unsigned int)out));
+}
+
+InputAudioDevice
+_AudioRouteManagerImpl::ConvertSoundIn2InputAudio(unsigned int route)
+{
+       switch (route)
+       {
+       case SOUND_ROUTE_IN_MIC:
+               return INPUT_AUDIO_DEVICE_MIC;
+       case SOUND_ROUTE_IN_WIRED_ACCESSORY:
+               return INPUT_AUDIO_DEVICE_WIRED_ACCESSORY;
+       default:
+               return INPUT_AUDIO_DEVICE_NONE;
+       }
+}
+
+unsigned int
+_AudioRouteManagerImpl::ConvertInputAudio2SoundIn(InputAudioDevice input)
+{
+       switch (input)
+       {
+       case INPUT_AUDIO_DEVICE_MIC:
+               return SOUND_ROUTE_IN_MIC;
+       case INPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
+               return SOUND_ROUTE_IN_WIRED_ACCESSORY;
+       default:
+               return 0;
+       }
+}
+
+unsigned int
+_AudioRouteManagerImpl::ConvertOutputAudio2SoundOut(OutputAudioDevice output)
+{
+       switch (output)
+       {
+       case OUTPUT_AUDIO_DEVICE_SPEAKER:
+               return SOUND_ROUTE_OUT_SPEAKER;
+       case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
+               return SOUND_ROUTE_OUT_WIRED_ACCESSORY;
+       case OUTPUT_AUDIO_DEVICE_BT_A2DP:
+               return SOUND_ROUTE_OUT_BLUETOOTH;
+       default:
+               return 0;
+       }
+}
+
+unsigned int
+_AudioRouteManagerImpl::ConvertAudioDevice2Route(const AudioRouteInfo &device)
+{
+       InputAudioDevice in = device.GetInputAudioDevice();
+       OutputAudioDevice out = device.GetOutputAudioDevice();
+       if ((in == INPUT_AUDIO_DEVICE_MIC) && (out == OUTPUT_AUDIO_DEVICE_RECEIVER))
+       {
+               return SOUND_ROUTE_IN_MIC_OUT_RECEIVER;
+       }
+       if ((in == INPUT_AUDIO_DEVICE_MIC) && (out == OUTPUT_AUDIO_DEVICE_SPEAKER))
+       {
+               return SOUND_ROUTE_IN_MIC_OUT_SPEAKER;
+       }
+       if ((in == INPUT_AUDIO_DEVICE_MIC) && (out == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY))
+       {
+               return SOUND_ROUTE_IN_MIC_OUT_HEADPHONE;
+       }
+       if ((in == INPUT_AUDIO_DEVICE_WIRED_ACCESSORY) && (out == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY))
+       {
+               return SOUND_ROUTE_INOUT_HEADSET;
+       }
+       if ((in == INPUT_AUDIO_DEVICE_BT_SCO) && (out == OUTPUT_AUDIO_DEVICE_BT_SCO))
+       {
+               return SOUND_ROUTE_INOUT_BLUETOOTH;
+       }
+       return 0;
+}
+
+OutputAudioDevice
+_AudioRouteManagerImpl::ConvertSoundOut2OutputAudio(unsigned int route)
+{
+       switch (route)
+       {
+       case SOUND_ROUTE_OUT_SPEAKER:
+               return OUTPUT_AUDIO_DEVICE_SPEAKER;
+       case SOUND_ROUTE_OUT_WIRED_ACCESSORY:
+               return OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY;
+       case SOUND_ROUTE_OUT_BLUETOOTH:
+               return OUTPUT_AUDIO_DEVICE_BT_A2DP;
+       default:
+               return OUTPUT_AUDIO_DEVICE_NONE;
+       }
+}
+
+void
+_AudioRouteManagerImpl::ConvertRoute2AudioDevice(unsigned int route, AudioRouteInfo& audioRouteInfo)
+{
+       switch (route)
+       {
+       case SOUND_ROUTE_IN_MIC_OUT_RECEIVER:
+               audioRouteInfo.SetInputAudioDevice(INPUT_AUDIO_DEVICE_MIC);
+               audioRouteInfo.SetOutputAudioDevice(OUTPUT_AUDIO_DEVICE_RECEIVER);
+               break;
+       case SOUND_ROUTE_IN_MIC_OUT_SPEAKER:
+               audioRouteInfo.SetInputAudioDevice(INPUT_AUDIO_DEVICE_MIC);
+               audioRouteInfo.SetOutputAudioDevice(OUTPUT_AUDIO_DEVICE_SPEAKER);
+               break;
+       case SOUND_ROUTE_IN_MIC_OUT_HEADPHONE:
+               audioRouteInfo.SetInputAudioDevice(INPUT_AUDIO_DEVICE_MIC);
+               audioRouteInfo.SetOutputAudioDevice(OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY);
+               break;
+       case SOUND_ROUTE_INOUT_HEADSET:
+               audioRouteInfo.SetInputAudioDevice(INPUT_AUDIO_DEVICE_WIRED_ACCESSORY);
+               audioRouteInfo.SetOutputAudioDevice(OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY);
+               break;
+       case SOUND_ROUTE_INOUT_BLUETOOTH:
+               audioRouteInfo.SetInputAudioDevice(INPUT_AUDIO_DEVICE_BT_SCO);
+               audioRouteInfo.SetOutputAudioDevice(OUTPUT_AUDIO_DEVICE_BT_SCO);
+               break;
+       default:
+               break;
+       }
+}
+
+};
+};             //Tizen::Media
diff --git a/src/FMedia_AudioSessionEvent.cpp b/src/FMedia_AudioSessionEvent.cpp
new file mode 100644 (file)
index 0000000..02d55ef
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseRtThread.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include "FMedia_AudioSessionEvent.h"
+#include "FMedia_AudioSessionEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Media
+{
+
+_AudioSessionEvent::_AudioSessionEvent(void)
+       :__pListener(null)
+{
+}
+
+_AudioSessionEvent::~_AudioSessionEvent(void)
+{
+}
+
+result
+_AudioSessionEvent::Construct(void)
+{
+       result r = E_SUCCESS;
+       __pListener = null;
+
+       r = _Event::Initialize();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+
+void
+_AudioSessionEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       IAudioSessionEventListener *pAudioSessionEventListener = dynamic_cast<IAudioSessionEventListener*> (&listener);
+       SysTryReturn(NID_MEDIA, pAudioSessionEventListener, , E_SYSTEM, "[E_SYSTEM] A system error has been occureed. The value of listener is null.");
+
+       __pListener = pAudioSessionEventListener;
+
+       const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
+
+       _AudioSessionEventArg *pArg = (_AudioSessionEventArg*) pTempArg;
+
+       switch (pArg->GetEventType())
+       {
+       case _AUDIO_SESSION_EVENT_INTERRUPTED:
+               pAudioSessionEventListener->OnAudioSessionInterrupted();
+               break;
+       case _AUDIO_SESSION_EVENT_RELEASED:
+               pAudioSessionEventListener->OnAudioSessionInterruptReleased();
+               break;
+       case _AUDIO_SESSION_EVENT_AUDIO_FOCUS_CHANGED:
+               pAudioSessionEventListener->OnAudioSessionAudioFocusChanged();
+               break;
+       default:
+               SysTryLog(NID_MEDIA, false, "The event type is wrong.");
+               break;
+       }
+}
+};
+};
diff --git a/src/FMedia_AudioSessionEvent.h b/src/FMedia_AudioSessionEvent.h
new file mode 100644 (file)
index 0000000..2440d3f
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_AudioSessionEvent.h
+// @brief                      This header file contains the declaration related to AudioIn class
+//
+//
+
+
+#ifndef _FMEDIA_INTERNAL_AUDIO_SESSION_EVENT_H_
+#define _FMEDIA_INTERNAL_AUDIO_SESSION_EVENT_H_
+
+#include <FBaseRtThread.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaIAudioSessionEventListener.h>
+#include <FMediaAudioIn.h>
+#include "FBaseRt_Event.h"
+
+namespace Tizen { namespace Media
+{
+
+
+class _AudioSessionEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+public:
+       _AudioSessionEvent(void);
+       ~_AudioSessionEvent(void);
+       result Construct(void);
+
+protected:
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+private:
+       _AudioSessionEvent(const _AudioSessionEvent& rhs);
+       _AudioSessionEvent& operator =(const _AudioSessionEvent& rhs);
+       IAudioSessionEventListener* __pListener;
+};     // _AudioSessionEvent
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioSessionEventArg.cpp b/src/FMedia_AudioSessionEventArg.cpp
new file mode 100644 (file)
index 0000000..68a5cf1
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMedia_AudioSessionEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_AudioSessionEventTypeArg::_AudioSessionEventTypeArg(void)
+       : __audioSessionEventType(_AUDIO_SESSION_EVENT_NONE)
+{
+
+}
+
+_AudioSessionEventTypeArg::~_AudioSessionEventTypeArg(void)
+{
+
+}
+
+void
+_AudioSessionEventTypeArg::SetEventType(_AudioSessionEventType eType)
+{
+       __audioSessionEventType = eType;
+}
+
+_AudioSessionEventType
+_AudioSessionEventTypeArg::GetEventType(void) const
+{
+       return __audioSessionEventType;
+}
+
+_AudioSessionEventArg::_AudioSessionEventArg(void)
+{
+
+}
+
+_AudioSessionEventArg::~_AudioSessionEventArg(void)
+{
+
+}
+
+};
+};   // Tizen::Media
diff --git a/src/FMedia_AudioSessionEventArg.h b/src/FMedia_AudioSessionEventArg.h
new file mode 100644 (file)
index 0000000..8e1947e
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_AudioSessionEventArg.h
+// @brief                      This header file contains the declaration related to _AudioSessionImpl class.
+//
+//
+
+
+#ifndef _FMEDIA_INTERNAL_AUDIO_SESSSION_EVENT_ARG_H_
+#define _FMEDIA_INTERNAL_AUDIO_SESSSION_EVENT_ARG_H_
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaAudioManagerTypes.h>
+
+namespace Tizen {namespace Media
+{
+
+enum _AudioSessionEventType
+{
+       _AUDIO_SESSION_EVENT_NONE,
+       _AUDIO_SESSION_EVENT_INTERRUPTED,
+       _AUDIO_SESSION_EVENT_RELEASED,
+       _AUDIO_SESSION_EVENT_AUDIO_FOCUS_CHANGED
+};
+
+class _AudioSessionImpl;
+
+class _AudioSessionEventTypeArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+       _AudioSessionEventTypeArg(void);
+       virtual ~_AudioSessionEventTypeArg(void);
+       _AudioSessionEventType GetEventType(void) const;
+private:
+       void SetEventType(_AudioSessionEventType eType);
+       _AudioSessionEventTypeArg(const _AudioSessionEventTypeArg& rhs);
+       _AudioSessionEventTypeArg& operator =(const _AudioSessionEventTypeArg& rhs);
+       _AudioSessionEventType __audioSessionEventType;
+       friend class _AudioSessionManagerImpl;
+};     //_AudioSessionEventTypeArg
+
+class _AudioSessionEventArg
+       : public _AudioSessionEventTypeArg
+{
+public:
+       _AudioSessionEventArg(void);
+       ~_AudioSessionEventArg(void);
+private:
+       friend class _AudioSessionManagerImpl;
+};     //_AudioSessionEventArg
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_AudioSessionManagerImpl.cpp b/src/FMedia_AudioSessionManagerImpl.cpp
new file mode 100644 (file)
index 0000000..a0e7f94
--- /dev/null
@@ -0,0 +1,234 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <iostream>
+#include <pthread.h>
+#include <FBaseSysLog.h>
+#include <FMediaIAudioSessionEventListener.h>
+#include "FMedia_AudioSessionManagerImpl.h"
+#include "FMedia_AudioManagerConvert.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+namespace Tizen{ namespace Media{
+
+_AudioSessionManagerImpl* _AudioSessionManagerImpl::__pAudioSessionImpl = null;
+
+void
+_AudioSessionManagerImpl::InitAudioSessionManagerImpl(void)
+{
+       static _AudioSessionManagerImpl instance;
+       __pAudioSessionImpl = &instance;
+}
+
+_AudioSessionManagerImpl*
+_AudioSessionManagerImpl::GetInstance()
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (__pAudioSessionImpl == null)
+       {
+               pthread_once(&onceBlock, InitAudioSessionManagerImpl);
+               r = __pAudioSessionImpl->Construct();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, ,r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return __pAudioSessionImpl;
+CATCH:
+       __pAudioSessionImpl = null;
+       return null;
+}
+
+result
+_AudioSessionManagerImpl::Construct(void)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+
+       __pAudioSessionEvent.reset(new (std::nothrow) _AudioSessionEvent);
+       SysTryCatch(NID_MEDIA, __pAudioSessionEvent.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = __pAudioSessionEvent->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ret = sound_manager_set_interrupted_cb(SoundSessionNotificationsCallback, (void*)this);
+       SysTryCatch(NID_MEDIA, ret == SOUND_MANAGER_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+               "[E_SYSTEM] A system error has been occurred. Failed to perform sound_manager_set_interrupted_cb operation with error code : 0x%x", ret);
+       return r;
+CATCH:
+       return r;
+}
+
+_AudioSessionManagerImpl::_AudioSessionManagerImpl()
+       : __pSingleAudioSessionListner(null)
+       , __currentSessionMode(AUDIO_SESSION_MODE_SHARED)
+       , __interruptedEvent(SOUND_INTERRUPTED_BY_MEDIA)
+       , __interruptFlag(false)
+{
+
+}
+
+_AudioSessionManagerImpl::~_AudioSessionManagerImpl()
+{
+       sound_manager_unset_interrupted_cb();
+       __pSingleAudioSessionListner = null;
+       __pAudioSessionImpl = null;
+}
+
+result
+_AudioSessionManagerImpl::AddListener(IAudioSessionEventListener *pListener)
+{
+       SysTryReturn(NID_MEDIA, pListener != null, E_INVALID_ARG, E_INVALID_ARG,
+               "[E_INVALID_ARG] Invalid argument is used. The value of pListener is null.");
+       return __pAudioSessionEvent->AddListener(*pListener);
+}
+
+result
+_AudioSessionManagerImpl::SetAudioSessionEventListener(IAudioSessionEventListener* pListener)
+{
+       result r = E_SUCCESS;
+       SysTryReturn(NID_MEDIA, __pAudioSessionEvent.get() != null, E_INVALID_OPERATION, E_INVALID_OPERATION,
+               "[E_INVALID_OPERATION] A error has been occurred. The value of __pAudioSessionEvent is null.");
+       if (__pSingleAudioSessionListner != null)
+       {
+               r = __pAudioSessionEvent->RemoveListener(*__pSingleAudioSessionListner);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] RemoveListener() failed", GetErrorMessage(r));
+               __pSingleAudioSessionListner = null;
+       }
+       if (pListener != null)
+       {
+               r = __pAudioSessionEvent->AddListener(*pListener);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] AddListener() failed", GetErrorMessage(r));
+               __pSingleAudioSessionListner = pListener;
+       }
+       return r;
+}
+
+result
+_AudioSessionManagerImpl::RemoveListener(IAudioSessionEventListener *pListener)
+{
+       return __pAudioSessionEvent->RemoveListener(*pListener);
+}
+
+
+result
+_AudioSessionManagerImpl::SetMode(AudioSessionMode sessionMode)
+{
+       result r = E_SUCCESS;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       ret = sound_manager_set_session_type(_AudioManagerConvert::ConvertAudioSession2SoundSession(sessionMode));
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryReturnResult(NID_MEDIA, r == E_SUCCESS, r,
+               "Failed to perform sound_manager_set_session_type operation with error code : 0x%x", ret);
+       __currentSessionMode = sessionMode;
+       return r;
+
+}
+
+AudioSessionMode
+_AudioSessionManagerImpl::GetMode(void)
+{
+       result r = E_SUCCESS;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       sound_session_type_e soundSession = SOUND_SESSION_TYPE_SHARE;
+       ret = sound_manager_get_session_type(&soundSession);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, ,r, "[%s] Propagating.", GetErrorMessage(r));
+       return _AudioManagerConvert::ConvertSoundSession2AudioSession(soundSession);
+CATCH:
+       //return default session type
+       return AUDIO_SESSION_MODE_SHARED;
+}
+
+sound_interrupted_code_e
+_AudioSessionManagerImpl::GetInterruptType(void)
+{
+       return __interruptedEvent;
+}
+
+void
+_AudioSessionManagerImpl::SoundSessionNotificationsCallback(sound_interrupted_code_e notify, void* pUserData)
+{
+       SysLog(NID_MEDIA, "This instance received message code : %d", notify);
+       _AudioSessionManagerImpl *pAudioSessionManagerImpl = (_AudioSessionManagerImpl *)pUserData;
+
+       switch (notify)
+       {
+       case SOUND_INTERRUPTED_COMPLETED:
+               if (!(pAudioSessionManagerImpl->__interruptFlag))
+               {
+                       __pAudioSessionImpl->SendReleased();
+               }
+               pAudioSessionManagerImpl->__interruptFlag = false;
+               break;
+       case SOUND_INTERRUPTED_BY_CALL:
+               pAudioSessionManagerImpl->__interruptFlag = true;
+               //fall through
+       case SOUND_INTERRUPTED_BY_MEDIA:
+               //fall through
+       case SOUND_INTERRUPTED_BY_RESOURCE_CONFLICT:
+               //fall through
+       case SOUND_INTERRUPTED_BY_EARJACK_UNPLUG:
+               __pAudioSessionImpl->SendAudioFocusChanged(notify);
+               break;
+       case SOUND_INTERRUPTED_BY_EMERGENCY:
+               //fall through
+       case SOUND_INTERRUPTED_BY_ALARM:
+               __pAudioSessionImpl->SendInterrupted(notify);
+               break;
+       default:
+               SysLogException(NID_MEDIA, E_SYSTEM, "A system error occurred. Invalid notify signal is %d",notify);
+               break;
+       }
+}
+
+void
+_AudioSessionManagerImpl::SendInterrupted(sound_interrupted_code_e notify)
+{
+       result r = E_SUCCESS;
+       _AudioSessionEventArg* pAudioSessionEventArg = new (std::nothrow) _AudioSessionEventArg;
+       SysTryReturn(NID_MEDIA, pAudioSessionEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       pAudioSessionEventArg->SetEventType(_AUDIO_SESSION_EVENT_INTERRUPTED);
+       __interruptedEvent = notify;
+       r = __pAudioSessionEvent->FireAsync(*pAudioSessionEventArg);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform FireAsync operation.", GetErrorMessage(r));
+}
+
+void
+_AudioSessionManagerImpl::SendAudioFocusChanged(sound_interrupted_code_e notify)
+{
+       result r = E_SUCCESS;
+       _AudioSessionEventArg* pAudioSessionEventArg = new (std::nothrow) _AudioSessionEventArg;
+       SysTryReturn(NID_MEDIA, pAudioSessionEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       pAudioSessionEventArg->SetEventType(_AUDIO_SESSION_EVENT_AUDIO_FOCUS_CHANGED);
+       __interruptedEvent = notify;
+       r = __pAudioSessionEvent->FireAsync(*pAudioSessionEventArg);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s]Failed to perform FireAsync operation.", GetErrorMessage(r));
+}
+
+void
+_AudioSessionManagerImpl::SendReleased()
+{
+       result r = E_SUCCESS;
+       _AudioSessionEventArg* pAudioSessionEventArg = new (std::nothrow) _AudioSessionEventArg;
+       SysTryReturn(NID_MEDIA, pAudioSessionEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       pAudioSessionEventArg->SetEventType(_AUDIO_SESSION_EVENT_RELEASED);
+       r = __pAudioSessionEvent->FireAsync(*pAudioSessionEventArg);
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Failed to perform FireAsync operation.", GetErrorMessage(r));
+}
+
+}
+}
diff --git a/src/FMedia_AudioStreamInfoImpl.cpp b/src/FMedia_AudioStreamInfoImpl.cpp
new file mode 100644 (file)
index 0000000..9f66964
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                FMedia__AudioStreamInfoImplImpl.cpp
+* @brief               This file contains the implementation of subsystem's Player.
+*/
+
+#include "FMedia_AudioStreamInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+_AudioStreamInfoImpl::_AudioStreamInfoImpl(CodecType codecType, int bitrate, int sampleRate, AudioChannelType channel)
+{
+       __codecType = codecType;
+       __bitrate = bitrate;
+       __sampleRate = sampleRate;
+       __channel = channel;
+}
+
+_AudioStreamInfoImpl::~_AudioStreamInfoImpl()
+{
+
+}
+
+_AudioStreamInfoImpl::_AudioStreamInfoImpl(const _AudioStreamInfoImpl& rhs)
+{
+       __codecType = rhs.__codecType;
+       __bitrate = rhs.__bitrate;
+       __sampleRate = rhs.__sampleRate;
+       __channel = rhs.__channel;
+}
+
+_AudioStreamInfoImpl&
+_AudioStreamInfoImpl::operator =(const _AudioStreamInfoImpl& rhs)
+{
+       // check for self-assignment
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __codecType = rhs.__codecType;
+       __bitrate = rhs.__bitrate;
+       __sampleRate = rhs.__sampleRate;
+       __channel = rhs.__channel;
+
+       return *this;
+
+}
+
+bool
+_AudioStreamInfoImpl::Equals(const Object& obj) const
+{
+       const _AudioStreamInfoImpl* pAudioStreamInfoImpl = dynamic_cast <const _AudioStreamInfoImpl *> (&obj);
+       if (!pAudioStreamInfoImpl)
+       {
+               return false;
+       }
+       return (((__codecType == pAudioStreamInfoImpl->__codecType) && (__bitrate == pAudioStreamInfoImpl->__bitrate)
+               && (__sampleRate == pAudioStreamInfoImpl->__sampleRate) && (__channel == pAudioStreamInfoImpl->__channel )) ? true : false);
+}
+
+int
+_AudioStreamInfoImpl::GetHashCode(void) const
+{
+       return static_cast<int>(((__bitrate ^ __codecType) + (__sampleRate ^ __channel )));
+}
+
+CodecType
+_AudioStreamInfoImpl::GetCodecType() const
+{
+       return __codecType;
+}
+
+int
+_AudioStreamInfoImpl::GetBitRate() const
+{
+       return __bitrate;
+}
+
+int
+_AudioStreamInfoImpl::GetSampleRate() const
+{
+       return __sampleRate;
+}
+
+AudioChannelType
+_AudioStreamInfoImpl::GetChannelType() const
+{
+       return __channel;
+}
+
+};
+};
diff --git a/src/FMedia_AudioStreamInfoImpl.h b/src/FMedia_AudioStreamInfoImpl.h
new file mode 100644 (file)
index 0000000..bd1f164
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaAudioStreamInfoImpl.h
+ * @brief                      This is the header file for the %AudioStreamInfoImpl class.
+ *
+ * This header file contains the declarations of the %AudioStreamInfoImpl class.
+ */
+
+#ifndef _FMEDIA_INTERNAL_AUDIOSTREAMINFO_IMPL_H_
+#define _FMEDIA_INTERNAL_AUDIOSTREAMINFO_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+class AudioStreamInfo;
+//
+// @class     AudioStreamInfoImpl
+// @brief     This class provides the methods to get audio stream information.
+//
+// This class provides the methods to get audio stream information, such as codec type, bit rate, sample rate, and channel count.
+//
+
+class _AudioStreamInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       //
+       // This is the destructor for this class.
+       //
+       //
+       virtual ~_AudioStreamInfoImpl(void);
+
+public:
+       //
+       //      Gets the encoding type of an audio stream.
+       //
+       //      @return         The value of the encoding type
+       //
+       //
+       CodecType GetCodecType(void) const;
+
+       //
+       //      Gets the bit rate of an audio.
+       //
+       //      @return             The audio bit rate in bits per second (bps)
+       //
+       int GetBitRate(void) const;
+
+       //
+       //      Gets the sampling rate of an audio.
+       //
+       //      @return             The audio sampling rate in hertz (Hz)
+       //
+       int GetSampleRate(void) const;
+
+       //
+       //      Gets the audio channel of an audio.
+       //
+       //      @return             The audio channel type
+       //
+       AudioChannelType GetChannelType(void) const;
+
+       //
+       // @see @ref Tizen::Media::AudioStreamInfo::Equals()
+       //
+       virtual bool Equals(const Object& obj) const;
+
+       //
+       // @see @ref Tizen::Media::AudioStreamInfo::GetHashCode()
+       //
+       virtual int GetHashCode(void) const;
+
+private:
+       //
+       // Initializes this instance of AudioStreamInfo with the specified parameters.
+       //
+       // @param [in]  codecType       The value of encoding type @n
+       // @param [in]  bitrate         The audio bit rate in bits per second (bps) @n
+       // @param [in]  sampleRate      The audio sample rate in hertz (Hz) @n
+       // @param [in]  channel         The audio channel type @n
+       //
+       _AudioStreamInfoImpl(CodecType codecType, int bitrate, int sampleRate, AudioChannelType channel);
+
+
+       _AudioStreamInfoImpl(const _AudioStreamInfoImpl& rhs);
+       _AudioStreamInfoImpl& operator =(const _AudioStreamInfoImpl& rhs);
+
+private:
+       CodecType __codecType;
+       int __bitrate;
+       int __sampleRate;
+       AudioChannelType __channel;
+       friend class AudioStreamInfo;
+};
+
+}}//Tizen::Media
+#endif
diff --git a/src/FMedia_BitWriter.cpp b/src/FMedia_BitWriter.cpp
new file mode 100644 (file)
index 0000000..a49242b
--- /dev/null
@@ -0,0 +1,151 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseObject.h>
+#include <FMedia_BitWriter.h>
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+static const unsigned char _LOG_2_TAB[256] = {
+       0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
+       5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+       6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+       7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+       7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+       7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+       7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+       8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
+};
+
+
+_BitWriter::_BitWriter(unsigned char* dest, int size)
+{
+       __num = 0;
+       __curr = 0;
+       __mask = 0x80;
+
+       __pBuf = dest;
+       __size = size;
+       __pos = 0;
+}
+
+_BitWriter::~_BitWriter(void)
+{
+
+}
+
+int
+_BitWriter::GetPosition(void)
+{
+       return __pos;
+}
+
+void
+_BitWriter::AlignByte(void)
+{
+       if (__mask != 0x80)
+       {
+               ++__num;
+               WriteByte(__curr);
+               __curr = 0;
+               __mask = 0x80;
+       }
+}
+
+void
+_BitWriter::PutBits(int count, unsigned long bits)
+{
+       while (count > 0)
+       {
+               PutBit((bool)((bits >> (count-1)) & 0x01));
+               count--;
+       }
+}
+
+void
+_BitWriter::PutBit(bool bit)
+{
+       if (bit)
+       {
+               __curr |= __mask;
+       }
+       __mask >>= 1;
+       if (__mask == 0)
+       {
+               ++__num;
+               WriteByte(__curr);
+               __curr = 0;
+               __mask = 0x80;
+       }
+}
+
+void
+_BitWriter::PutByte(unsigned char v)
+{
+       ++__num;
+       if (__mask == 0x80)
+       {
+               WriteByte(v);
+               return;
+       }
+
+       unsigned char ml = _LOG_2_TAB[__mask];
+       __curr |= v >> (8 - ml);
+       WriteByte(__curr);
+       __curr = v << ml;
+}
+
+void
+_BitWriter::PutWord(unsigned short v)
+{
+       PutByte((v >> 8) & 0x00ff);
+       PutByte((v     ) & 0x00ff);
+}
+
+void
+_BitWriter::PutDword(unsigned long v)
+{
+       PutByte((unsigned char) ((v >> 24) & 0x00ff));
+       PutByte((unsigned char) ((v >> 16) & 0x00ff));
+       PutByte((unsigned char) ((v >> 8 ) & 0x00ff));
+       PutByte((unsigned char) ((v      ) & 0x00ff));
+}
+
+void
+_BitWriter::WriteByte(unsigned char v)
+{
+       if (__pos >= __size)
+       {
+               return ;
+       }
+
+       __pBuf[__pos] = v;
+       __pos++;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_BitWriter.h b/src/FMedia_BitWriter.h
new file mode 100644 (file)
index 0000000..c7c2e29
--- /dev/null
@@ -0,0 +1,65 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *     @file   FMedia_BitWriter.h
+ *     @brief  This is the header file for the Tizen::Media::_BitWriter.
+ *
+ *     This header file contains the declarations of the Tizen::Media::_BitWriter.
+ */
+
+#ifndef FMEDIA_INTERNAL_BITWRITER_H_
+#define FMEDIA_INTERNAL_BITWRITER_H_
+
+namespace Tizen { namespace Media
+{
+
+class _BitWriter :
+       public Tizen::Base::Object
+{
+public:
+       _BitWriter(unsigned char* dest, int size);
+
+       virtual ~_BitWriter(void);
+
+       int GetPosition(void);
+
+       void AlignByte(void);
+
+       void PutBits(int count, unsigned long bits);
+
+       void PutBit(bool bit);
+
+       void PutByte(unsigned char v);
+
+       void PutWord(unsigned short v);
+
+       void PutDword(unsigned long v);
+
+protected:
+       void WriteByte(unsigned char v);
+private:
+       int __num;
+       unsigned char __curr;
+       unsigned char __mask;
+       unsigned char *__pBuf;
+       int __size;
+       int __pos;
+};
+
+}} // Tizen::Media
+#endif // FMEDIA_INTERNAL_BITWRITER_H_
diff --git a/src/FMedia_CamPtrUtil.h b/src/FMedia_CamPtrUtil.h
new file mode 100755 (executable)
index 0000000..0fc6b64
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CamPtrUtil.h
+ * @brief              This header file contains the declarations of the pointer utility fuctions for the camera and recorder.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAM_PTR_UTIL_H_
+#define _FMEDIA_INTERNAL_CAM_PTR_UTIL_H_
+
+#include <camera.h>
+#include <FBaseColIList.h>
+#include <FBaseColIListT.h>
+#include <FGrpPixelFormat.h>
+#include <FMediaTypes.h>
+#include "FMedia_CameraTypes.h"
+
+namespace Tizen { namespace Media
+{
+
+/**
+* @class       _ListPtrUtil
+* @brief       This class is utility for list pointer handling.
+*
+*/
+class _ListPtrUtil
+{
+public:
+       struct Remover
+       {
+               void operator() (Tizen::Base::Collection::IListT<camera_pixel_format_e>* pList) const
+               {
+                       if (pList != null)
+                       {
+                               pList->RemoveAll();
+                               delete pList;
+                       }
+               }
+
+               void operator() (Tizen::Base::Collection::IList* pList) const
+               {
+                       if (pList != null)
+                       {
+                               pList->RemoveAll(true);
+                               delete pList;
+                       }
+               }
+
+               void operator() (Tizen::Base::Collection::IListT<int>* pList) const
+               {
+                       if (pList != null)
+                       {
+                               pList->RemoveAll();
+                               delete pList;
+                       }
+               }
+
+               void operator() (Tizen::Base::Collection::IListT<Tizen::Graphics::PixelFormat>* pList) const
+               {
+                       if (pList != null)
+                       {
+                               pList->RemoveAll();
+                               delete pList;
+                       }
+               }
+
+               void operator() (Tizen::Base::Collection::IListT<CodecType>* pList) const
+               {
+                       if (pList != null)
+                       {
+                               pList->RemoveAll();
+                               delete pList;
+                       }
+               }
+
+               void operator() (Tizen::Base::Collection::IListT<MediaContainerType>* pList) const
+               {
+                       if (pList != null)
+                       {
+                               pList->RemoveAll();
+                               delete pList;
+                       }
+               }
+
+               void operator() (Tizen::Base::Collection::IListT<_CameraDeviceType>* pList) const
+               {
+                       if (pList != null)
+                       {
+                               pList->RemoveAll();
+                               delete pList;
+                       }
+               }
+       };
+
+       static Remover remover;
+
+private:
+       _ListPtrUtil(void);
+       ~_ListPtrUtil(void);
+
+       _ListPtrUtil(const _ListPtrUtil& rhs);
+       _ListPtrUtil& operator =(const _ListPtrUtil& rhs);
+};
+
+}}
+#endif
diff --git a/src/FMedia_CameraBuffer.cpp b/src/FMedia_CameraBuffer.cpp
new file mode 100755 (executable)
index 0000000..b283375
--- /dev/null
@@ -0,0 +1,147 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraBuffer.cpp
+ * @brief                      This file contains the implementation of the %_CameraBuffer class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include "FMedia_CameraBuffer.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media
+{
+
+_CameraBuffer::_CameraBuffer(void)
+       : __bufferType(_CAMERA_BUFFER_NONE)
+       , __pixelFormat(MEDIA_PIXEL_FORMAT_NONE)
+       , __width(0)
+       , __height(0)
+       , __codec(CODEC_NONE)
+       , __hasHeader(false)
+{
+}
+
+_CameraBuffer::~_CameraBuffer(void)
+{
+}
+
+result
+_CameraBuffer::Construct(int capacity, _CameraBufferType bufferType, MediaPixelFormat pixelFormat, int width, int height)
+{
+       result r = E_SUCCESS;
+//     SysLog(NID_MEDIA, "Enter. capacity:%d, bufferType:%d, pixelFormat:%d, width:%d, height:%d", capacity, bufferType, pixelFormat, width, height);
+       SysTryReturn(NID_MEDIA, capacity>0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The capacity[%d] is invalid.", capacity);
+       SysTryReturn(NID_MEDIA, bufferType >= _CAMERA_BUFFER_PREVIEW && bufferType <= _CAMERA_BUFFER_CAPTURE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The bufferType(%d)  is invalid.", bufferType);
+       SysTryReturn(NID_MEDIA, pixelFormat >= MEDIA_PIXEL_FORMAT_NONE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The pixelFormat(%d)  is invalid.", pixelFormat);
+
+       r = ByteBuffer::Construct(capacity);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __bufferType = bufferType;
+       __pixelFormat = pixelFormat;
+       __width = width;
+       __height = height;
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CameraBuffer::Construct(int capacity, _CameraBufferType bufferType, CodecType codec, bool hasHeader, int width, int height)
+{
+       result r = E_SUCCESS;
+//     SysLog(NID_MEDIA, "Capacity:%d, bufferType:%d, codec:0x%x, width:%d, height:%d", capacity, bufferType, codec, width, height);
+       SysTryReturn(NID_MEDIA, capacity>0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The capacity[%d] is invalid.", capacity);
+       SysTryReturn(NID_MEDIA, bufferType >= _CAMERA_BUFFER_PREVIEW && bufferType <= _CAMERA_BUFFER_CAPTURE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The bufferType(%d)  is invalid.", bufferType);
+       SysTryReturn(NID_MEDIA, codec >= CODEC_NONE && codec < CODEC_MAX
+               , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The codec(0x%x)        is invalid.", codec);
+
+       r = ByteBuffer::Construct(capacity);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __bufferType = bufferType;
+       __width = width;
+       __height = height;
+       __codec = codec;
+       __hasHeader = hasHeader;
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CameraBuffer::Construct(const _CameraBuffer& cameraBuffer)
+{
+       result r = E_SUCCESS;
+//     SysLog(NID_MEDIA, "BufferType:%d, pixelFormat:%d", cameraBuffer.__bufferType, cameraBuffer.__pixelFormat);
+
+       r = ByteBuffer::Construct(cameraBuffer);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __bufferType = cameraBuffer.__bufferType;
+       __pixelFormat = cameraBuffer.__pixelFormat;
+       __width = cameraBuffer.__width;
+       __height = cameraBuffer.__height;
+       __codec = cameraBuffer.__codec;
+       __hasHeader = cameraBuffer.__hasHeader;
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+MediaPixelFormat
+_CameraBuffer::GetPixelFormat(void) const
+{
+       return __pixelFormat;
+}
+
+_CameraBufferType
+_CameraBuffer::GetBufferType(void) const
+{
+       return __bufferType;
+}
+
+int
+_CameraBuffer::GetWidth(void) const
+{
+       return __width;
+}
+
+int
+_CameraBuffer::GetHeight(void) const
+{
+       return __height;
+}
+
+CodecType
+_CameraBuffer::GetCodecType(void) const
+{
+       return __codec;
+}
+
+}}   // Tizen::Media
diff --git a/src/FMedia_CameraBuffer.h b/src/FMedia_CameraBuffer.h
new file mode 100755 (executable)
index 0000000..52ce9f3
--- /dev/null
@@ -0,0 +1,165 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraImpl.h
+ * @brief                      This header file contains the declarations of the %_CameraImpl class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_BUFFER_H_
+#define _FMEDIA_INTERNAL_CAMERA_BUFFER_H_
+
+#include <FBaseByteBuffer.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @enum _CameraBufferType
+ * Defines the buffer type of the camera.
+ */
+enum _CameraBufferType
+{
+       _CAMERA_BUFFER_NONE,
+       _CAMERA_BUFFER_PREVIEW,
+       _CAMERA_BUFFER_CAPTURE,
+};
+
+/**
+ * @class      _CameraBuffer
+ * @brief      This class implements the APIs of %_CameraBuffer class.
+ */
+class _CameraBuffer
+       : public Tizen::Base::ByteBuffer
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
+        * initialize this instance.
+        * @see                 Construct()
+        */
+       _CameraBuffer(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread
+        * where the Construct() method is called.
+        *
+        * @see                 Construct()
+        */
+       virtual ~_CameraBuffer(void);
+
+       /**
+       * Initializes this instance of camera buffer with the specified parameters. @n
+       * This method creates an instance of camera buffer in the subsystem. Only one instance is created at a given time.
+       *
+       * @return               An error code
+       * @param[in]    capacity                                The capacity of the buffer
+       * @param[in]    bufferType                              The buffer type
+       * @param[in]    pixelFormat                             The pixel format
+       * @param[in]    width                                   The width of the buffer data
+       * @param[in]    height                                  The height of the buffer data
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_INVALID_ARG                   A specified input parameter is invalid.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       */
+       result Construct(int capacity, _CameraBufferType bufferType, MediaPixelFormat pixelFormat, int width, int height);
+
+       /**
+       * Initializes this instance of camera buffer with the specified parameters. @n
+       * This method creates an instance of camera buffer in the subsystem. Only one instance is created at a given time.
+       *
+       * @return               An error code
+       * @param[in]    capacity                                The capacity of the buffer
+       * @param[in]    bufferType                              The buffer type
+       * @param[in]    codec                                   The encoded type of the buffer
+       * @param[in]    hasHeader                               The flag determining the buffer has header
+       * @param[in]    width                                   The width of the buffer data
+       * @param[in]    height                                  The height of the buffer data
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_INVALID_ARG                   A specified input parameter is invalid.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       */
+       result Construct(int capacity, _CameraBufferType bufferType, CodecType codec, bool hasHeader, int width, int height);
+
+       /**
+        * Initializes this instance of %_CameraBuffer which is a view of the specified _CameraBuffer. @n
+        * This is the copy constructor for the %_CameraBuffer class.
+        *
+        * @param[in]   cameraBuffer          The %_CameraBuffer instance used to initialize new object
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_ARG     A specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+        */
+       result Construct(const _CameraBuffer& cameraBuffer);
+
+       /**
+       * Gets the pixel format of the buffer.
+       *
+       * @return               The buffer's pixel format
+       */
+       MediaPixelFormat GetPixelFormat(void) const;
+
+       /**
+       * Gets the type of the buffer.
+       *
+       * @return               The buffer type
+       */
+       _CameraBufferType GetBufferType(void) const;
+
+       /**
+       * Gets the width of the buffer.
+       *
+       * @return               The width
+       */
+       int GetWidth(void) const;
+
+       /**
+       * Gets the height of the buffer.
+       *
+       * @return               The height
+       */
+       int GetHeight(void) const;
+
+       /**
+       * Gets the encoded codec type of the buffer.
+       *
+       * @return               The buffer's encoded codec type
+       */
+       CodecType GetCodecType(void) const;
+
+private:
+       _CameraBuffer(const _CameraBuffer& cameraBuffer);
+       _CameraBuffer& operator =(const _CameraBuffer& cameraBuffer);
+
+       _CameraBufferType __bufferType;
+       MediaPixelFormat __pixelFormat;
+       int __width;
+       int __height;
+       CodecType __codec;
+       bool __hasHeader;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_CameraCapability.cpp b/src/FMedia_CameraCapability.cpp
new file mode 100755 (executable)
index 0000000..37f366b
--- /dev/null
@@ -0,0 +1,1945 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMedia_CameraCapability.cpp
+ * @brief              This file contains the implementation of camera/recorder capability header file FMedia_CameraCapability.h
+ */
+
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBaseColArrayList.h>
+#include "FMedia_CameraCoordinator.h"
+#include "FMedia_CameraCapability.h"
+#include "FMedia_CameraCapabilitySession.h"
+#include "FMedia_CameraUtil.h"
+#include "FMedia_CamPtrUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media
+{
+
+_CameraCapabilitySafeHashMapT* _CameraCapability::__pMap = null;
+
+_CameraCapabilitySafeHashMapT::_CameraCapabilitySafeHashMapT(void)
+{
+}
+
+_CameraCapabilitySafeHashMapT::~_CameraCapabilitySafeHashMapT(void)
+{
+       RemoveItems();
+       _CameraCapability::__pMap = null;
+}
+
+void
+_CameraCapabilitySafeHashMapT::RemoveItems(void)
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr<IListT<_CameraDeviceType>, _ListPtrUtil::Remover> pList (GetKeysN(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pList.get() != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
+
+       for (int i = 0; i < GetCount(); i++)
+       {
+               _CameraDeviceType deviceType = _CAMERA_DEVICE_NONE;
+               r = pList->GetAt(i, deviceType);
+               if (IsFailed(r) && deviceType == _CAMERA_DEVICE_NONE)
+               {
+                       continue;
+               }
+
+               _CameraCapability* pCapability = null;
+               r = GetValue(deviceType, pCapability);
+               if (IsFailed(r) && pCapability == null)
+               {
+                       continue;
+               }
+               delete pCapability;
+       }
+       RemoveAll();
+}
+
+const _CameraCapability::keyServiceMap _CameraCapability::__SERVICE_MAP[] =
+{
+       {
+               _COP_NONE, _CAMERA_DEVICE_PRIMARY, null
+       },
+       {
+               _COP_PRIMARY_CAPTURE_FORMAT, _CAMERA_DEVICE_PRIMARY, GetSupportedCaptureFormatN
+       },
+       {
+               _COP_PRIMARY_CAPTURE_RESOLUTION, _CAMERA_DEVICE_PRIMARY, GetSupportedCaptureResolutionN
+       },
+       {
+               _COP_PRIMARY_DIRECTION, _CAMERA_DEVICE_PRIMARY, GetDirectionN
+       },
+       {
+               _COP_PRIMARY_EFFECT, _CAMERA_DEVICE_PRIMARY, GetSupportedEffectTypeN
+       },
+       {
+               _COP_PRIMARY_ISO_LEVEL, _CAMERA_DEVICE_PRIMARY, GetSupportedIsoLevelN
+       },
+       {
+               _COP_PRIMARY_PREVIEW_FORMAT, _CAMERA_DEVICE_PRIMARY, GetSupportedPreviewFormatN
+       },
+       {
+               _COP_PRIMARY_PREVIEW_FRAMERATE, _CAMERA_DEVICE_PRIMARY, GetSupportedPreviewFrameRateN
+       },
+       {
+               _COP_PRIMARY_PREVIEW_RESOLUTION, _CAMERA_DEVICE_PRIMARY, GetSupportedPreviewResolutionN
+       },
+       {
+               _COP_PRIMARY_RECORDING_RESOLUTION, _CAMERA_DEVICE_PRIMARY, GetSupportedRecordingResolutionN
+       },
+       {
+               _COP_PRIMARY_ROTATION, _CAMERA_DEVICE_PRIMARY, GetPhysicalRotationN
+       },
+       {
+               _COP_PRIMARY_BRIGHTNESS, _CAMERA_DEVICE_PRIMARY, GetSupportedBrightnessN
+       },
+       {
+               _COP_PRIMARY_CONTRAST, _CAMERA_DEVICE_PRIMARY, GetSupportedContrastN
+       },
+       {
+               _COP_PRIMARY_EXPOSURE, _CAMERA_DEVICE_PRIMARY, GetSupportedExposureN
+       },
+       {
+               _COP_PRIMARY_FLASH_MODE, _CAMERA_DEVICE_PRIMARY, GetSupportedFlashModeN
+       },
+       {
+               _COP_PRIMARY_FOCUS_MODE, _CAMERA_DEVICE_PRIMARY, GetSupportedFocusModeN
+       },
+       {
+               _COP_PRIMARY_METERING_MODE, _CAMERA_DEVICE_PRIMARY, GetSupportedMeteringModeN
+       },
+       {
+               _COP_PRIMARY_WHITE_BALANCE, _CAMERA_DEVICE_PRIMARY, GetSupportedWhiteBalanceN
+       },
+       {
+               _COP_PRIMARY_ZOOM_TYPE, _CAMERA_DEVICE_PRIMARY, null
+       },
+       {
+               _COP_PRIMARY_FLIP, _CAMERA_DEVICE_PRIMARY, null
+       },
+       {
+               _COP_PRIMARY_PREVIEW_ROTATION, _CAMERA_DEVICE_PRIMARY, null
+       },
+       {
+               _COP_PRIMARY_ZERO_SHUTTER_LAG, _CAMERA_DEVICE_PRIMARY, GetZeroShutterLagN
+       },
+       {
+               _COP_PRIMARY_ZOOM_LEVEL, _CAMERA_DEVICE_PRIMARY, GetSupportedZoomLevelN
+       },
+       {
+               _COP_PRIMARY_MAX_FRAMERATE, _CAMERA_DEVICE_PRIMARY, GetSupportedMaxRecordingFrameRateN
+       },
+       {
+               _COP_SECONDARY_CAPTURE_FORMAT, _CAMERA_DEVICE_SECONDARY, GetSupportedCaptureFormatN
+       },
+       {
+               _COP_SECONDARY_CAPTURE_RESOLUTION, _CAMERA_DEVICE_SECONDARY, GetSupportedCaptureResolutionN
+       },
+       {
+               _COP_SECONDARY_DIRECTION, _CAMERA_DEVICE_SECONDARY, GetDirectionN
+       },
+       {
+               _COP_SECONDARY_EFFECT, _CAMERA_DEVICE_SECONDARY, GetSupportedEffectTypeN
+       },
+       {
+               _COP_SECONDARY_ISO_LEVEL, _CAMERA_DEVICE_SECONDARY, GetSupportedIsoLevelN
+       },
+       {
+               _COP_SECONDARY_PREVIEW_FORMAT, _CAMERA_DEVICE_SECONDARY, GetSupportedPreviewFormatN
+       },
+       {
+               _COP_SECONDARY_PREVIEW_FRAMERATE, _CAMERA_DEVICE_SECONDARY, GetSupportedPreviewFrameRateN
+       },
+       {
+               _COP_SECONDARY_PREVIEW_RESOLUTION, _CAMERA_DEVICE_SECONDARY, GetSupportedPreviewResolutionN
+       },
+       {
+               _COP_SECONDARY_RECORDING_RESOLUTION, _CAMERA_DEVICE_SECONDARY, GetSupportedRecordingResolutionN
+       },
+       {
+               _COP_SECONDARY_ROTATION, _CAMERA_DEVICE_SECONDARY, GetPhysicalRotationN
+       },
+       {
+               _COP_SECONDARY_BRIGHTNESS, _CAMERA_DEVICE_SECONDARY, GetSupportedBrightnessN
+       },
+       {
+               _COP_SECONDARY_CONTRAST, _CAMERA_DEVICE_SECONDARY, GetSupportedContrastN
+       },
+       {
+               _COP_SECONDARY_EXPOSURE, _CAMERA_DEVICE_SECONDARY, GetSupportedExposureN
+       },
+       {
+               _COP_SECONDARY_FLASH_MODE, _CAMERA_DEVICE_SECONDARY, GetSupportedFlashModeN
+       },
+       {
+               _COP_SECONDARY_FOCUS_MODE, _CAMERA_DEVICE_SECONDARY, GetSupportedFocusModeN
+       },
+       {
+               _COP_SECONDARY_METERING_MODE, _CAMERA_DEVICE_SECONDARY, GetSupportedMeteringModeN
+       },
+       {
+               _COP_SECONDARY_WHITE_BALANCE, _CAMERA_DEVICE_SECONDARY, GetSupportedWhiteBalanceN
+       },
+       {
+               _COP_SECONDARY_ZOOM_TYPE, _CAMERA_DEVICE_SECONDARY, null
+       },
+       {
+               _COP_SECONDARY_FLIP, _CAMERA_DEVICE_SECONDARY, null
+       },
+       {
+               _COP_SECONDARY_PREVIEW_ROTATION, _CAMERA_DEVICE_SECONDARY, null
+       },
+       {
+               _COP_SECONDARY_ZERO_SHUTTER_LAG, _CAMERA_DEVICE_SECONDARY, GetZeroShutterLagN
+       },
+       {
+               _COP_SECONDARY_ZOOM_LEVEL, _CAMERA_DEVICE_SECONDARY, GetSupportedZoomLevelN
+       },
+       {
+               _COP_SECONDARY_MAX_FRAMERATE, _CAMERA_DEVICE_SECONDARY, GetSupportedMaxRecordingFrameRateN
+       },
+       {
+               _COP_MAX, _CAMERA_DEVICE_SECONDARY, null
+       },
+};
+
+_CameraCapability::_CameraCapability(void)
+       : __device(_CAMERA_DEVICE_NONE)
+       , __handle(MM_INVALID_HANDLE)
+       , __initPreviewWidth(0)
+       , __initPreviewHeight(0)
+       , __initCaptureWidth(0)
+       , __initCaptureHeight(0)
+       , __initPreviewFormat(::CAMERA_PIXEL_FORMAT_INVALID)
+       , __initCaptureFormat(::CAMERA_PIXEL_FORMAT_INVALID)
+       , __initFlashMode(::CAMERA_ATTR_FLASH_MODE_OFF)
+       , __initEffectMode(::CAMERA_ATTR_EFFECT_NONE)
+       , __initFps(::CAMERA_ATTR_FPS_AUTO)
+       , __initIsoLevel(::CAMERA_ATTR_ISO_AUTO)
+       , __initWb(::CAMERA_ATTR_WHITE_BALANCE_NONE)
+       , __initSceneMode(::CAMERA_ATTR_SCENE_MODE_NORMAL)
+       , __initMeteringMode(::CAMERA_ATTR_EXPOSURE_MODE_OFF)
+       , __initAfMode(::CAMERA_ATTR_AF_NONE)
+{
+}
+
+_CameraCapability::~_CameraCapability(void)
+{
+       _CameraCoordinator::Release(__device);
+       SysLog(NID_MEDIA, "Destroyed");
+}
+
+result
+_CameraCapability::Construct(_CameraDeviceType cameraDevice)
+{
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+       _CameraCoordinator* pCameraCoordinator = null;
+       SysLog(NID_MEDIA, "Enter. camera device:%d", cameraDevice);
+
+       pCameraCoordinator = _CameraCoordinator::AddInstance(cameraDevice);
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, pCameraCoordinator !=null && r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __handle = pCameraCoordinator->GetCameraHandle();
+       __device = cameraDevice;
+
+       err = camera_get_preview_resolution(__handle, &__initPreviewWidth, &__initPreviewHeight);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the preview resolution error.");
+
+       err = camera_get_capture_resolution(__handle, &__initCaptureWidth, &__initCaptureHeight);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the capture resolution error.");
+
+       err = camera_get_preview_format(__handle, &__initPreviewFormat);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the preview format error.");
+
+       err = camera_get_capture_format(__handle, &__initCaptureFormat);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the capture format error.");
+
+       err = camera_attr_get_flash_mode(__handle, &__initFlashMode);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the flash mode error.");
+
+       err = camera_attr_get_effect(__handle, &__initEffectMode);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the effect mode error.");
+
+       err = camera_attr_get_preview_fps(__handle, &__initFps);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the fps error.");
+
+       err = camera_attr_get_iso(__handle, &__initIsoLevel);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the iso error.");
+
+       err = camera_attr_get_whitebalance(__handle, &__initWb);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the white balance.");
+
+       err = camera_attr_get_scene_mode(__handle, &__initSceneMode);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the scene mode error.");
+
+       err = camera_attr_get_exposure_mode(__handle, &__initMeteringMode);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the exposure error.");
+
+       err = camera_attr_get_af_mode(__handle, &__initAfMode);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting the AF mode error.");
+
+       return r;
+}
+
+void
+_CameraCapability::InitSafeHashMapInst()
+{
+       static _CameraCapabilitySafeHashMapT map;
+       result r = E_SUCCESS;
+
+       r = map.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pMap = &map;
+       return;
+CATCH:
+       __pMap = null;
+}
+
+_CameraCapability*
+_CameraCapability::AddInstance(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+       bool out = false;
+       ClearLastResult();
+
+       _CameraCapability* pCapability = null;
+
+       SysTryReturn(NID_MEDIA, cameraDevice > _CAMERA_DEVICE_NONE && cameraDevice < _CAMERA_DEVICE_MAX,
+                               null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument. camderDevice:%d.", cameraDevice);
+
+       static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+
+       if (!__pMap)
+       {
+               pthread_once(&once_block, InitSafeHashMapInst);
+               r = GetLastResult();
+               SysTryCatch(NID_MEDIA, __pMap != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       r = __pMap->ContainsKey(cameraDevice, out);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (out)
+       {
+               r = __pMap->GetValue(cameraDevice, pCapability);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS && pCapability != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else
+       {
+               pCapability = new (std::nothrow) _CameraCapability();
+               SysTryCatch(NID_MEDIA, pCapability !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pCapability->Construct(cameraDevice);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = __pMap->Add(cameraDevice, pCapability);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       pCapability->AddRefCount();
+       return pCapability;
+
+CATCH:
+       if (pCapability != null)
+       {
+               delete pCapability;
+       }
+       return null;
+}
+
+void
+_CameraCapability::Release(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+
+       if (__pMap != null)
+       {
+               _CameraCapability* pCameraCapability = null;
+               r = __pMap->GetValue(cameraDevice, pCameraCapability);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               if (pCameraCapability->ReleaseRefCount() == 0)
+               {
+                       delete pCameraCapability;
+                       r = __pMap->Remove(cameraDevice);
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+}
+
+Tizen::Base::Collection::ArrayList*
+_CameraCapability::GetListN(_CameraOperationType key, _ResultType& itemType)
+{
+       //check key boundary condition
+       SysTryReturn(NID_MEDIA, (key > _COP_NONE && key < _COP_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument. key :%d", key);
+
+       _CameraDeviceType deviceType = __SERVICE_MAP[key].deviceType;
+       _CameraQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
+
+       //check service handler for a given key
+       SysTryReturn(NID_MEDIA, serviceRoutine != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The query function is not found.");
+
+       std::unique_ptr<ArrayList, _ListPtrUtil::Remover> pList (null, _ListPtrUtil::remover);
+       Object* pObj = serviceRoutine(deviceType, _QUERY_LIST, itemType);
+       switch (itemType)
+       {
+       case _RESULT_INTEGER_LIST:
+               //fall through
+       case _RESULT_PAIR_INTEGER_LIST:
+               //fall through
+       case _RESULT_DIMENSION_LIST:
+               //fall through
+       case _RESULT_DOUBLE_LIST:
+               //fall through
+       case _RESULT_STRING_LIST:
+       {
+               pList.reset(dynamic_cast<ArrayList*>(pObj));
+               SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               SysTryCatch(NID_MEDIA, pList->GetCount() > 0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Empty data returned for key = [%d]", key);
+               SysLog(NID_MEDIA, "Valid data returned for key = %d count = %d", key, pList->GetCount());
+       }
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Supported List is not retrieved. key = [%d]", key);
+               goto CATCH;
+               break;
+       }
+       return pList.release();
+
+CATCH:
+       return null;
+}
+
+bool
+_CameraCapability::IsSupported(_CameraOperationType key)
+{
+       //check key boundary condition
+       SysTryReturn(NID_MEDIA, (key > _COP_NONE && key < _COP_MAX), false, E_INVALID_ARG, "[E_INVALID_ARG] The key:%d is invalid.", key);
+
+       _CameraDeviceType deviceType = __SERVICE_MAP[key].deviceType;
+       _CameraQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
+       _ResultType itemType = _RESULT_NONE;
+
+       //check service handler for a given key
+       SysTryReturn(NID_MEDIA, serviceRoutine != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       std::unique_ptr<ArrayList, _ListPtrUtil::Remover> pList (null, _ListPtrUtil::remover);
+       Object* pObj = serviceRoutine(deviceType, _QUERY_LIST, itemType);
+       switch (itemType)
+       {
+       case _RESULT_INTEGER_LIST:
+               //fall through
+       case _RESULT_DIMENSION_LIST:
+               //fall through
+       case _RESULT_DOUBLE_LIST:
+               //fall through
+       case _RESULT_STRING_LIST:
+       {
+               pList.reset(dynamic_cast<ArrayList*>(pObj));
+               SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               SysTryCatch(NID_MEDIA, pList->GetCount()>0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no valid data in key = [%d].", key);
+       }
+               break;
+
+       case _RESULT_PAIR_INTEGER_LIST:
+       {
+               pList.reset(dynamic_cast<ArrayList*>(pObj));
+               SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               {
+                       Integer* pInteger = null;
+                       pInteger = dynamic_cast<Integer*>(pList->GetAt(1));              // Get max value;
+                       SysTryCatch(NID_MEDIA, pInteger != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Max value is null for key = [%d].", key);
+                       SysTryCatch(NID_MEDIA, pInteger->ToInt() > 0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Max value is %d for key = [%d].", pInteger->ToInt(), key);
+               }
+       }
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               goto CATCH;
+               break;
+       }
+       SysLog(NID_MEDIA, "Valid data returned for key = %d count = %d", key, pList->GetCount());
+       return true;
+
+CATCH:
+       return false;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetValueN(_CameraOperationType key, _QueryType queryType, _ResultType& itemType)
+{
+       Tizen::Base::Object* pValue = null;
+
+       //check key boundary condition
+       SysTryReturn(NID_MEDIA, (key > _COP_NONE && key < _COP_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] The key:%d is invalid.", key);
+       SysTryReturn(NID_MEDIA, (queryType >= _QUERY_DEFAULT_VALUE && queryType < _QUERY_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] The query:%d is invalid.", queryType);
+
+       _CameraDeviceType deviceType = __SERVICE_MAP[key].deviceType;
+       _CameraQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
+
+       //check service handler for a given key
+       SysTryReturn(NID_MEDIA, serviceRoutine != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The query function is not found.");
+
+       Object* pObj = serviceRoutine(deviceType, queryType, itemType);
+
+       switch (itemType)
+       {
+       case _RESULT_INTEGER:
+       {
+               pValue = dynamic_cast<Integer*>(pObj);
+               SysTryReturn(NID_MEDIA, null != pValue, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+       }
+               break;
+
+       case _RESULT_DIMENSION:
+       {
+               pValue = dynamic_cast<Dimension*>(pObj);
+               SysTryReturn(NID_MEDIA, null != pValue, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+       }
+               break;
+
+       case _RESULT_INTEGER_LIST:
+               //fall through
+       case _RESULT_PAIR_INTEGER_LIST:
+               //fall through
+       case _RESULT_DIMENSION_LIST:
+               //fall through
+       case _RESULT_DOUBLE_LIST:
+               //fall through
+       case _RESULT_STRING_LIST:
+               //fall through
+       default:
+               SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Default value cannot be retrived. key = [%d], itemType:%d", key, itemType);
+               goto CATCH;
+               break;
+       }
+       SysLog(NID_MEDIA, "Valid data returned for key = %d", key);
+       return pValue;
+
+CATCH:
+       return null;
+}
+
+_CameraHandle
+_CameraCapability::GetHandle(void) const
+{
+       return __handle;
+}
+
+_CameraDeviceType
+_CameraCapability::GetDevice(void) const
+{
+       return __device;
+}
+
+void
+_CameraCapability::GetInitResolution(AttributeResType opType, int &width, int &height) const
+{
+       switch (opType)
+       {
+       case ATTR_RES_PREVIEW:
+       {
+               width = __initPreviewWidth;
+               height = __initPreviewHeight;
+       }
+               break;
+
+       case ATTR_RES_CAPTURE:
+       {
+               width = __initCaptureWidth;
+               height = __initCaptureHeight;
+       }
+               break;
+
+       default:
+               break;
+       }
+}
+
+void
+_CameraCapability::GetInitValue(AttributeType opType, int& mmAttr) const
+{
+       switch (opType)
+       {
+       case ATTR_PREVIEW_FORMAT:
+       {
+               mmAttr = __initPreviewFormat;
+       }
+               break;
+
+       case ATTR_CAPTURE_FORMAT:
+       {
+               mmAttr = __initCaptureFormat;
+       }
+               break;
+
+       case ATTR_FLASH_MODE:
+       {
+               mmAttr = __initFlashMode;
+       }
+               break;
+
+       case ATTR_EFFECT_MODE:
+       {
+               mmAttr = __initEffectMode;
+       }
+               break;
+
+       case ATTR_FPS:
+       {
+               mmAttr = __initFps;
+       }
+               break;
+
+       case ATTR_ISO_LEVEL:
+       {
+               mmAttr = __initIsoLevel;
+       }
+               break;
+
+       case ATTR_WHITE_BALANCE:
+       {
+               mmAttr = __initWb;
+       }
+               break;
+
+       case ATTR_SCENE_MODE:
+       {
+               mmAttr = __initSceneMode;
+       }
+               break;
+
+       case ATTR_EXPOSURE_MODE:
+       {
+               mmAttr = __initMeteringMode;
+       }
+               break;
+
+       case ATTR_AUTO_FOCUS_MODE:
+       {
+               mmAttr = __initAfMode;
+       }
+               break;
+
+       default:
+               break;
+       }
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedPreviewResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pResolution = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pResolutionList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pResolutionList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_foreach_supported_preview_resolution(cameraHandle, SupportedCameraPreviewResolutionCb, pResolutionList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_DIMENSION_LIST;
+               pResolution = pResolutionList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int width = 0;
+               int height = 0;
+               pCapability->GetInitResolution(_CameraCapability::ATTR_RES_PREVIEW, width, height);
+
+               std::unique_ptr<Dimension> pDimResolution (new (std::nothrow) Dimension(width, height));
+               SysTryReturn(NID_MEDIA, pDimResolution.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_DIMENSION;
+               pResolution = pDimResolution.release();
+       }
+
+       return pResolution;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedCaptureResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pResolution = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pResolutionList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pResolutionList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_foreach_supported_capture_resolution(cameraHandle, SupportedCameraCaptureResolutionCb, pResolutionList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_DIMENSION_LIST;
+               pResolution = pResolutionList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int width = 0;
+               int height = 0;
+               pCapability->GetInitResolution(_CameraCapability::ATTR_RES_CAPTURE, width, height);
+
+               std::unique_ptr<Dimension> pDimResolution (new (std::nothrow) Dimension(width, height));
+               SysTryReturn(NID_MEDIA, pDimResolution.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_DIMENSION;
+               pResolution = pDimResolution.release();
+       }
+
+       return pResolution;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedRecordingResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pResolution = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pResolutionList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pResolutionList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_foreach_supported_preview_resolution(cameraHandle, SupportedCameraPreviewResolutionCb, pResolutionList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_DIMENSION_LIST;
+               pResolution = pResolutionList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int width = 0;
+               int height = 0;
+               pCapability->GetInitResolution(_CameraCapability::ATTR_RES_PREVIEW, width, height);
+
+               std::unique_ptr<Dimension> pDimResolution (new (std::nothrow) Dimension(width, height));
+               SysTryReturn(NID_MEDIA, pDimResolution.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_DIMENSION;
+               pResolution = pDimResolution.release();
+       }
+
+       return pResolution;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedPreviewFormatN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pFormat = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+//from here
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFormatList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_foreach_supported_preview_format(cameraHandle, SupportedCameraPreviewFormatCb, pFormatList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pFormat = pFormatList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               PixelFormat value = PIXEL_FORMAT_YCbCr420_PLANAR;
+
+// Camera's PowerOn should be called to initialize the default value with capability's return value.
+               result r = E_SUCCESS;
+               int mmAttr = ::CAMERA_PIXEL_FORMAT_INVALID;
+               pCapability->GetInitValue(_CameraCapability::ATTR_PREVIEW_FORMAT, mmAttr);
+
+               r = _CameraUtil::GetOspGrpPixelFormat((camera_pixel_format_e)mmAttr, value);
+               //SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               //This is temporary code because PIXEL_FORMAT_YUYV is not in the Graphics's PIXEL_FORMAT list.
+               if (r  != E_SUCCESS)
+               {
+                       value = PIXEL_FORMAT_YCbCr420_PLANAR;
+                       SysLog(NID_MEDIA, "YCbCr420 will be used instead of device default value.");
+               }
+
+               std::unique_ptr<Integer> pFormatValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pFormatValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pFormat = pFormatValue.release();
+       }
+
+       return pFormat;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedCaptureFormatN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pFormat = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFormatList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_foreach_supported_capture_format(cameraHandle, SupportedCameraCaptureFormatCb, pFormatList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pFormat = pFormatList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               PixelFormat value = PIXEL_FORMAT_JPEG;
+
+// This means that the real device's default value is different from the capability's return value.
+// Camera's PowerOn should be called to initialize the default value with capability's return value.
+//             result r = E_SUCCESS;
+//             int mmAttr = ::CAMERA_PIXEL_FORMAT_INVALID;
+//             pCapability->GetInitValue(_CameraCapability::ATTR_CAPTURE_FORMAT, mmAttr);
+//
+//             r = _CameraUtil::GetOspGrpPixelFormat((camera_pixel_format_e)mmAttr, value);
+//             SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pFormatValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pFormatValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pFormat = pFormatValue.release();
+       }
+
+       return pFormat;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedFlashModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pFlash = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFlashList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pFlashList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_attr_foreach_supported_flash_mode(cameraHandle, SupportedCameraAttrFlashModeCb, pFlashList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pFlash = pFlashList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int mmAttr = ::CAMERA_ATTR_FLASH_MODE_OFF;
+               CameraFlashMode value = CAMERA_FLASH_MODE_OFF;
+
+               pCapability->GetInitValue(_CameraCapability::ATTR_FLASH_MODE, mmAttr);
+               r = _CameraUtil::GetOspFlashMode((camera_attr_flash_mode_e)mmAttr, value);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pFlashValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pFlashValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pFlash = pFlashValue.release();
+       }
+
+       return pFlash;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedEffectTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pEffect = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pEffectList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pEffectList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_attr_foreach_supported_effect(cameraHandle, SupportedCameraAttrEffectCb, pEffectList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               // In the case of including only NONE effect, delete the NONE capability for the application's usability.
+               if (pEffectList->GetCount() == 1)
+               {
+                       Integer* pInteger = null;
+                       pInteger = dynamic_cast<Integer*>(pEffectList->GetAt(0));
+                       SysTryReturn(NID_MEDIA, pInteger != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Integer instance is not available.");
+
+                       if (pInteger->ToInt() == (int)CAMERA_EFFECT_NONE)
+                       {
+                               pEffectList->RemoveAll(true);
+                       }
+               }
+               itemType = _RESULT_INTEGER_LIST;
+               pEffect = pEffectList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int mmAttr = ::CAMERA_ATTR_EFFECT_NONE;
+               CameraEffect value = CAMERA_EFFECT_NONE;
+
+               pCapability->GetInitValue(_CameraCapability::ATTR_EFFECT_MODE, mmAttr);
+               r = _CameraUtil::GetOspEffect((camera_attr_effect_mode_e)mmAttr, value);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pEffectValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pEffectValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pEffect = pEffectValue.release();
+       }
+
+       return pEffect;
+}
+
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedPreviewFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pFps = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFpsList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pFpsList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_attr_foreach_supported_fps(cameraHandle, SupportedCameraAttrFpsCb, pFpsList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pFps = pFpsList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int mmAttr = ::CAMERA_ATTR_FPS_AUTO;
+               int value = 0;
+
+               pCapability->GetInitValue(_CameraCapability::ATTR_FPS, mmAttr);
+               r = _CameraUtil::GetOspFps((camera_attr_fps_e)mmAttr, value);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pFpsValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pFpsValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pFps = pFpsValue.release();
+       }
+
+       return pFps;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedPreviewFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, const Tizen::Graphics::Dimension &dim, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "Dim's width : %d, height : %d", dim.width, dim.height);
+       return GetSupportedPreviewFrameRateN(deviceType, queryType, itemType);
+}
+
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedMaxRecordingFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "_QueryType is : %d, will be ignored", queryType);
+
+       Object* pPreviewObj = GetSupportedPreviewFrameRateN(deviceType, _QUERY_LIST, itemType);
+       SysTryReturn(NID_MEDIA, pPreviewObj != null, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Preview is not supported.");
+
+       std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pFpsList (dynamic_cast<_MediaSafeArrayList*>(pPreviewObj), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pFpsList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  List is wrong.");
+
+       //the last time of the list shall be the maximum value of the fps
+
+       int count = pFpsList->GetCount();
+       SysTryReturn(NID_MEDIA, count > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  List is wrong.");
+
+       Integer* pItemObj = (Integer*) (pFpsList->GetAt(count - 1));
+       itemType = _RESULT_INTEGER;
+
+       std::unique_ptr<Integer> pIntegerObj (new (std::nothrow) Integer(*pItemObj));
+       SysTryReturn(NID_MEDIA, pIntegerObj.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  out of memory");
+
+       return pIntegerObj.release();
+}
+
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedIsoLevelN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pIsoLevel = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pIsoLevelList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pIsoLevelList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_attr_foreach_supported_iso(cameraHandle, SupportedCameraAttrIsoCb, pIsoLevelList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               // In the case of including only NONE IsoLevel, delete the NONE capability for the application's usability.
+               if (pIsoLevelList->GetCount() == 1)
+               {
+                       Integer* pInteger = null;
+                       pInteger = dynamic_cast<Integer*>(pIsoLevelList->GetAt(0));
+                       SysTryReturn(NID_MEDIA, pInteger != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Integer instance is not available. (0) item is not found.");
+
+                       if (pInteger->ToInt() == (int)CAMERA_ISO_AUTO)
+                       {
+                               pIsoLevelList->RemoveAll(true);
+                       }
+               }
+               itemType = _RESULT_INTEGER_LIST;
+               pIsoLevel = pIsoLevelList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int mmAttr = ::CAMERA_ATTR_ISO_AUTO;
+               CameraIsoLevel value = CAMERA_ISO_AUTO;
+
+               pCapability->GetInitValue(_CameraCapability::ATTR_ISO_LEVEL, mmAttr);
+               r = _CameraUtil::GetOspIso((camera_attr_iso_e)mmAttr, value);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pIsoLevelValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pIsoLevelValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pIsoLevel = pIsoLevelValue.release();
+       }
+
+       return pIsoLevel;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedWhiteBalanceN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pWb = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pWbList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pWbList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_attr_foreach_supported_whitebalance(cameraHandle, SupportedCameraAttrWhitebalanceCb, pWbList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pWb = pWbList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int mmAttr = ::CAMERA_ATTR_WHITE_BALANCE_NONE;
+               CameraWhiteBalance value = CAMERA_WHITE_BALANCE_AUTO;
+
+               pCapability->GetInitValue(_CameraCapability::ATTR_WHITE_BALANCE, mmAttr);
+               r = _CameraUtil::GetOspWhiteBalance((camera_attr_whitebalance_e)mmAttr, value);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pWbValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pWbValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pWb = pWbValue.release();
+       }
+
+       return pWb;
+}
+
+// This feature is not implemented. It will be implemented based on the request.
+Tizen::Base::Object*
+_CameraCapability::GetSupportedShutterSpeedN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
+       return null;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedSceneN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pScene = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pSceneList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pSceneList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_attr_foreach_supported_scene_mode(cameraHandle, SupportedCameraAttrSceneModeCb, pSceneList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pScene = pSceneList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int mmAttr = ::CAMERA_ATTR_SCENE_MODE_NORMAL;
+               _CameraSceneMode value = CAMERA_SCENE_NONE;
+
+               pCapability->GetInitValue(_CameraCapability::ATTR_SCENE_MODE, mmAttr);
+               r = _CameraUtil::GetOspScene((camera_attr_scene_mode_e)mmAttr, value);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pSceneValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pSceneValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pScene = pSceneValue.release();
+       }
+
+       return pScene;
+}
+
+// This feature is not implemented. It will be implemented based on the request.
+Tizen::Base::Object*
+_CameraCapability::GetSupportedMeteringN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
+       return null;
+}
+
+
+// This feature is not implemented. It will be implemented based on the request.
+Tizen::Base::Object*
+_CameraCapability::GetSupportedApertureN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
+       return null;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedExposureN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pExposure = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               int mmMin = 0;
+               int mmMax = 0;
+
+               err = camera_attr_get_exposure_range(cameraHandle, &mmMin, &mmMax);
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+               SysTryReturn(NID_MEDIA, mmMax - mmMin > 0, null, E_UNSUPPORTED_OPERATION,
+                       "[E_UNSUPPORTED_OPERATION] This operation is not supported");
+
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pExposureList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pExposureList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               std::unique_ptr<Object> pMin (new (std::nothrow) Integer(0));
+               SysTryReturn(NID_MEDIA, pMin.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pExposureList->AddPtr(std::move(pMin));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Object> pMax (new (std::nothrow) Integer(9));
+               SysTryReturn(NID_MEDIA, pMax.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pExposureList->AddPtr(std::move(pMax));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               itemType = _RESULT_PAIR_INTEGER_LIST;
+               pExposure = pExposureList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               std::unique_ptr<Integer> pExposureValue (new (std::nothrow) Integer(5));
+               SysTryReturn(NID_MEDIA, pExposureValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pExposure = pExposureValue.release();
+       }
+
+       return pExposure;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedMeteringModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pMeteringMode = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pMeteringModeList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pMeteringModeList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] out of memory");
+
+               err = camera_attr_foreach_supported_exposure_mode(cameraHandle, SupportedCameraAttrMeteringModeCb, pMeteringModeList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pMeteringMode = pMeteringModeList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int mmAttr = ::CAMERA_ATTR_EXPOSURE_MODE_OFF;
+               CameraMeteringMode value = CAMERA_METERING_MODE_NONE;
+
+               pCapability->GetInitValue(_CameraCapability::ATTR_EXPOSURE_MODE, mmAttr);
+               r = _CameraUtil::GetOspMeteringMode((camera_attr_exposure_mode_e)mmAttr, value);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pMeteringModeValue (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pMeteringModeValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] out of memory");
+
+               itemType = _RESULT_INTEGER;
+               pMeteringMode = pMeteringModeValue.release();
+       }
+
+       return pMeteringMode;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedFocusModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pAutoFocus = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pAutoFocusRangeList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pAutoFocusRangeList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = camera_attr_foreach_supported_af_mode(cameraHandle, SupportedCameraAttrAfModeCb, pAutoFocusRangeList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pAutoFocus = pAutoFocusRangeList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               int mmAttr = ::CAMERA_ATTR_AF_NONE;
+               CameraFocusMode value = CAMERA_FOCUS_MODE_NONE;
+
+               pCapability->GetInitValue(_CameraCapability::ATTR_AUTO_FOCUS_MODE, mmAttr);
+               r = _CameraUtil::GetOspFocusMode((camera_attr_af_mode_e)mmAttr, value);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Integer> pAutoFocusRange (new (std::nothrow) Integer((int)value));
+               SysTryReturn(NID_MEDIA, pAutoFocusRange.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pAutoFocus = pAutoFocusRange.release();
+       }
+
+       return pAutoFocus;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedZoomTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
+       return null;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedFlipTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
+       return null;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedPreviewRotationN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
+       return null;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetZeroShutterLagN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pZeroShutterLag = null;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               SysLogException(NID_MEDIA, E_INVALID_ARG, "[E_INVALID_ARG] This key doesn't give the list.");
+               itemType = _RESULT_NONE;
+               pZeroShutterLag = null;
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               bool supported = false;
+               supported = camera_is_supported_zero_shutter_lag(cameraHandle);
+
+               std::unique_ptr<Integer> pInteger (new (std::nothrow) Integer((int)supported));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] out of memory");
+
+               itemType = _RESULT_INTEGER;
+               pZeroShutterLag = pInteger.release();
+       }
+
+       return pZeroShutterLag;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedContrastN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pContrast = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               int mmMin = 0;
+               int mmMax = 0;
+
+               err = camera_attr_get_contrast_range(cameraHandle, &mmMin, &mmMax);
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+               SysTryReturn(NID_MEDIA, mmMax - mmMin > 0, null, E_UNSUPPORTED_OPERATION,
+                       "[E_UNSUPPORTED_OPERATION] This operation is not supported");
+
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pContrastList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pContrastList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               std::unique_ptr<Object> pMin (new (std::nothrow) Integer(0));
+               SysTryReturn(NID_MEDIA, pMin.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pContrastList->AddPtr(std::move(pMin));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Object> pMax (new (std::nothrow) Integer(9));
+               SysTryReturn(NID_MEDIA, pMax.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pContrastList->AddPtr(std::move(pMax));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               itemType = _RESULT_PAIR_INTEGER_LIST;
+               pContrast = pContrastList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               std::unique_ptr<Integer> pContrastValue (new (std::nothrow) Integer(5));
+               SysTryReturn(NID_MEDIA, pContrastValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pContrast = pContrastValue.release();
+       }
+
+       return pContrast;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedBrightnessN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pBrightness = null;
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               int mmMin = 0;
+               int mmMax = 0;
+
+               err = camera_attr_get_brightness_range(cameraHandle, &mmMin, &mmMax);
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+               SysTryReturn(NID_MEDIA, mmMax - mmMin > 0, null, E_UNSUPPORTED_OPERATION,
+                       "[E_UNSUPPORTED_OPERATION] This operation is not supported");
+
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pBrightnessList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pBrightnessList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               std::unique_ptr<Object> pMin (new (std::nothrow) Integer(0));
+               SysTryReturn(NID_MEDIA, pMin.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pBrightnessList->AddPtr(std::move(pMin));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Object> pMax (new (std::nothrow) Integer(9));
+               SysTryReturn(NID_MEDIA, pMax.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pBrightnessList->AddPtr(std::move(pMax));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               itemType = _RESULT_PAIR_INTEGER_LIST;
+               pBrightness = pBrightnessList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               std::unique_ptr<Integer> pBrightnessValue (new (std::nothrow) Integer(5));
+               SysTryReturn(NID_MEDIA, pBrightnessValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pBrightness = pBrightnessValue.release();
+       }
+
+       return pBrightness;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetSupportedZoomLevelN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pZoom = null;
+       int err = MM_SUCCESS;
+       int mmMin = 0;
+       int mmMax = 0;
+       result r = E_SUCCESS;
+
+       _CameraCapabilitySession cameraCapbilitySession;
+       r = cameraCapbilitySession.Construct(deviceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCapability* pCapability = cameraCapbilitySession.GetCameraCapability();
+       SysTryReturn(NID_MEDIA, pCapability != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A capability instance is not found.");
+
+       _CameraHandle cameraHandle = pCapability->GetHandle();
+       SysTryReturn(NID_MEDIA, cameraHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       err = camera_attr_get_zoom_range(cameraHandle, &mmMin, &mmMax);
+       SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+       SysTryReturn(NID_MEDIA, mmMax - mmMin > 0, null, E_UNSUPPORTED_OPERATION,
+               "[E_UNSUPPORTED_OPERATION] This operation is not supported");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pZoomList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pZoomList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               std::unique_ptr<Object> pMin (new (std::nothrow) Integer(mmMin));
+               SysTryReturn(NID_MEDIA, pMin.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pZoomList->AddPtr(std::move(pMin));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               std::unique_ptr<Object> pMax (new (std::nothrow) Integer(mmMax));
+               SysTryReturn(NID_MEDIA, pMax.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pZoomList->AddPtr(std::move(pMax));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               itemType = _RESULT_PAIR_INTEGER_LIST;
+               pZoom = pZoomList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               std::unique_ptr<Integer> pZoomValue (new (std::nothrow) Integer(mmMin));
+               SysTryReturn(NID_MEDIA, pZoomValue.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               itemType = _RESULT_INTEGER;
+               pZoom = pZoomValue.release();
+       }
+
+       return pZoom;
+}
+
+Tizen::Base::Object*
+_CameraCapability::GetDirectionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
+       return null;
+}
+
+// Camera direction
+Tizen::Base::Object*
+_CameraCapability::GetPhysicalRotationN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType)
+{
+       SysLog(NID_MEDIA, "DeviceType is : %d, queryType is : %d itemType is : %d", deviceType, queryType, itemType);
+       return null;
+}
+
+bool
+_CameraCapability::SupportedCameraPreviewResolutionCb(int width, int height, void* pUserData)
+{
+       result r = E_SUCCESS;
+
+//In Redwood Target, If both width and height are lager than 1088, Video Recordingis not  supported because of MFC limmitation.
+       if (width >= 1088 && height >= 1088)
+       {
+               return true;
+       }
+//If Preview resolution ratio is not same Capture resolution ratio, Capture do not performed because of camera hw module's limmitation in RedWood target.
+       if ((width == 176 && height == 144) || (width == 1280 && height == 720))
+       {
+               return true;
+       }
+
+       _MediaSafeArrayList* pResolutionList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pResolutionList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       std::unique_ptr<Object> pDim (new (std::nothrow) Dimension(width, height));
+       SysTryReturn(NID_MEDIA, pDim.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pResolutionList->AddPtr(std::move(pDim));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraCaptureResolutionCb(int width, int height, void* pUserData)
+{
+       result r = E_SUCCESS;
+
+// This means that 1080 HD resolution capture is not supported.
+// In Redwood Target, 1392X1392 Resolution is not  supported because of MFC limmitation.
+       if ((height == 1080) || (width == 1392 && height == 1392))
+       {
+               return true;
+       }
+
+       _MediaSafeArrayList* pResolutionList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pResolutionList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       std::unique_ptr<Object> pDim (new (std::nothrow) Dimension(width, height));
+       SysTryReturn(NID_MEDIA, pDim.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pResolutionList->AddPtr(std::move(pDim));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraPreviewFormatCb(camera_pixel_format_e format, void *pUserData)
+{
+       result r = E_SUCCESS;
+       Tizen::Graphics::PixelFormat previewPixelValue = (Tizen::Graphics::PixelFormat)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pFormatList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pFormatList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspGrpPixelFormat(format, previewPixelValue);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(previewPixelValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pFormatList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraCaptureFormatCb(camera_pixel_format_e format, void *pUserData)
+{
+       result r = E_SUCCESS;
+       Tizen::Graphics::PixelFormat capturePixelValue = (Tizen::Graphics::PixelFormat)MEDIA_INVALID_VALUE;
+
+// This means that the raw format capture is not supported yet.
+       if ( format == ::CAMERA_PIXEL_FORMAT_I420 || format == ::CAMERA_PIXEL_FORMAT_YUYV )
+       {
+               return true;
+       }
+
+       _MediaSafeArrayList* pFormatList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pFormatList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspGrpPixelFormat(format, capturePixelValue);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(capturePixelValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pFormatList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraAttrFlashModeCb(camera_attr_flash_mode_e mode, void *pUserData)
+{
+       result r = E_SUCCESS;
+       CameraFlashMode flashMode = (CameraFlashMode)MEDIA_INVALID_VALUE;
+
+// This means that the flash-off mode is not included to the supported list.
+       if ( mode == ::CAMERA_ATTR_FLASH_MODE_OFF )
+       {
+               return true;
+       }
+
+       _MediaSafeArrayList* pFlashList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pFlashList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspFlashMode(mode, flashMode);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(flashMode));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pFlashList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return true;
+ }
+
+bool
+_CameraCapability::SupportedCameraAttrEffectCb(camera_attr_effect_mode_e effect, void *pUserData)
+{
+       result r = E_SUCCESS;
+       CameraEffect effectValue = (CameraEffect)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pEffectList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pEffectList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspEffect(effect, effectValue);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(effectValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pEffectList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraAttrFpsCb(camera_attr_fps_e fps, void *pUserData)
+{
+       result r = E_SUCCESS;
+       int framePerSec = 0;
+
+       _MediaSafeArrayList* pfpsList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pfpsList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspFps(fps, framePerSec);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(framePerSec));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pfpsList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraAttrWhitebalanceCb(camera_attr_whitebalance_e wb, void *pUserData)
+{
+       result r = E_SUCCESS;
+       CameraWhiteBalance wbValue = (CameraWhiteBalance)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pWhitebalanceList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pWhitebalanceList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspWhiteBalance(wb, wbValue);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(wbValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pWhitebalanceList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraAttrSceneModeCb(camera_attr_scene_mode_e mode, void *pUserData)
+{
+       result r = E_SUCCESS;
+       _CameraSceneMode sceneModeValue = (_CameraSceneMode)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pSceneList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pSceneList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspScene(mode, sceneModeValue);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(sceneModeValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pSceneList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraAttrIsoCb(camera_attr_iso_e iso, void *pUserData)
+{
+       result r = E_SUCCESS;
+       CameraIsoLevel isoValue = (CameraIsoLevel)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pIsoLevelList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pIsoLevelList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspIso(iso, isoValue);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(isoValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pIsoLevelList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraAttrMeteringModeCb(camera_attr_exposure_mode_e mode, void *pUserData)
+{
+       result r = E_SUCCESS;
+       CameraMeteringMode exposureModeValue = (CameraMeteringMode)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pExposureList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pExposureList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspMeteringMode(mode,exposureModeValue);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(exposureModeValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pExposureList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       return true;
+}
+
+bool
+_CameraCapability::SupportedCameraAttrAfModeCb(camera_attr_af_mode_e mode, void *pUserData)
+{
+       result r = E_SUCCESS;
+       CameraFocusMode afModeValue = CAMERA_FOCUS_MODE_NONE;
+       bool additionalMode = false;
+       CameraFocusMode additionalAfModeValue = CAMERA_FOCUS_MODE_NONE;
+
+       _MediaSafeArrayList* pAutoFocusList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pAutoFocusList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _CameraUtil::GetOspFocusMode(mode,afModeValue, additionalMode, additionalAfModeValue);
+       if (r == E_SUCCESS)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(afModeValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pAutoFocusList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               //if there is any specific Osp mode which is not defined in the mm layer, add the additional value to the list based on the mm mode.
+               //For example, CAMERA_FOCUS_MODE_NORMAL and CAMERA_FOCUS_MODE_CONTINUOUS_AUTO are from mm's ::CAMERA_ATTR_AF_NORMAL.
+               if (additionalMode)
+               {
+                       std::unique_ptr<Object> pInteger2 (new (std::nothrow) Integer(additionalAfModeValue));
+                       SysTryReturn(NID_MEDIA, pInteger2.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       r = pAutoFocusList->AddPtr(std::move(pInteger2));
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       return true;
+}
+
+}}
diff --git a/src/FMedia_CameraCapability.h b/src/FMedia_CameraCapability.h
new file mode 100755 (executable)
index 0000000..a891707
--- /dev/null
@@ -0,0 +1,644 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                        FMedia_CameraCapability.h
+* @brief               This header file contains the implementation header for camera capability.
+*
+*/
+#ifndef _FMEDIA_INTERNAL_CAMERA_CAPABILITY_H_
+#define _FMEDIA_INTERNAL_CAMERA_CAPABILITY_H_
+
+#include <FBaseObject.h>
+#include <FBaseColHashMapT.h>
+#include <FBaseColArrayList.h>
+#include <FGrpDimension.h>
+#include "FMedia_CameraTypes.h"
+#include "FMedia_CapabilityTypes.h"
+#include "FMedia_CameraRefHelper.h"
+
+namespace Tizen { namespace Media
+{
+
+class _CameraCapabilitySafeHashMapT;
+typedef Tizen::Base::Object* (*_CameraQueryFunc)(_CameraDeviceType, _QueryType, _ResultType&);
+/**
+* @class       _CameraCapability
+* @brief       This class is common for camera and recorder and media capability.
+*
+*/
+class _CameraCapability
+       : public _CameraRefHelper
+{
+public:
+       /**
+       * Get the instance of _CameraCapability.
+       *
+       * @return               The _CameraCapability instance
+       * @param[in]    cameraDevice                    The camcorder device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       static _CameraCapability* AddInstance(_CameraDeviceType cameraDevice);
+
+       /**
+       * Release the specific _CameraCapability
+       *
+       * @param[in]    cameraDevice                    The camera device type
+       */
+       static void Release(_CameraDeviceType cameraDevice);
+
+       /**
+       * function to get the  for specific key type
+       *
+       * @return               IList*
+       * @param[in]    key                                             camera operation query key
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_UNSUPPORTED_OPERATION   operation not supported
+       */
+       static Tizen::Base::Collection::ArrayList* GetListN(_CameraOperationType key, _ResultType& itemType);
+
+       /**
+       * function to check the feature support
+       *
+       * @return               bool
+       * @param[in]    key                                             camera operation query key
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       * @exception    E_UNSUPPORTED_OPERATION   operation not supported
+       */
+       static bool IsSupported(_CameraOperationType key);
+
+       /**
+       * function to get the default value for a specific key
+       *
+       * @return               Object
+       * @param[in]    key                                             camera operation query key
+       * @param[in] queryType                          Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       * @exception    E_UNSUPPORTED_OPERATION   operation not supported
+       */
+       static Tizen::Base::Object* GetValueN(_CameraOperationType key, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * Gets the device selection.
+       *
+       * @return                  The device selection
+       */
+       _CameraDeviceType GetDevice(void) const;
+
+       /**
+       * Gets the camera's handle
+       *
+       * @return                  The camera handle
+       */
+       _CameraHandle GetHandle(void) const;
+
+       enum AttributeType
+       {
+               ATTR_PREVIEW_FORMAT,
+               ATTR_CAPTURE_FORMAT,
+               ATTR_FLASH_MODE,
+               ATTR_EFFECT_MODE,
+               ATTR_FPS,
+               ATTR_ISO_LEVEL,
+               ATTR_WHITE_BALANCE,
+               ATTR_SCENE_MODE,
+               ATTR_EXPOSURE_MODE,
+               ATTR_AUTO_FOCUS_MODE,
+       };
+
+       enum AttributeResType
+       {
+               ATTR_RES_PREVIEW,
+               ATTR_RES_CAPTURE,
+       };
+       /**
+       * Gets the camera's initial resolution
+       *
+       * @param[in]    opType                          The resolution operationType.
+       * @param[out]   width                           The initial width.
+       * @param[out]   height                          The initial height.
+       */
+       void GetInitResolution(AttributeResType opType, int &width, int &height) const;
+
+       /**
+       * Gets the camera's initial value
+       *
+       * @param[in]    opType                          The operationType.
+       * @param[out]   mmAttr                          The mm attribute
+       */
+       void GetInitValue(AttributeType opType, int& mmAttr) const;
+
+       /**
+       * function to get the supported frame rate at each preview resolution.
+       *
+       * @return               Object
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[in]    dim                                             parameter to specify the preview resolution
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedPreviewFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, const Tizen::Graphics::Dimension &dim, _ResultType& itemType);
+
+private:
+       friend class _CameraCapabilitySafeHashMapT;
+
+       typedef struct
+       {
+               _CameraOperationType key;
+               _CameraDeviceType deviceType;
+               _CameraQueryFunc serviceRoutine;
+       }keyServiceMap;
+
+       /**
+       *       The constructor.
+       */
+       _CameraCapability(void);
+
+       /**
+       *       The destructor.
+       *       Resources are deallocated by this method.
+       */
+       ~_CameraCapability(void);
+
+       /**
+       * Initializes this instance of _CamcorderCoordinator.
+       *
+       * @return               An error code
+       * @param[in]    cameraDevice                    The camcorder device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       result Construct(_CameraDeviceType cameraDevice);
+
+       _CameraCapability(const _CameraCapability& rhs);
+       _CameraCapability& operator =(const _CameraCapability& rhs);
+
+       /**
+       * function to get the supported preview resolution
+       *
+       * @return       ArrayList object(Tizen::Graphics::Dimension)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedPreviewResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported capture resolution
+       *
+       * @return       ArrayList object(Tizen::Graphics::Dimension)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedCaptureResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported recorded resolution
+       *
+       * @return       ArrayList object(Tizen::Graphics::Dimension)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+
+       static Tizen::Base::Object* GetSupportedRecordingResolutionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported preview format
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedPreviewFormatN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported capture format
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedCaptureFormatN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported auto focus type
+       *
+       * @return       ArrayList object(Tizen::Graphics::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedFocusModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported effect type
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedEffectTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported frame rate
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedPreviewFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the maximum supported frame rate
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedMaxRecordingFrameRateN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported ISO level
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedIsoLevelN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported white balance
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedWhiteBalanceN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported shutter speed
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedShutterSpeedN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported scene type
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedSceneN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported metering
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedMeteringN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported aperture
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedApertureN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported zoom type
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedZoomTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported flip type
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedFlipTypeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported preview rotation type
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedPreviewRotationN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported capture mode
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetZeroShutterLagN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported zoom level values (min, max)
+       *
+       * @return       ArrayList object(Tizen::Base::Integer)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedZoomLevelN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the camera direction
+       *
+       * @return               (Tizen::Base::Integer) type object
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetDirectionN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the rotation value
+       *
+       * @return               (Tizen::Base::Integer) type object
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetPhysicalRotationN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported contrast
+       *
+       * @return               The object which contains the values
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedContrastN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported brightness
+       *
+       * @return               The object which contains the values
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedBrightnessN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported exposure
+       *
+       * @return               The object which contains the values
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedExposureN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported exposure mode
+       *
+       * @return               The object which contains the values
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedMeteringModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported flash
+       *
+       * @return               void* (IList*)
+       * @param[in]    camSel                                  camera type [primary/secondary]
+       * @param[in]    queryType                               Query of what property is requested
+       * @param[out]   itemType                                Item type of returned Object
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedFlashModeN(_CameraDeviceType deviceType, _QueryType queryType, _ResultType& itemType);
+
+       static bool SupportedCameraPreviewResolutionCb(int width, int height, void* pUserData);
+       static bool SupportedCameraCaptureResolutionCb(int width, int height, void* pUserData);
+       static bool SupportedCameraPreviewFormatCb(camera_pixel_format_e format, void *pUserData);
+       static bool SupportedCameraCaptureFormatCb(camera_pixel_format_e format, void *pUserData);
+       static bool SupportedCameraAttrFlashModeCb(camera_attr_flash_mode_e mode, void *pUserData);
+       static bool SupportedCameraAttrEffectCb(camera_attr_effect_mode_e effect, void *pUserData);
+       static bool SupportedCameraAttrFpsCb(camera_attr_fps_e fps, void *pUserData);
+       static bool SupportedCameraAttrIsoCb(camera_attr_iso_e iso, void *pUserData);
+       static bool SupportedCameraAttrWhitebalanceCb(camera_attr_whitebalance_e wb, void *pUserData);
+       static bool SupportedCameraAttrSceneModeCb(camera_attr_scene_mode_e mode, void *pUserData);
+       static bool SupportedCameraAttrMeteringModeCb(camera_attr_exposure_mode_e mode, void *pUserData);
+       static bool SupportedCameraAttrAfModeCb(camera_attr_af_mode_e mode, void *pUserData);
+
+       static void InitSafeHashMapInst(void);
+
+       static _CameraCapabilitySafeHashMapT* __pMap;
+       static const keyServiceMap __SERVICE_MAP[];
+
+       _CameraDeviceType __device;
+       _CameraHandle __handle;
+       int __initPreviewWidth;
+       int __initPreviewHeight;
+       int __initCaptureWidth;
+       int __initCaptureHeight;
+       camera_pixel_format_e __initPreviewFormat;
+       camera_pixel_format_e __initCaptureFormat;
+       camera_attr_flash_mode_e __initFlashMode;
+       camera_attr_effect_mode_e __initEffectMode;
+       camera_attr_fps_e __initFps;
+       camera_attr_iso_e __initIsoLevel;
+       camera_attr_whitebalance_e __initWb;
+       camera_attr_scene_mode_e __initSceneMode;
+       camera_attr_exposure_mode_e __initMeteringMode;
+       camera_attr_af_mode_e __initAfMode;
+};
+
+/**
+* @class       _CameraCapabilitySafeHashMapT
+* @brief       This class is for handling safe HashMap.
+*
+*/
+class _CameraCapabilitySafeHashMapT
+       : public Tizen::Base::Collection::HashMapT<_CameraDeviceType, _CameraCapability*>
+       , public virtual Tizen::Base::Collection::ICollectionT <Tizen::Base::Collection::MapEntryT <_CameraDeviceType, _CameraCapability*> >
+{
+public:
+       _CameraCapabilitySafeHashMapT(void);
+       virtual ~_CameraCapabilitySafeHashMapT(void);
+       void RemoveItems(void);
+
+private:
+       _CameraCapabilitySafeHashMapT(const _CameraCapabilitySafeHashMapT& rhs);
+       _CameraCapabilitySafeHashMapT& operator =(const _CameraCapabilitySafeHashMapT& rhs);
+};
+
+}}
+
+#endif
diff --git a/src/FMedia_CameraCapabilitySession.cpp b/src/FMedia_CameraCapabilitySession.cpp
new file mode 100755 (executable)
index 0000000..ec06e77
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraCapabilitySession.cpp
+ * @brief                      This file contains the implementation of the %_CameraCapabilitySession class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include "FMedia_CameraTypes.h"
+#include "FMedia_CameraCapability.h"
+#include "FMedia_CameraCapabilitySession.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+_CameraCapabilitySession::_CameraCapabilitySession(void)
+       : __cameraDevice(_CAMERA_DEVICE_NONE)
+       , __pCameraCapability(null)
+{
+}
+
+_CameraCapabilitySession::~_CameraCapabilitySession(void)
+{
+       _CameraCapability::Release(__cameraDevice);
+       SysLog(NID_MEDIA, "Capability handle released");
+}
+
+result
+_CameraCapabilitySession::Construct(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. camera device:%d", cameraDevice);
+
+       __pCameraCapability = _CameraCapability::AddInstance(cameraDevice);
+       SysTryCatch(NID_MEDIA, __pCameraCapability != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  __pCameraCapability instance must not be null.");
+
+       __cameraDevice = cameraDevice;
+       return r;
+CATCH:
+       return r;
+}
+
+_CameraCapability*
+_CameraCapabilitySession::GetCameraCapability(void)
+{
+       return __pCameraCapability;
+}
+
+}}// Tizen::Media
diff --git a/src/FMedia_CameraCapabilitySession.h b/src/FMedia_CameraCapabilitySession.h
new file mode 100755 (executable)
index 0000000..1b41e46
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraCapabilitySession.h
+ * @brief                      This header file contains the declarations of the %_CameraCapabilitySession class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_CAPABILITY_SESSION_H_
+#define _FMEDIA_INTERNAL_CAMERA_CAPABILITY_SESSION_H_
+
+#include <FBaseObject.h>
+#include "FMedia_CameraTypes.h"
+
+namespace Tizen { namespace Media
+{
+
+class _CameraCapability;
+
+/**
+* @class       _CameraCapabilitySession
+* @brief       This class is common for recorder session.
+*
+*/
+class _CameraCapabilitySession
+       : public Tizen::Base::Object
+{
+public:
+       _CameraCapabilitySession(void);
+       virtual ~_CameraCapabilitySession(void);
+
+       result Construct(_CameraDeviceType cameraDevice);
+       _CameraCapability* GetCameraCapability(void);
+
+private:
+       _CameraDeviceType __cameraDevice;
+       _CameraCapability* __pCameraCapability;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_CameraCoordinator.cpp b/src/FMedia_CameraCoordinator.cpp
new file mode 100755 (executable)
index 0000000..d2a3469
--- /dev/null
@@ -0,0 +1,1109 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraCoordinator.cpp
+ * @brief                      This file contains the implementation of the %FMedia_CameraCoordinator class.
+ *
+ */
+#include <FBaseSysLog.h>
+#include "FMedia_CameraManager.h"
+#include "FMedia_RecorderManager.h"
+#include "FMedia_CameraCoordinator.h"
+#include "FMedia_ICameraCoordinatorListener.h"
+#include "FMedia_CameraUtil.h"
+#include "FMedia_RecorderUtil.h"
+
+//#define _VIDEO_RECORDER_ROTATION_
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+static const int _ORIENTATION_FOR_RECORDING = 0x1;
+static const int _ORIENTATION_FOR_CAMERA = 0x1 << 1;
+
+typedef int (*_CameraFunc)(_CameraHandle mmHandle);
+
+typedef struct
+{
+       camera_state_e prevState;
+       camera_state_e postState;
+       _CameraFunc pFunc;
+}_CameraStateTransitTable;
+
+static const _CameraStateTransitTable _CAMERA_STATE_TRANSIT[] =
+{
+       {::CAMERA_STATE_CREATED, ::CAMERA_STATE_PREVIEW, camera_start_preview },
+       {::CAMERA_STATE_CAPTURED, ::CAMERA_STATE_PREVIEW, camera_start_preview },
+       {::CAMERA_STATE_CAPTURED, ::CAMERA_STATE_CREATED, camera_stop_preview },
+       {::CAMERA_STATE_PREVIEW, ::CAMERA_STATE_CREATED, camera_stop_preview },
+};
+
+typedef int (*_RecorderFunc)(_RecorderHandle mmHandle);
+
+typedef struct
+{
+       recorder_state_e prevState;
+       recorder_state_e postState;
+       _RecorderFunc pFunc;
+}_RecorderStateTransitTable;
+
+static const _RecorderStateTransitTable _RECORDER_STATE_TRANSIT[] =
+{
+       {::RECORDER_STATE_CREATED, ::RECORDER_STATE_READY, recorder_prepare },
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_RECORDING, recorder_start },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_PAUSED, recorder_pause },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, recorder_commit },
+//     {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, recorder_cancel },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_READY, recorder_commit },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_READY, recorder_cancel },
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_CREATED, recorder_unprepare },
+};
+
+_CameraCoordinatorSafeHashMapT* _CameraCoordinator::__pMap = null;
+
+_CameraCoordinatorSafeHashMapT::_CameraCoordinatorSafeHashMapT(void)
+{
+}
+
+_CameraCoordinatorSafeHashMapT::~_CameraCoordinatorSafeHashMapT(void)
+{
+       RemoveItems();
+       _CameraCoordinator::__pMap = null;
+}
+
+void
+_CameraCoordinatorSafeHashMapT::RemoveItems(void)
+{
+       IListT <_CameraDeviceType>* pList = null;
+       _CameraCoordinator* pCoordinator = null;
+       result r = E_SUCCESS;
+
+       pList = GetKeysN();
+       SysTryReturn(NID_MEDIA, pList != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
+       for (int i = 0; i < GetCount(); i++)
+       {
+               _CameraDeviceType deviceType = _CAMERA_DEVICE_NONE;
+               r = pList->GetAt(i, deviceType);
+               if (IsFailed(r) && deviceType == _CAMERA_DEVICE_NONE)
+               {
+                       continue;
+               }
+
+               r = GetValue(deviceType, pCoordinator);
+               if (IsFailed(r) && pCoordinator == null)
+               {
+                       continue;
+               }
+               delete pCoordinator;
+       }
+       pList->RemoveAll();
+       delete pList;
+       RemoveAll();
+}
+
+_CameraCoordinator::_CameraCoordinator()
+       : __cameraDevice(_CAMERA_DEVICE_NONE)
+       , __cameraHandle(MM_INVALID_HANDLE)
+       , __recorderHandle(MM_INVALID_HANDLE)
+       , __mode(_CAMERA_MODE_NONE)
+       , __pListenerList(null)
+       , __orientationFlag(0)
+       , __cameraOrientation(CAMERA_EXIF_ORIENTATION_TOP_LEFT)
+       , __recordingRotation(RECORDING_ROTATION_NONE)
+{
+}
+
+_CameraCoordinator::~_CameraCoordinator()
+{
+       if (__pListenerList != null)
+       {
+               __pListenerList->RemoveAll();
+               delete __pListenerList;
+       }
+
+       _CameraManager::Release(__cameraDevice);
+       SysLog(NID_MEDIA, "Camera manager released");
+}
+
+result
+_CameraCoordinator::Construct(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+       _CameraManager* pCameraManager = null;
+       SysLog(NID_MEDIA, "Enter. camera device:%d", cameraDevice);
+
+       pCameraManager = _CameraManager::AddInstance(cameraDevice);
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, pCameraManager !=null && r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __cameraHandle = pCameraManager->GetHandle();
+
+       __pListenerList = new (std::nothrow) LinkedListT <_ICameraCoordinatorListener*>();
+       SysTryCatch(NID_MEDIA, __pListenerList !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       __cameraDevice = cameraDevice;
+       __mode = _CAMERA_MODE_IMAGE;
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CameraCoordinator::AddRecorder(_RecorderDeviceType recorderDevice)
+{
+       result r = E_SUCCESS;
+       _RecorderManager* pRecorderManager = null;
+       SysLog(NID_MEDIA, "Enter. recorder device:%d", recorderDevice);
+
+       pRecorderManager = _RecorderManager::AddInstance(recorderDevice);
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, pRecorderManager !=null && r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __recorderHandle = pRecorderManager->GetHandle();               // new recorder handle
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+void
+_CameraCoordinator::RemoveRecorder(_RecorderDeviceType recorderDevice)
+{
+       SysLog(NID_MEDIA, "Enter. recorder device:%d", recorderDevice);
+       _RecorderManager::Release(recorderDevice);
+       __recorderHandle = MM_INVALID_HANDLE;
+       __orientationFlag = __orientationFlag & (~_ORIENTATION_FOR_RECORDING);
+}
+
+_CameraCoordinator*
+_CameraCoordinator::AddInstance(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+       bool out = false;
+       ClearLastResult();
+
+       static bool isMapConstructed = false;
+       static _CameraCoordinatorSafeHashMapT map;
+       _CameraCoordinator* pCoordinator = null;
+
+       SysTryReturn(NID_MEDIA, cameraDevice > _CAMERA_DEVICE_NONE && cameraDevice < _CAMERA_DEVICE_MAX,
+                               null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(camderDevice) is used. camderDevice:%d is wrong.", cameraDevice);
+
+       if (!isMapConstructed)
+       {
+               r = map.Construct();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               isMapConstructed = true;
+               __pMap = &map;
+       }
+
+       r = map.ContainsKey(cameraDevice, out);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (out)
+       {
+               r = map.GetValue(cameraDevice, pCoordinator);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS && pCoordinator != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else
+       {
+               pCoordinator = new (std::nothrow) _CameraCoordinator();
+               SysTryCatch(NID_MEDIA, pCoordinator !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+               r = pCoordinator->Construct(cameraDevice);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = map.Add(cameraDevice, pCoordinator);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       pCoordinator->AddRefCount();
+       return pCoordinator;
+
+CATCH:
+       if (pCoordinator != null)
+       {
+               delete pCoordinator;
+       }
+       return null;
+}
+
+_CameraCoordinator*
+_CameraCoordinator::AddInstance(_RecorderDeviceType recorderDevice)
+{
+       _CameraCoordinator* pCoordinator = null;
+       _CameraDeviceType cameraDevice = _CAMERA_DEVICE_NONE;
+       ClearLastResult();
+
+       switch (recorderDevice)
+       {
+       case _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA:
+               cameraDevice = _CAMERA_DEVICE_PRIMARY;
+               break;
+
+       case _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA:
+               cameraDevice = _CAMERA_DEVICE_SECONDARY;
+               break;
+
+       default:
+               break;
+       }
+
+       if (cameraDevice == _CAMERA_DEVICE_NONE)
+       {
+               SysLogException(NID_MEDIA, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(recorderDevice) is used. recorderDevice :%d is wrong.", recorderDevice);
+       }
+       else
+       {
+               pCoordinator = AddInstance(cameraDevice);
+               if (pCoordinator == null)
+               {
+                       SysLogException(NID_MEDIA, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The camera device(%d)'s coordinator is not available.", cameraDevice);
+               }
+       }
+       return pCoordinator;
+}
+
+void
+_CameraCoordinator::Release(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+
+       if (__pMap != null)
+       {
+               _CameraCoordinator* pCoordinator = null;
+               r = __pMap->GetValue(cameraDevice, pCoordinator);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               if (pCoordinator->ReleaseRefCount() == 0)
+               {
+                       delete pCoordinator;
+                       r = __pMap->Remove(cameraDevice);
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+}
+
+void
+_CameraCoordinator::Release(_RecorderDeviceType recorderDevice)
+{
+       if (__pMap != null)
+       {
+               _CameraDeviceType cameraDevice = _CAMERA_DEVICE_NONE;
+
+               switch (recorderDevice)
+               {
+               case _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA:
+                       cameraDevice = _CAMERA_DEVICE_PRIMARY;
+                       break;
+               case _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA:
+                       cameraDevice = _CAMERA_DEVICE_SECONDARY;
+                       break;
+               default:
+                       break;
+               }
+
+               Release(cameraDevice);
+       }
+}
+
+_CameraCoordinator*
+_CameraCoordinator::HasInstance(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+       _CameraCoordinator* pCoordinator = null;
+       bool out = false;
+       ClearLastResult();
+
+       SysTryReturn(NID_MEDIA, cameraDevice > _CAMERA_DEVICE_NONE && cameraDevice < _CAMERA_DEVICE_MAX,
+                               null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(camderDevice) is used. camderDevice:%d is wrong.", cameraDevice);
+       SysTryReturn(NID_MEDIA, __pMap != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] No coordinator was created.");
+
+       r = __pMap->ContainsKey(cameraDevice, out);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryCatch(NID_MEDIA, out == true, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Camera device(%d) was not created.", cameraDevice);
+
+       r = __pMap->GetValue(cameraDevice, pCoordinator);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS && pCoordinator != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pCoordinator;
+
+CATCH:
+       return null;
+}
+
+_CameraCoordinator*
+_CameraCoordinator::HasInstance(_RecorderDeviceType recorderDevice)
+{
+       _CameraCoordinator* pCoordinator = null;
+       _CameraDeviceType cameraDevice = _CAMERA_DEVICE_NONE;
+       ClearLastResult();
+
+       switch (recorderDevice)
+       {
+       case _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA:
+               cameraDevice = _CAMERA_DEVICE_PRIMARY;
+               break;
+
+       case _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA:
+               cameraDevice = _CAMERA_DEVICE_SECONDARY;
+               break;
+
+       default:
+               break;
+       }
+
+       if (cameraDevice == _CAMERA_DEVICE_NONE)
+       {
+               SysLogException(NID_MEDIA, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(recorderDevice) is used. recorderDevice :%d is wrong.", recorderDevice);
+       }
+       else
+       {
+               pCoordinator = HasInstance(cameraDevice);
+               if (pCoordinator == null)
+               {
+                       SysLogException(NID_MEDIA, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The camera device(%d)'s coordinator is not available.", cameraDevice);
+               }
+       }
+       return pCoordinator;
+}
+
+result
+_CameraCoordinator::AddCameraCoordinatorListener(_ICameraCoordinatorListener& listener)
+{
+       result r = E_SUCCESS;
+       r = __pListenerList->Add(&listener);
+       return r;
+}
+
+result
+_CameraCoordinator::RemoveCameraCoordinatorListener(_ICameraCoordinatorListener& listener)
+{
+       result r = E_SUCCESS;
+       r = __pListenerList->Remove(&listener);
+       return r;
+}
+
+_CameraMode
+_CameraCoordinator::GetMode(void) const
+{
+       return __mode;
+}
+
+_CameraHandle
+_CameraCoordinator::GetCameraHandle(void) const
+{
+       return __cameraHandle;
+}
+
+_RecorderHandle
+_CameraCoordinator::GetRecorderHandle(void) const
+{
+       return __recorderHandle;
+}
+
+result
+_CameraCoordinator::NotifyModeChangePrepared(_CameraMode mode)
+{
+       result r = E_SUCCESS;
+       IEnumeratorT <_ICameraCoordinatorListener*>* pEnum = null;
+       _ICameraCoordinatorListener* pListener = null;
+       SysLog(NID_MEDIA, "mode:%d", mode);
+
+       pEnum = __pListenerList->GetEnumeratorN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, pEnum != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               r = pEnum->GetCurrent(pListener);
+               SysTryCatch(NID_MEDIA, pListener != null && r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                                  "[E_SYSTEM] A system error has been occurred.  The listener is not proper");
+
+               r = pListener->OnCameraCoordinatorModeChangePrepared(mode);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       delete pEnum;
+       return r;
+
+CATCH:
+       if (pEnum != null)
+       {
+               delete pEnum;
+               pEnum = null;
+       }
+       return r;
+}
+
+result
+_CameraCoordinator::NotifyModeChanged(_CameraMode mode)
+{
+       result r = E_SUCCESS;
+       IEnumeratorT <_ICameraCoordinatorListener*>* pEnum = null;
+       _ICameraCoordinatorListener* pListener = null;
+       SysLog(NID_MEDIA, "mode:%d", mode);
+
+       pEnum = __pListenerList->GetEnumeratorN();
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, pEnum != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               r = pEnum->GetCurrent(pListener);
+               SysTryCatch(NID_MEDIA, pListener != null && r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                                  "[E_SYSTEM] A system error has been occurred.  The listener is not proper");
+
+               r = pListener->OnCameraCoordinatorModeChanged(mode);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       delete pEnum;
+       return r;
+
+CATCH:
+       if (pEnum != null)
+       {
+               delete pEnum;
+               pEnum = null;
+       }
+       return r;
+}
+
+result
+_CameraCoordinator::StartMmPreview(void)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. mode:%d", __mode);
+
+       switch (__mode)
+       {
+       case _CAMERA_MODE_IMAGE:
+               r = ChangeCameraStateTo(::CAMERA_STATE_PREVIEW);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+
+       case _CAMERA_MODE_VIDEO:
+               r = ChangeRecorderStateTo(::RECORDER_STATE_READY);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camcorder mode :%d is wrong", __mode);
+               goto CATCH;
+               break;
+       }
+
+CATCH:
+       return r;
+}
+
+result
+_CameraCoordinator::StopMmPreview(void)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Enter.");
+
+       if (__mode == _CAMERA_MODE_IMAGE)
+       {
+               r = ChangeCameraStateTo(::CAMERA_STATE_CREATED);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else if (__mode == _CAMERA_MODE_VIDEO)
+       {
+               recorder_state_e recorderState = ::RECORDER_STATE_NONE;
+               recorderState = GetRecorderState();
+
+               switch (recorderState)
+               {
+               case ::RECORDER_STATE_RECORDING:
+                       r = ChangeRecorderStateTo(::RECORDER_STATE_READY);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       r = ChangeRecorderStateTo(::RECORDER_STATE_CREATED);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       break;
+
+               case ::RECORDER_STATE_READY:
+                       r = ChangeRecorderStateTo(::RECORDER_STATE_CREATED);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       break;
+
+               default:
+                       r = E_INVALID_STATE;
+                       SysLogException(NID_MEDIA, E_INVALID_STATE, "[E_INVALID_STATE] recorderState is in an invalid state. recorderState:%d", recorderState);
+                       break;
+               }
+       }
+       else
+       {
+               r = E_INVALID_STATE;
+               SysLogException(NID_MEDIA, E_INVALID_STATE, "[E_INVALID_STATE] CamcorderMode is in an invalid state. mode :%d", __mode);
+       }
+
+CATCH:
+       return r;
+}
+
+result
+_CameraCoordinator::ChangeMode(_CameraMode mode, bool callback)
+{
+       result r = E_SUCCESS;
+       camera_state_e cameraState = ::CAMERA_STATE_NONE;
+       recorder_state_e recorderState = ::RECORDER_STATE_NONE;
+       _RecorderDeviceType recorderDevice = _RECORDER_DEVICE_NONE;
+       int err = MM_SUCCESS;
+
+       SysLog(NID_MEDIA, "Mode should be changed. mode:%d", mode);
+       if (mode == _CAMERA_MODE_VIDEO)
+       {
+               cameraState = GetCameraState();
+
+               switch (cameraState)
+               {
+               case ::CAMERA_STATE_CREATED:
+                       //fall through
+               case ::CAMERA_STATE_NONE:
+                       break;
+
+               case ::CAMERA_STATE_PREVIEW:
+                       //fall through
+               case ::CAMERA_STATE_CAPTURED:
+                       r = ChangeCameraStateTo(::CAMERA_STATE_CREATED);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       break;
+
+               case ::CAMERA_STATE_CAPTURING:
+                       r = E_INVALID_STATE;
+                       SysLogException(NID_MEDIA, r, "[E_INVALID_STATE] cameraState(%d) is in an invalid state. While the camera is capturing, the mode cannot be changed.", cameraState);
+                       goto CATCH;
+                       break;
+
+               default:
+                       break;
+               }
+
+               // Start recorder
+               if ( __recorderHandle == MM_INVALID_HANDLE )
+               {
+                       recorderDevice = __cameraDevice == _CAMERA_DEVICE_PRIMARY ?
+                               _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA;
+                       r = AddRecorder(recorderDevice);                // recorder_create() will be called.
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       __mode = _CAMERA_MODE_VIDEO;
+               }
+
+               if (callback)
+               {
+                       r = NotifyModeChangePrepared(mode);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               switch (cameraState)
+               {
+               case ::CAMERA_STATE_NONE:
+                       //fall through
+               case ::CAMERA_STATE_CREATED:
+                       break;
+
+               case ::CAMERA_STATE_PREVIEW:
+                       r = ChangeRecorderStateTo(::RECORDER_STATE_READY);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       break;
+
+               case ::CAMERA_STATE_CAPTURED:
+               default:
+                       break;
+               }
+       }
+       else if ( mode == _CAMERA_MODE_IMAGE )
+       {
+               recorderState = GetRecorderState();
+
+               // Stop the recorder
+               switch (recorderState)
+               {
+               case ::RECORDER_STATE_NONE:
+                       break;
+
+               case ::RECORDER_STATE_CREATED:
+                       recorderDevice = __cameraDevice == _CAMERA_DEVICE_PRIMARY ?
+                               _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA;
+                       RemoveRecorder(recorderDevice);         // the mode will be changed to IMAGE.
+                       __mode = _CAMERA_MODE_IMAGE;
+                       break;
+
+               case ::RECORDER_STATE_READY:
+                       r = ChangeRecorderStateTo(::RECORDER_STATE_CREATED);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       recorderDevice = __cameraDevice == _CAMERA_DEVICE_PRIMARY ?
+                               _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA;
+                       RemoveRecorder(recorderDevice);
+                       __mode = _CAMERA_MODE_IMAGE;
+                       if (callback)
+                       {
+                               r = NotifyModeChangePrepared(mode);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+                       r = ChangeCameraStateTo(::CAMERA_STATE_PREVIEW);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       break;
+
+               case ::RECORDER_STATE_RECORDING:
+                       //fall through
+               case ::RECORDER_STATE_PAUSED:
+                       err = recorder_cancel(__recorderHandle);                // TODO
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       r = ChangeRecorderStateTo(::RECORDER_STATE_CREATED);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       recorderDevice = __cameraDevice == _CAMERA_DEVICE_PRIMARY ?
+                               _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA;
+
+                       RemoveRecorder(recorderDevice);
+                       __mode = _CAMERA_MODE_IMAGE;
+                       if (callback)
+                       {
+                               r = NotifyModeChangePrepared(mode);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+                       r = ChangeCameraStateTo(::CAMERA_STATE_PREVIEW);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       if (callback)
+       {
+               // Notify that the mode is changed to callback camera and video recorder's configurations.
+               r = NotifyModeChanged(mode);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+bool
+_CameraCoordinator::IsCalmChangeMode(_CameraMode mode)
+{
+       camera_state_e cameraState = ::CAMERA_STATE_NONE;
+       recorder_state_e recorderState = ::RECORDER_STATE_NONE;
+       bool calmChange = false;
+
+       if (mode == _CAMERA_MODE_VIDEO)
+       {
+               cameraState = GetCameraState();
+
+               switch (cameraState)
+               {
+               case ::CAMERA_STATE_CREATED:
+                       //fall through
+               case ::CAMERA_STATE_NONE:
+                       calmChange = true;
+                       break;
+
+               case ::CAMERA_STATE_PREVIEW:
+                       //fall through
+               case ::CAMERA_STATE_CAPTURED:
+                       //fall through
+               case ::CAMERA_STATE_CAPTURING:
+                       calmChange = false;
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       else if ( mode == _CAMERA_MODE_IMAGE )
+       {
+               recorderState = GetRecorderState();
+
+               // Stop the recorder
+               switch (recorderState)
+               {
+               case ::RECORDER_STATE_NONE:
+                       //fall through
+               case ::RECORDER_STATE_CREATED:
+                       calmChange = true;
+                       break;
+
+               case ::RECORDER_STATE_READY:
+                       //fall through
+               case ::RECORDER_STATE_RECORDING:
+                       //fall through
+               case ::RECORDER_STATE_PAUSED:
+                       calmChange = false;
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       SysLog(NID_MEDIA, "mode:%d, calm:%d", mode, calmChange);
+       return calmChange;
+}
+
+
+_CameraDeviceType
+_CameraCoordinator::GetCameraDevice(void) const
+{
+       return __cameraDevice;
+}
+
+camera_state_e
+_CameraCoordinator::GetCameraState(void) const
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       camera_state_e state = ::CAMERA_STATE_NONE;
+
+       err = camera_get_state(__cameraHandle, &state);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return state;
+
+CATCH:
+       return ::CAMERA_STATE_NONE;
+}
+
+recorder_state_e
+_CameraCoordinator::GetRecorderState(void) const
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       recorder_state_e state = ::RECORDER_STATE_NONE;
+
+       err = recorder_get_state(__recorderHandle, &state);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return state;
+
+CATCH:
+       return ::RECORDER_STATE_NONE;
+}
+
+result
+_CameraCoordinator::ConvertResult(int err) const
+{
+       result r = E_SYSTEM;
+       if (err != CAMERA_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "MM Err:0x%x", err);
+       }
+
+       // Global error
+       if (err == CAMERA_ERROR_NONE || err == RECORDER_ERROR_NONE)
+       {
+               r = E_SUCCESS;
+       }
+       else if (err == CAMERA_ERROR_INVALID_PARAMETER || err == RECORDER_ERROR_INVALID_PARAMETER)
+       {
+               r = E_INVALID_ARG;
+       }
+       else if (err == CAMERA_ERROR_INVALID_STATE || err == RECORDER_ERROR_INVALID_STATE)
+       {
+               r = E_INVALID_STATE;
+       }
+       else if (err == CAMERA_ERROR_OUT_OF_MEMORY || err == RECORDER_ERROR_OUT_OF_MEMORY)
+       {
+               r = E_OUT_OF_MEMORY;
+       }
+       else if (err == CAMERA_ERROR_DEVICE || err == RECORDER_ERROR_DEVICE)
+       {
+               r = E_DEVICE_FAILED;
+       }
+       else if (err == CAMERA_ERROR_INVALID_OPERATION
+                       || err == CAMERA_ERROR_SECURITY_RESTRICTED
+                       || err == RECORDER_ERROR_INVALID_OPERATION
+                       || err == RECORDER_ERROR_SECURITY_RESTRICTED)
+       {
+               r = E_SYSTEM;
+       }
+       else if (err == CAMERA_ERROR_DEVICE_BUSY
+                       || err == CAMERA_ERROR_SOUND_POLICY
+                       || err == RECORDER_ERROR_SOUND_POLICY)
+       {
+               r = E_DEVICE_BUSY;
+       }
+       else if (err == CAMERA_ERROR_DEVICE_NOT_FOUND)
+       {
+               r = E_DEVICE_UNAVAILABLE;
+       }
+       else
+       {
+               r = E_UNKNOWN;
+       }
+
+       return r;
+}
+
+
+result
+_CameraCoordinator::ChangeCameraStateTo(camera_state_e destState)
+{
+       result r = E_SUCCESS;
+       int tableTotalCount = 0;
+       int i = 0;
+       int err = MM_SUCCESS;
+       camera_state_e preState = ::CAMERA_STATE_NONE;
+       camera_state_e postState = ::CAMERA_STATE_NONE;
+
+       preState = GetCameraState();
+       tableTotalCount = sizeof(_CAMERA_STATE_TRANSIT) / sizeof(_CAMERA_STATE_TRANSIT[0]);
+       SysLog(NID_MEDIA, " PreState:%d, destState:%d, tableTotalCount:%d", preState, destState, tableTotalCount);
+
+       for (i = 0; i < tableTotalCount; i++)
+       {
+               if (preState == _CAMERA_STATE_TRANSIT[i].prevState && destState == _CAMERA_STATE_TRANSIT[i].postState)
+               {
+                       if (_CAMERA_STATE_TRANSIT[i].pFunc != null)
+                       {
+                               SysLog(NID_MEDIA,
+                                                       "Exist the matching state field. loop i:%d, current state:%d, destState:%d", i,
+                                                       preState, destState);
+                               err = _CAMERA_STATE_TRANSIT[i].pFunc(__cameraHandle);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
+
+                               // Check whether the retuned states are destinationed states.
+                               postState = GetCameraState();
+                               SysTryCatch(NID_MEDIA, destState == postState, r = E_INVALID_STATE, E_INVALID_STATE,
+                                                  "[E_INVALID_STATE] camera_state_e of C-API is in an invalid state. result preState:%d, is different from the desired state:%d", postState,
+                                                  destState);
+                               SysLog(NID_MEDIA, "[E_SUCCESS] Found. result postState:%d, param destState:%d", postState,
+                                                       destState);
+                       }
+                       break;
+               }
+
+       }
+       SysTryCatch(NID_MEDIA, i != tableTotalCount, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Not found. ");
+       return r;
+
+CATCH:
+       SysLog(NID_MEDIA, "[%s] Real preState:%d, param destState:%d", GetErrorMessage(r), preState, destState);
+       return r;
+}
+
+result
+_CameraCoordinator::ChangeRecorderStateTo(recorder_state_e destState)
+{
+       result r = E_SUCCESS;
+       int tableTotalCount = 0;
+       int i = 0;
+       int err = MM_SUCCESS;
+       recorder_state_e preState = ::RECORDER_STATE_NONE;
+       recorder_state_e postState = ::RECORDER_STATE_NONE;
+
+       preState = GetRecorderState();
+       tableTotalCount = sizeof(_RECORDER_STATE_TRANSIT) / sizeof(_RECORDER_STATE_TRANSIT[0]);
+       SysLog(NID_MEDIA, " PreState:%d, destState:%d, tableTotalCount:%d", preState, destState, tableTotalCount);
+
+       for (i = 0; i < tableTotalCount; i++)
+       {
+               if (preState == _RECORDER_STATE_TRANSIT[i].prevState && destState == _RECORDER_STATE_TRANSIT[i].postState)
+               {
+                       if (_RECORDER_STATE_TRANSIT[i].pFunc != null)
+                       {
+                               SysLog(NID_MEDIA,
+                                                       "Exist the matching state field. loop i:%d, current state:%d, destState:%d", i,
+                                                       preState, destState);
+                               err = _RECORDER_STATE_TRANSIT[i].pFunc(__recorderHandle);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
+
+                               // Check whether the retuned states are destinationed states.
+                               postState = GetRecorderState();
+                               SysTryCatch(NID_MEDIA, destState == postState, r = E_INVALID_STATE, E_INVALID_STATE,
+                                                  "[E_INVALID_STATE] recorder_state_e of C-API is in an invalid state. result preState:%d, is different from the desired state:%d", postState,
+                                                  destState);
+                               SysLog(NID_MEDIA, "[E_SUCCESS] Found. result preState:%d, param destState:%d", postState,
+                                                       destState);
+                       }
+                       break;
+               }
+
+       }
+       SysTryCatch(NID_MEDIA, i != tableTotalCount, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Not found. ");
+       return r;
+
+CATCH:
+       SysLog(NID_MEDIA, "[%s] Real preState:%d, param destState:%d", GetErrorMessage(r), preState, destState);
+       return r;
+}
+
+result
+_CameraCoordinator::SetCameraSourceFormat(camera_pixel_format_e pixelFormat)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Camera_pixel_format_e is :%d", pixelFormat);
+
+       err = camera_set_preview_format(__cameraHandle, pixelFormat);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating, pixelFormat:%d", GetErrorMessage(r), pixelFormat);
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+camera_pixel_format_e
+_CameraCoordinator::GetCameraSourceFormat(void) const
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       camera_pixel_format_e pixelFormat = CAMERA_PIXEL_FORMAT_INVALID;
+
+       err = camera_get_preview_format(__cameraHandle, &pixelFormat);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+
+       return pixelFormat;
+
+CATCH:
+       return pixelFormat;
+}
+
+result
+_CameraCoordinator::StartCapture(camera_capturing_cb capturingCb , camera_capture_completed_cb completedCb , void *pUserData)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       if (__orientationFlag & _ORIENTATION_FOR_CAMERA)
+       {
+               r = SetCameraOrientationAttr(__cameraOrientation);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else if (__orientationFlag & _ORIENTATION_FOR_RECORDING)        // If recorder setting is remained.
+       {
+               r = SetCameraOrientationAttr(CAMERA_EXIF_ORIENTATION_TOP_LEFT); // To set the init value
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       err = camera_start_capture(__cameraHandle, capturingCb, completedCb, pUserData);
+       r = ConvertResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Camera capture failed.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+_CameraCoordinator::StartRecord(void)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       if (__orientationFlag & _ORIENTATION_FOR_RECORDING)
+       {
+               r = SetRecordingOrientationAttr(__recordingRotation);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else if (__orientationFlag & _ORIENTATION_FOR_CAMERA)   // If recorder setting is remained.
+       {
+               r = SetRecordingOrientationAttr(RECORDING_ROTATION_NONE);       // To set the init value
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       err = recorder_start(__recorderHandle);
+       r = ConvertResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Recorder record failed.", GetErrorMessage(r));
+
+       return r;
+}
+
+void
+_CameraCoordinator::SetRecordingOrientation(RecordingRotation rotation)
+{
+       __orientationFlag = __orientationFlag | _ORIENTATION_FOR_RECORDING;
+       __recordingRotation = rotation;
+}
+
+void
+_CameraCoordinator::SetCameraOrientation(CameraExifOrientation orientation)
+{
+       __orientationFlag = __orientationFlag | _ORIENTATION_FOR_CAMERA;
+       __cameraOrientation = orientation;
+}
+
+result
+_CameraCoordinator::SetRecordingOrientationAttr(RecordingRotation rotation)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+#if _VIDEO_RECORDER_ROTATION_
+       recorder_rotation_e mmAttr = ::RECORDER_ROTATION_NONE;
+       r = _RecorderUtil::GetMmRotation(rotation, mmAttr);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), rotation);
+
+       err = recorder_attr_set_recording_orientation(__recorderHandle, mmAttr);
+       r = ConvertResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Camcorder set attribute failed. rotation:%d", GetErrorMessage(r), rotation);
+#else
+       CameraRotation cameraRotation = CAMERA_ROTATION_NONE;
+       r = _RecorderUtil::GetCameraRotation(rotation, cameraRotation);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), rotation);
+
+       camera_attr_tag_orientation_e mmOrientationAttr = CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT;
+       r = _CameraUtil::GetMmExifOrientation(cameraRotation, mmOrientationAttr);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), rotation);
+
+       err = camera_attr_set_tag_orientation(__cameraHandle, mmOrientationAttr);
+       r = ConvertResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Camcorder set attribute failed. Mm orientation:%d", GetErrorMessage(r), mmOrientationAttr);
+#endif
+
+       return r;
+}
+
+result
+_CameraCoordinator::SetCameraOrientationAttr(CameraExifOrientation orientation)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       camera_attr_tag_orientation_e attr = ::CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT;
+
+       r = _CameraUtil::GetMmExifOrientation(orientation, attr);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. orientation:%d", GetErrorMessage(r), orientation);
+
+       err = camera_attr_set_tag_orientation(__cameraHandle, attr);
+       r = ConvertResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. orientation:%d", GetErrorMessage(r), orientation);
+
+       return r;
+}
+
+}}
diff --git a/src/FMedia_CameraCoordinator.h b/src/FMedia_CameraCoordinator.h
new file mode 100755 (executable)
index 0000000..e0a52fa
--- /dev/null
@@ -0,0 +1,428 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraCoordinator.h
+ * @brief                      This header file contains the declarations of the %_CameraCoordinator class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_COORDINATOR_H_
+#define _FMEDIA_INTERNAL_CAMERA_COORDINATOR_H_
+
+#include <camera.h>
+#include <recorder.h>
+#include <FBaseColLinkedListT.h>
+#include <FBaseColHashMapT.h>
+#include <FMediaCameraTypes.h>
+#include <FMediaRecorderTypes.h>
+#include "FMedia_CameraTypes.h"
+#include "FMedia_RecorderTypes.h"
+#include "FMedia_CameraRefHelper.h"
+
+namespace Tizen { namespace Media
+{
+class _ICameraCoordinatorListener;
+class _CameraCoordinatorSafeHashMapT;
+
+/**
+ * @class      _CameraCoordinator
+ * @brief      This class implements the _CameraCoordinator class.
+ *
+ */
+class _CameraCoordinator
+       : public _CameraRefHelper
+{
+public:
+       /**
+       * Get the instance of _CameraCoordinator.
+       *
+       * @return               The _CameraCoordinator instance
+       * @param[in]    cameraDevice                    The camera device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       static _CameraCoordinator* AddInstance(_CameraDeviceType cameraDevice);
+
+       /**
+       * Get the instance of _CameraCoordinator.
+       *
+       * @return               The _CameraCoordinator instance
+       * @param[in]    recorderDevice                  The recorder device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       static _CameraCoordinator* AddInstance(_RecorderDeviceType recorderDevice);
+
+       /**
+       * Release the specific _CameraCoordinator.
+       *
+       * @param[in]    cameraDevice                    The camera device type
+       */
+       static void Release(_CameraDeviceType cameraDevice);
+
+       /**
+       * Release the specific _CameraCoordinator.
+       *
+       * @param[in]    recorderDevice                  The recorder device type
+       */
+       static void Release(_RecorderDeviceType recorderDevice);
+
+       /**
+       * Check whether it has the instance.
+       *
+       * @return               The _CameraCoordinator instance
+       * @param[in]    cameraDevice                    The camera device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       static _CameraCoordinator* HasInstance(_CameraDeviceType cameraDevice);
+
+       /**
+       * Check whether it has the instance.
+       *
+       * @return               The _CameraCoordinator instance
+       * @param[in]    recorderDevice                  The recorder device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       static _CameraCoordinator* HasInstance(_RecorderDeviceType recorderDevice);
+
+       /**
+       * Adds the listener to this object. @n
+       * Added listeners are called after this object's callbacks are called from the camera.
+       *
+       * @return               An error code
+       * @param[in]    listener                                        A listener instance
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       result AddCameraCoordinatorListener(_ICameraCoordinatorListener& listener);
+
+       /**
+       * Removes the listener from this object. @n
+       *
+       * @return               An error code
+       * @param[in]    listener                                        A listener instance
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       result RemoveCameraCoordinatorListener(_ICameraCoordinatorListener& listener);
+
+       /**
+       * Gets the mode.
+       *
+       * @return                  The camera mode
+       */
+       _CameraMode GetMode(void) const;
+
+       /**
+       * Gets the camera device selection.
+       *
+       * @return                  The camera device selection
+       */
+       _CameraDeviceType GetCameraDevice(void) const;
+
+       /**
+       * Gets the camera handle
+       *
+       * @return                  The camera handle
+       */
+       _CameraHandle GetCameraHandle(void) const;
+
+       /**
+       * Gets the recorder handle
+       *
+       * @return                  The recorder handle
+       */
+       _RecorderHandle GetRecorderHandle(void) const;
+
+       /**
+       * Notifies the mode changing status to _ICameraCoordinatorListener
+       *
+       * @return               An error code
+       * @param[in]    mode                    camera mode
+       * @remarks      This mtehod calls _ICameraCoordinatorListener::::OnCameraCoordinatorModeChangePrepared().
+       *                       This method will call every _ICameraCoordinatorListener which are registered to _CameraCoordinator.
+       */
+       result NotifyModeChangePrepared(_CameraMode mode);
+
+       /**
+       * Notifies the mode changed status to _ICameraCoordinatorListener
+       *
+       * @return               An error code
+       * @param[in]    mode                    camera mode
+       * @remarks      This mtehod calls _ICameraCoordinatorListener::::OnCameraCoordinatorModeChanged().
+       *                       This method will call every _ICameraCoordinatorListener which are registered to _CameraCoordinator.
+       */
+       result NotifyModeChanged(_CameraMode mode);
+
+       /**
+       * Start the preview.
+       *
+       * @return               An error code
+       * @param[in]    mode                                            The mode to set
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       */
+       result StartMmPreview(void);
+
+       /**
+       * Stop the preview.
+       *
+       * @return               An error code
+       * @param[in]    mode                                            The mode to set
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       */
+       result StopMmPreview(void);
+
+       /**
+       * Changes the camcorder mode.
+       *
+       * @return               An error code
+       * @param[in]    mode                                            The mode to set
+       * @param[in]    callback                                                The flag to call the callback
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       */
+       result ChangeMode(_CameraMode mode, bool callback);
+
+       /**
+       * Check if the change mode can be calmly.
+       *
+       * @return               The flag of calm change mode
+       * @param[in]    mode                                            The mode to set
+       */
+       bool IsCalmChangeMode(_CameraMode mode);
+
+       /**
+       * Set source format.
+       *
+       * @return          An error code
+       * @param[in]    pixelFormat                      camera's preview format
+       */
+       result SetCameraSourceFormat(camera_pixel_format_e pixelFormat);
+
+       /**
+       * Get source format.
+       *
+       * @return          camera's preview format
+       */
+       camera_pixel_format_e GetCameraSourceFormat(void) const;
+
+       /**
+       * Captures the current image data from the camera sensor.
+       *
+       * @return               An error code
+       * @param[in]    capturingCb                                     The capture callback
+       * @param[in]    completedCb                             The capture completed callback
+       * @param[in]    pUserData                                       The user data
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       */
+       result StartCapture(camera_capturing_cb capturingCb , camera_capture_completed_cb completedCb , void *pUserData);
+
+       /**
+       * Start recording.
+       *
+       * @return               An error code
+       */
+       result StartRecord(void);
+
+       /**
+       * Sets the orientation of the recorder.
+       *
+       * @return               An error code
+       */
+       void SetRecordingOrientation(RecordingRotation rotation);
+
+       /**
+       * Sets the orientation of the camera.
+       *
+       * @return               An error code
+       */
+       void SetCameraOrientation(CameraExifOrientation orientation);
+
+private:
+       friend class _CameraCoordinatorSafeHashMapT;
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
+        * initialize this instance.
+        * @see                 Construct()
+        */
+       _CameraCoordinator(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread
+        * where the Construct() method is called.
+        *
+        * @see                 Construct()
+        */
+       virtual ~_CameraCoordinator(void);
+
+       /**
+       * Initializes this instance of _CameraCoordinator.
+       *
+       * @return               An error code
+       * @param[in]    cameraDevice                    The camera device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       result Construct(_CameraDeviceType cameraDevice);
+
+       /**
+       * Add the recorder
+       *
+       * @return               An error code
+       * @param[in]    recorderDevice                  The recorder device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       result AddRecorder(_RecorderDeviceType recorderDevice);
+
+       /**
+       * Remove the recorder
+       *
+       * @param[in]    recorderDevice                  The recorder device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       void RemoveRecorder(_RecorderDeviceType recorderDevice);
+
+       /**
+       * Converts the error from camera to Result.
+       *
+       * @return          An error code
+       * @param[in]    err                      camera error
+       */
+       result ConvertResult(int err) const;
+
+       /**
+       * Change the state.
+       *
+       * @return          An error code
+       * @param[in]    destState                        camera's destinationed state
+       * @remarks      This method makes the camera's state change. @n
+       *                       Acccording to this, Camera's state is changed.
+       */
+       result ChangeCameraStateTo(camera_state_e destState);
+
+       /**
+       * Gets the camera's state.
+       *
+       * @return                  The state
+       */
+       camera_state_e GetCameraState(void) const;
+
+       /**
+       * Gets the recorder's state.
+       *
+       * @return                  The state
+       */
+       recorder_state_e GetRecorderState(void) const;
+
+       /**
+       * Change the state.
+       *
+       * @return          An error code
+       * @param[in]    destState                        recorder's destinationed state
+       * @remarks      This method makes the camera's state change. @n
+       *                       acccording to this, VideoRecorder and AudioRecorder's state is changed.
+       */
+       result ChangeRecorderStateTo(recorder_state_e destState);
+
+       /**
+       * Sets the orientation of the recorder.
+       *
+       * @return               An error code
+       * @param[in]    rotation                        The rotation of the recorder
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
+       * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
+       */
+       result SetRecordingOrientationAttr(RecordingRotation rotation);
+
+       /**
+       * Sets the orientation of the camera.
+       *
+       * @return               An error code
+       * @param[in]    orientation                     The orientation of the camera
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
+       * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
+       */
+       result SetCameraOrientationAttr(CameraExifOrientation orientation);
+
+       _CameraCoordinator(const _CameraCoordinator& rhs);
+       _CameraCoordinator& operator =(const _CameraCoordinator& rhs);
+
+       _CameraDeviceType __cameraDevice;
+       _CameraHandle __cameraHandle;
+       _RecorderHandle __recorderHandle;
+       _CameraMode __mode;
+       Tizen::Base::Collection::LinkedListT <_ICameraCoordinatorListener*>* __pListenerList;
+       int __orientationFlag;
+       CameraExifOrientation __cameraOrientation;
+       RecordingRotation __recordingRotation;
+
+       static _CameraCoordinatorSafeHashMapT* __pMap;
+};
+
+/**
+* @class       _CameraCoordinatorSafeHashMapT
+* @brief       This class is for handling safe HashMap.
+*
+*/
+class _CameraCoordinatorSafeHashMapT
+       : public Tizen::Base::Collection::HashMapT<_CameraDeviceType, _CameraCoordinator*>
+       , public virtual Tizen::Base::Collection::ICollectionT <Tizen::Base::Collection::MapEntryT <_CameraDeviceType, _CameraCoordinator*> >
+{
+public:
+       _CameraCoordinatorSafeHashMapT(void);
+       virtual ~_CameraCoordinatorSafeHashMapT(void);
+       void RemoveItems(void);
+
+private:
+       _CameraCoordinatorSafeHashMapT(const _CameraCoordinatorSafeHashMapT& rhs);
+       _CameraCoordinatorSafeHashMapT& operator =(const _CameraCoordinatorSafeHashMapT& rhs);
+};
+
+}}
+#endif
diff --git a/src/FMedia_CameraEvent.cpp b/src/FMedia_CameraEvent.cpp
new file mode 100755 (executable)
index 0000000..7f35cd3
--- /dev/null
@@ -0,0 +1,200 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraEvent.cpp
+ * @brief                      This file contains the event processing for Camera
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include <FMediaICameraEventListener.h>
+#include "FMedia_CameraImpl.h"
+#include "FMedia_CameraEvent.h"
+#include "FMedia_CameraCoordinator.h"
+#include "FMedia_CameraUtil.h"
+#include "FMedia_ImageUtil.h"
+#include "FMedia_ColorConverter.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media
+{
+
+_CameraEvent::_CameraEvent(void)
+       : __pCameraImpl(null)
+{
+
+}
+
+_CameraEvent::~_CameraEvent(void)
+{
+
+}
+
+result
+_CameraEvent::Construct(_CameraImpl& cameraImpl)
+{
+       result r = E_SUCCESS;
+
+       __pCameraImpl = &cameraImpl;
+       r = _Event::Initialize();
+       return r;
+}
+
+result
+_CameraEvent::SendEvent(_CameraEventType event, CameraErrorReason err, result res, const ByteBuffer* pByteBuffer)
+{
+       result r = E_SUCCESS;
+       std::unique_ptr <_CameraEventArg> pCameraEventArg (new (std::nothrow) _CameraEventArg());
+       SysTryReturn(NID_MEDIA, pCameraEventArg.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pCameraEventArg->SetEventType(event);
+       pCameraEventArg->SetResult(res);
+       pCameraEventArg->SetError(err);
+       pCameraEventArg->SetData(pByteBuffer);
+       r = FireAsync(*(pCameraEventArg.get()));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       // In case of success, event argument should be released for Base::Event to use the argument continuously.
+       pCameraEventArg.release();
+       return r;
+}
+
+void
+_CameraEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       ICameraEventListener* pCameraEventListener = dynamic_cast <ICameraEventListener*>(&listener);
+       SysTryReturn(NID_MEDIA, pCameraEventListener != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
+
+       Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <Tizen::Base::Runtime::IEventArg*>(&arg);
+       _CameraEventArg* pArg = dynamic_cast <_CameraEventArg*>(pTempArg);
+       SysTryReturn(NID_MEDIA, pArg != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
+
+       result r = E_SUCCESS;
+       switch (pArg->GetEventType())
+       {
+       case _CAMERA_EVENT_ERROR:
+               __pCameraImpl->SetState(CAMERA_STATE_ERROR);
+               pCameraEventListener->OnCameraErrorOccurred(pArg->GetError());
+               break;
+
+       case _CAMERA_EVENT_AUTO_FOCUSED:
+               if (__pCameraImpl->GetState() == CAMERA_STATE_AUTO_FOCUSING)
+               {
+                       __pCameraImpl->SetState(CAMERA_STATE_PREVIEW);
+               }
+               pCameraEventListener->OnCameraAutoFocused(pArg->GetResult() == E_SUCCESS ? true : false);
+               break;
+
+       case _CAMERA_EVENT_CAPTURED:
+       {
+               if (__pCameraImpl->GetState() == CAMERA_STATE_CAPTURING)
+               {
+                       if (__pCameraImpl->IsZeroShutterLag())
+                       {
+                               r = __pCameraImpl->GetCoordinator()->StartMmPreview();
+                               if (r != E_SUCCESS)
+                               {
+                                       SysLogException(NID_MEDIA, r, "[%s] Start Preview is failed.", GetErrorMessage(r));
+                                       goto CATCH_CAPTURE;
+                               }
+                               __pCameraImpl->SetState(CAMERA_STATE_PREVIEW);
+                       }
+                       else
+                       {
+                               __pCameraImpl->SetState(CAMERA_STATE_CAPTURED);
+                       }
+               }
+               if (pArg->GetData() != null)
+               {
+                       pCameraEventListener->OnCameraCaptured(*(pArg->GetData()), pArg->GetResult());
+               }
+               else
+               {
+                       ByteBuffer emptyBuffer;
+                       pCameraEventListener->OnCameraCaptured(emptyBuffer, pArg->GetResult());
+               }
+       }
+               break;
+       CATCH_CAPTURE:
+               __pCameraImpl->SetState(CAMERA_STATE_ERROR);
+               pCameraEventListener->OnCameraErrorOccurred(CAMERA_ERROR_DEVICE_FAILED);
+               break;
+
+       case _CAMERA_EVENT_PREVIEWED_DATA:
+       {
+               _CameraBuffer* pBuffer = __pCameraImpl->DequeueDataN(_CAMERA_BUFFER_PREVIEW);
+               SysTryReturn(NID_MEDIA, pBuffer != null, , E_INVALID_DATA, "[E_INVALID_DATA] Invalid preview data.");
+
+               MediaPixelFormat mediaSrcFormat = pBuffer->GetPixelFormat();
+
+               // Get the preview format which is from the application setting.
+               MediaPixelFormat mediaUserFormat = MEDIA_PIXEL_FORMAT_NONE;
+               double ratio = 0.0;
+               _CameraUtil::GetOspMediaPixelFormat(__pCameraImpl->GetPreviewFormat(), mediaUserFormat, ratio);
+
+               // If the conversion is needed
+               if (mediaSrcFormat != mediaUserFormat)
+               {
+                       result r = E_SUCCESS;
+                       _ColorConverter cvt;
+                       const byte * pSrcBuf = pBuffer->GetPointer();
+                       _CameraBuffer dstCameraBuffer;
+                       int convertedBufSize = 0;
+                       byte * pConvertedBuf = null;
+                       int width = pBuffer->GetWidth();
+                       int height = pBuffer->GetHeight();
+
+                       SysLog(NID_MEDIA, "Preview callback. MM format should be converted from %d to %d", mediaSrcFormat, mediaUserFormat);
+                       r = cvt.Construct(mediaSrcFormat, width, height, mediaUserFormat, width, height);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       convertedBufSize = _ImageUtil::GetBufferSize(mediaUserFormat, width, height);
+                       SysTryCatch(NID_MEDIA, convertedBufSize > 0, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       r = dstCameraBuffer.Construct(convertedBufSize, _CAMERA_BUFFER_PREVIEW, mediaUserFormat, width, height);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), convertedBufSize);
+
+                       pConvertedBuf = const_cast<byte*>(dstCameraBuffer.GetPointer());
+                       SysTryCatch(NID_MEDIA, pConvertedBuf != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] byte instance is not available. dstCameraBuffer.GetPointer() is null.");
+
+                       r = cvt.Convert(pSrcBuf, pBuffer->GetCapacity(), pConvertedBuf, convertedBufSize);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       pCameraEventListener->OnCameraPreviewed(dstCameraBuffer, pArg->GetResult());
+               }
+               else            //If the conversion is not needed.
+               {
+                       SysLog(NID_MEDIA, "Preview callback. Format is %d", mediaSrcFormat);
+                       pCameraEventListener->OnCameraPreviewed(*pBuffer, pArg->GetResult());
+               }
+
+CATCH:
+               delete pBuffer;
+       }
+       break;
+
+       default:
+               break;
+
+       }
+}
+
+}}
+
diff --git a/src/FMedia_CameraEvent.h b/src/FMedia_CameraEvent.h
new file mode 100755 (executable)
index 0000000..96114db
--- /dev/null
@@ -0,0 +1,106 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraEvent.h
+ * @brief                      This header file contains the declaration of _CameraEvent class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_EVENT_H_
+#define _FMEDIA_INTERNAL_CAMERA_EVENT_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseRt_Event.h>
+#include "FMedia_CameraEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+class _CameraImpl;
+
+/**
+ * @class      _CameraEvent
+ * @brief              This class provides the Camera Event.
+ *
+ *     This class is the Camera event, which can notify to the listeners which derives ICameraEventListener.
+ *     This event is fired upon receipt of notification from subsystem.
+ *     For instances, when the auto-focusing is completed, ICameraEventListener::OnCameraAutoFocused is invoked.
+ *
+ *     @see    Camera, _CameraEventArg, ICameraEventListener
+ */
+class _CameraEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+public:
+       /**
+        *      The constructor.
+        */
+       _CameraEvent(void);
+
+       /**
+        *      The destructor.
+        */
+       ~_CameraEvent(void);
+
+       /**
+        * Initializes a new instance of this class
+        *
+        *      @param[in]      cameraImpl      The _CameraImpl object
+        */
+       result Construct(_CameraImpl& cameraImpl);
+
+       /**
+        *      Sends event.
+        *
+        *  @return             The error code.
+        *  @param[in]  event                                   The event type.
+        *      @param[in]      err                                             The error reason
+        *      @param[in]      res                                             The result of the event
+        *      @param[in]      pByteBuffer                             The data
+        *      @exception      E_SUCCESS                                                    - This method is successful.
+        *      @exception      E_OUT_OF_MEMORY                                  - Failed to allocate the required/requested memory.
+        *      @exception      E_INVALID_STATE                 - This instance is in an invalid state for this method.
+        *      @exception      E_INVALID_ARG                                - The argument passed to a method contains an invalid value.
+        */
+       result SendEvent(_CameraEventType event, CameraErrorReason err, result res, const Tizen::Base::ByteBuffer* pByteBuffer);
+
+protected:
+       /**
+        *      Finds out and invokes the method of listener corresponding to the specified event argument.
+        *
+        *  @param[in]  listener                                               An event listener to be invoked. This must be an instance of ICameraEventListener.
+        *      @param[in]      arg                                                           An argument to be fired.
+        *      @exception      E_SUCCESS                                                    - This method is successful.
+        *      @exception      E_OUT_OF_MEMORY                                  - Failed to allocate the required/requested memory.
+        *      @exception      E_INVALID_STATE                 - This instance is in an invalid state for this method.
+        *      @exception      E_INVALID_ARG                                - The argument passed to a method contains an invalid value.
+        */
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+       _CameraEvent(const _CameraEvent& rhs);
+       _CameraEvent& operator =(const _CameraEvent& rhs);
+
+       _CameraImpl* __pCameraImpl;
+
+};
+
+}}
+
+#endif
diff --git a/src/FMedia_CameraEventArg.cpp b/src/FMedia_CameraEventArg.cpp
new file mode 100755 (executable)
index 0000000..fea6833
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraEventArg.cpp
+ * @brief                      This file contains the event arguments from subsystem to FMedia's event listener.
+ *
+ */
+#include <FBaseSysLog.h>
+#include "FMedia_CameraEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+_CameraEventArg::_CameraEventArg(void)
+       : __cameraEventType(_CAMERA_EVENT_NONE)
+       , __pCameraData(null)
+       , __result(E_SUCCESS)
+       , __error(CAMERA_ERROR_NONE)
+{
+
+}
+
+_CameraEventArg::~_CameraEventArg(void)
+{
+       if (__pCameraData != null)
+       {
+               delete __pCameraData;
+       }
+}
+
+void
+_CameraEventArg::SetEventType(_CameraEventType eType)
+{
+       __cameraEventType = eType;
+}
+
+_CameraEventType
+_CameraEventArg::GetEventType(void) const
+{
+       return __cameraEventType;
+}
+
+void
+_CameraEventArg::SetData(const Tizen::Base::ByteBuffer* pData)
+{
+       if (pData != null)
+       {
+               __pCameraData = new (std::nothrow) ByteBuffer();
+               SysTryReturn(NID_MEDIA, __pCameraData !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+               __pCameraData->Construct(*pData); //shallow copy
+       }
+}
+
+Tizen::Base::ByteBuffer*
+_CameraEventArg::GetData(void) const
+{
+       return __pCameraData;
+}
+
+result
+_CameraEventArg::GetResult(void) const
+{
+       return __result;
+}
+
+void
+_CameraEventArg::SetResult(result r)
+{
+       __result = r;
+}
+
+void
+_CameraEventArg::SetError(CameraErrorReason r)
+{
+       __error = r;
+}
+
+CameraErrorReason
+_CameraEventArg::GetError(void) const
+{
+       return __error;
+}
+
+}}// Tizen::Media
+
diff --git a/src/FMedia_CameraEventArg.h b/src/FMedia_CameraEventArg.h
new file mode 100755 (executable)
index 0000000..5b3d6db
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraEventArg.h
+ * @brief                      This header file contains the declaration of Tizen::Media namespace.
+ *
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_EVENTARG_H_
+#define _FMEDIA_INTERNAL_CAMERA_EVENTARG_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaCameraTypes.h>
+
+namespace Tizen {namespace Media
+{
+//@enum _CameraEventType
+//@brief This represents Camera's event type.
+enum _CameraEventType
+{
+       _CAMERA_EVENT_NONE,                                      // Event_None */
+       _CAMERA_EVENT_AUTO_FOCUSED,                              // Auto foucs Event*/
+       _CAMERA_EVENT_CAPTURED,                       // Capture Event*/
+       _CAMERA_EVENT_PREVIEWED_DATA,                   // Preview Event
+       _CAMERA_EVENT_ERROR,                                     // Error event */
+};
+
+
+/**
+* @class       _CameraEventArg
+* @brief       This class contains the information about the Camera event.
+*
+*      This event argument is used in ICameraEventListener's On-methods. It contains time information
+*      as well as camera instance.
+*
+*      @see    Camera, ICameraEventListener
+*
+*/
+class _CameraEventArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+       /**
+       *       Constructor
+       */
+       _CameraEventArg(void);
+
+       /**
+       *       Destructor
+       */
+       ~_CameraEventArg(void);
+
+       /**
+        *      Get the event type.
+        *
+        *      @return Camera Event type of this argument.
+        */
+       _CameraEventType GetEventType(void) const;
+
+       /**
+        *      Set the event type.
+        */
+       void SetEventType(_CameraEventType eType);
+
+
+       /**
+       *       Get the data provided by the Camera
+       *
+       *       @return data defined in Camera subsystem.
+       */
+       Tizen::Base::ByteBuffer* GetData(void) const;
+
+       /**
+       *       Set the data provided by the Camera
+       */
+       void SetData(const Tizen::Base::ByteBuffer* data);
+
+       /**
+        *      Get the result.
+        *
+        *      @return Camera result of a aync method.
+        */
+       result GetResult(void) const;
+
+       /**
+        *      Set the result.
+        */
+       void SetResult(result r);
+
+       /**
+        *      Get the error.
+        *
+        *      @return Camera error of this argument.
+        */
+       CameraErrorReason GetError(void) const;
+
+       /**
+        *      Set the error.
+        */
+       void SetError(CameraErrorReason r);
+
+
+private:
+       _CameraEventArg(const _CameraEventArg& rhs);
+       _CameraEventArg& operator =(const _CameraEventArg& rhs);
+
+       _CameraEventType __cameraEventType;
+
+       Tizen::Base::ByteBuffer* __pCameraData;
+       result __result;
+       CameraErrorReason __error;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_CameraImpl.cpp b/src/FMedia_CameraImpl.cpp
new file mode 100755 (executable)
index 0000000..0e8ec50
--- /dev/null
@@ -0,0 +1,3307 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraImpl.cpp
+ * @brief                      This file contains the implementation of the %_CameraImpl class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <Evas.h>
+#include <FBaseInteger.h>
+#include <FBaseSysLog.h>
+#include <FBaseColArrayList.h>
+#include <FGrpDimension.h>
+#include <FGrpPoint.h>
+#include <FGrp_BufferInfoImpl.h>
+#include <FMediaTypes.h>
+#include <FMediaImageTypes.h>
+#include <FMediaCamera.h>
+#include <FMediaICameraEventListener.h>
+#include <FMediaCapabilityTypes.h>
+#include "FMedia_CameraImpl.h"
+#include "FMedia_CameraEvent.h"
+#include "FMedia_CameraUtil.h"
+#include "FMedia_CameraCapability.h"
+#include "FMedia_CameraCoordinator.h"
+#include "FMedia_CapabilityImpl.h"
+#include "FMedia_CamPtrUtil.h"
+
+#define _CAMERA_EVAS_PIXMAP_ 1
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media
+{
+static const int _RELOAD_BRIGHTNESS = 0x1;
+static const int _RELOAD_CONTRAST = 0x1 << 1;
+static const int _RELOAD_EXPOSURE = 0x1 << 2;
+static const int _RELOAD_MAX_ZOOM_LEVEL = 0x1 << 3;
+static const int _RELOAD_ZOOM_LEVEL = 0x1 << 4;
+static const int _RELOAD_PREVIEW_RESOLUTION = 0x1 << 5;
+static const int _RELOAD_CAPTURE_RESOLUTION = 0x1 << 6;
+static const int _RELOAD_PREVIEW_FORMAT = 0x1 << 7;
+static const int _RELOAD_CAPTURE_FORMAT = 0x1 << 8;
+static const int _RELOAD_EFFECT = 0x1 << 9;
+static const int _RELOAD_WB = 0x1 << 10;
+static const int _RELOAD_QUALITY = 0x1 << 11;
+static const int _RELOAD_ISO = 0x1 << 12;
+static const int _RELOAD_FLASH = 0x1 << 13;
+static const int _RELOAD_EXIF_ORIENTATION = 0x1 << 14;
+static const int _RELOAD_EXIF_GPS_COORDINATES = 0x1 << 15;
+static const int _RELOAD_FLIP = 0x1 << 16;
+static const int _RELOAD_PREVIEW_ROTATION = 0x1 << 17;
+static const int _RELOAD_FPS = 0x1 << 18;
+static const int _RELOAD_PREVIEW_PREPARE = 0x1 << 19;
+static const int _RELOAD_INTERNAL_PREVIEW_FORMAT = 0x1 << 20;
+static const int _RELOAD_FOCUS_MODE = 0x1 << 21;
+static const int _RELOAD_ZERO_SHUTTER_LAG = 0x1 << 22;
+static const int _RELOAD_METERING_MODE = 0x1 << 23;
+static const int _RELOAD_EXTRA = 0x1 << 24;
+
+static const int _PREVIEW_PRE_PROCESSING = 0x01;
+static const int _PREVIEW_POST_PROCESSING = 0x01 << 1;
+
+static const double _CAMERA_EXIF_GPS_INVALID_LATITUDE = 90.1;
+static const double _CAMERA_EXIF_GPS_INVALID_LONGITUDE = 180.1;
+
+static const int _MAX_CAPTURE_BUFFER_COUNT = 10;
+static const int _MAX_PREVIEW_BUFFER_COUNT = 2;
+static const int _MIN_PROPERTY = 0;
+static const int _MAX_PROPERTY = 9;
+static const int _INVALID_FOCUS_COORDINATE = -1;
+
+bool _CameraImpl::__isUsed = false;
+
+enum _FocusModeOperation
+{
+       _FOCUS_MODE_OP_NONE,
+       _FOCUS_MODE_OP_CONTINUOUS,
+       _FOCUS_MODE_OP_CANCEL,
+};
+
+typedef struct
+{
+       CameraFocusMode currentMode;
+       _FocusModeOperation focusOperation0;
+       CameraFocusMode destMode;
+       _FocusModeOperation focusOperation1;
+} _CameraFocusModeTransitTable;
+
+static const _CameraFocusModeTransitTable _CAMERA_FOCUS_MODE_TRANSIT[] =
+{
+       {CAMERA_FOCUS_MODE_NONE,                        _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_NONE,                         _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_NONE,                        _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_NORMAL,                       _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_NONE,                        _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_MACRO,                        _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_NONE,                        _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,              _FOCUS_MODE_OP_CONTINUOUS},
+       {CAMERA_FOCUS_MODE_NONE,                        _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_INFINITE,                     _FOCUS_MODE_OP_NONE},
+
+       {CAMERA_FOCUS_MODE_NORMAL,                      _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_NONE,                 _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_NORMAL,                      _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_NORMAL,                       _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_NORMAL,                      _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_MACRO,                        _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_NORMAL,                      _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,              _FOCUS_MODE_OP_CONTINUOUS},
+       {CAMERA_FOCUS_MODE_NORMAL,                      _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_INFINITE,                     _FOCUS_MODE_OP_NONE},
+
+       {CAMERA_FOCUS_MODE_MACRO,                       _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_NONE,                 _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_MACRO,                       _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_NORMAL,                       _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_MACRO,                       _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_MACRO,                        _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_MACRO,                       _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,              _FOCUS_MODE_OP_CONTINUOUS},
+       {CAMERA_FOCUS_MODE_MACRO,                       _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_INFINITE,                     _FOCUS_MODE_OP_NONE},
+
+       {CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,             _FOCUS_MODE_OP_CANCEL,          CAMERA_FOCUS_MODE_NONE,                 _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,             _FOCUS_MODE_OP_CANCEL,          CAMERA_FOCUS_MODE_NORMAL,                       _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,             _FOCUS_MODE_OP_CANCEL,          CAMERA_FOCUS_MODE_MACRO,                        _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,             _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,              _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,             _FOCUS_MODE_OP_CANCEL,          CAMERA_FOCUS_MODE_INFINITE,                     _FOCUS_MODE_OP_NONE},
+
+       {CAMERA_FOCUS_MODE_INFINITE,                    _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_NONE,                 _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_INFINITE,                    _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_NORMAL,                       _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_INFINITE,                    _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_MACRO,                        _FOCUS_MODE_OP_NONE},
+       {CAMERA_FOCUS_MODE_INFINITE,                    _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,              _FOCUS_MODE_OP_CONTINUOUS},
+       {CAMERA_FOCUS_MODE_INFINITE,                    _FOCUS_MODE_OP_NONE,            CAMERA_FOCUS_MODE_INFINITE,                     _FOCUS_MODE_OP_NONE},
+};
+
+enum _FocusOperation
+{
+       _FOCUS_OP_NONE,
+       _FOCUS_OP_ONCE,
+};
+
+typedef struct
+{
+       CameraFocusMode currentMode;
+       _FocusOperation focusOperation;
+       CameraState state;
+} _CameraFocusOperationTable;
+
+static const _CameraFocusOperationTable _CAMERA_FOCUS_OPERATIONT[] =
+{
+//     {CAMERA_FOCUS_MODE_NONE,                        _FOCUS_OP_NONE,         (CameraState)-1,},
+       {CAMERA_FOCUS_MODE_NORMAL,                      _FOCUS_OP_ONCE,         CAMERA_STATE_AUTO_FOCUSING,},
+       {CAMERA_FOCUS_MODE_MACRO,                       _FOCUS_OP_ONCE,         CAMERA_STATE_AUTO_FOCUSING,},
+       {CAMERA_FOCUS_MODE_CONTINUOUS_AUTO,_FOCUS_OP_NONE,              (CameraState)-1,},              //no state change in the continuous mode
+//     {CAMERA_FOCUS_MODE_INFINITE,                    _FOCUS_OP_NONE,         (CameraState)-1,},
+};
+
+_CameraImpl::_CameraImpl(void)
+       : __deviceType(_CAMERA_DEVICE_NONE)
+       , __pCoordinator(null)
+       , __pCameraCapability(null)
+       , __state(CAMERA_STATE_INITIALIZED)
+       , __handle(MM_INVALID_HANDLE)
+       , __pCameraEvent(null)
+       , __pCameraEventListener(null)
+       , __pCaptureBufferQueue(null)
+       , __pPreviewBufferQueue(null)
+       , __isConstructed(false)
+       , __isPoweredOn(false)
+       , __selection(CAMERA_PRIMARY)
+       , __brightness(DEFAULT_CAMERA_BRIGHTNESS)
+       , __contrast(DEFAULT_CAMERA_CONTRAST)
+       , __exposure(DEFAULT_CAMERA_EXPOSURE)
+       , __zoomLevel(0)
+       , __minZoomLevel(0)
+       , __maxZoomLevel(0)
+       , __effect(CAMERA_EFFECT_NONE)
+       , __wb(CAMERA_WHITE_BALANCE_AUTO )
+       , __quality(CAMERA_QUALITY_NORMAL)
+       , __isoLevel(CAMERA_ISO_DEFAULT)
+       , __flashMode(CAMERA_FLASH_MODE_OFF)
+       , __zeroShutterLag(false)
+       , __meteringMode(CAMERA_METERING_MODE_NONE)
+       , __focusCallback(false)
+       , __isFocusAreaSet(false)
+       , __exifOrientation(CAMERA_EXIF_ORIENTATION_NONE)
+       , __exifLatitude(_CAMERA_EXIF_GPS_INVALID_LATITUDE)
+       , __exifLongitude(_CAMERA_EXIF_GPS_INVALID_LONGITUDE)
+       , __exifAltitude(0)
+       , __flip(CAMERA_FLIP_NONE)
+       , __previewRotation(CAMERA_ROTATION_NONE)
+#if defined(_OSP_EMUL_)
+       , __fps(30)
+#else
+       , __fps(DEFAULT_CAMERA_PREVIEW_FPS)
+#endif
+       , __focusMode(CAMERA_FOCUS_MODE_NONE)
+       , __previewProcessing(0)
+       , __previewRegionHandle(_BufferInfoImpl::INVALID_BUFFER_HANDLE)
+       , __previewDisplayType(::CAMERA_DISPLAY_TYPE_NONE)
+       , __displayRotationType(CAMERA_ROTATION_NONE)
+       , __physicalDirection(CAMERA_DIRECTION_BACK)
+       , __physicalRotation(CAMERA_ROTATION_NONE)
+       , __supportedFocusPointCount(0)
+       , __pPreProcessCbFunc(null)
+       , __pPreProcessUserData(null)
+{
+       __previewResolution.width = 0;
+       __previewResolution.height = 0;
+       __deviceDefaultPreviewResolution.width = 0;
+       __deviceDefaultPreviewResolution.height = 0;
+
+       __captureResolution.width = 0;
+       __captureResolution.height = 0;
+       __deviceDefaultCaptureResolution.width = 0;
+       __deviceDefaultCaptureResolution.height = 0;
+
+       __previewFormat = PIXEL_FORMAT_YCbCr420_PLANAR;
+       __deviceDefaultPreviewFormat = PIXEL_FORMAT_YCbCr420_PLANAR;
+
+       __captureFormat = PIXEL_FORMAT_JPEG;
+       __deviceDefaultCaptureFormat = PIXEL_FORMAT_JPEG;
+
+       for(int i = 0; i < MAX_FOCUS_POINT; i++)
+       {
+               __focusPoints[0][i] = _INVALID_FOCUS_COORDINATE;
+               __focusPoints[1][i] = _INVALID_FOCUS_COORDINATE;
+       }
+}
+
+_CameraImpl::~_CameraImpl(void)
+{
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               int err = MM_SUCCESS;
+               err = camera_unset_state_changed_cb(__handle);
+               err = camera_unset_interrupted_cb(__handle);
+               err = camera_unset_focus_changed_cb(__handle);
+               err = camera_unset_preview_cb(__handle);
+               __handle = MM_INVALID_HANDLE;
+       }
+       if (__pCoordinator != null)
+       {
+               __pCoordinator->RemoveCameraCoordinatorListener(*this);
+
+               if (IsPoweredOn())
+               {
+                       PowerOff();
+               }
+
+               _CameraCoordinator::Release(__deviceType);
+       }
+
+       if (__pCameraCapability != null)
+       {
+               _CameraCapability::Release(__deviceType);
+       }
+
+       if (__pCameraEvent != null)
+       {
+               delete __pCameraEvent;
+       }
+
+       if (__pCaptureBufferQueue != null)
+       {
+               __pCaptureBufferQueue->RemoveAll(true);
+               delete __pCaptureBufferQueue;
+       }
+
+       if (__pPreviewBufferQueue != null)
+       {
+               __pPreviewBufferQueue->RemoveAll(true);
+               delete __pPreviewBufferQueue;
+       }
+
+       if ( __isConstructed )
+       {
+               __isUsed = false;
+       }
+
+       SysLog(NID_MEDIA, "Destroyed");
+}
+
+result
+_CameraImpl::Construct(ICameraEventListener& listener, CameraSelection camSel)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. camSel:%d", camSel);
+
+       SysTryReturn(NID_MEDIA, !__isUsed, E_DEVICE_BUSY, E_DEVICE_BUSY, "[E_DEVICE_BUSY] A camera device is already used.");
+       SysTryReturn(NID_MEDIA, !__isConstructed, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] _CameraImpl is in an invalid state. A camera device is already constructed.");
+       SysTryReturn(NID_MEDIA, camSel >= CAMERA_PRIMARY && camSel <= CAMERA_SECONDARY, E_DEVICE_UNAVAILABLE, E_DEVICE_UNAVAILABLE, "[E_DEVICE_UNAVAILABLE] The camsel(%d)  is invalid.", camSel);
+
+       // _CapablityImpl object should be created before the camera_create() is called to get the recorder capability without problem. camera c-api.
+       // _CapabilityImpl is not deleted until the application exits.
+       int cameraCount = 0;
+       _CapabilityImpl* pCapabilityImpl = _CapabilityImpl::GetInstance();
+       SysTryReturn(NID_MEDIA, pCapabilityImpl != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Capability is not obtained.");
+
+       r = pCapabilityImpl->GetValue(L"Camera.Count", cameraCount);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Number of Camera was not obtained.");
+       SysTryReturn(NID_MEDIA, camSel < cameraCount, E_DEVICE_UNAVAILABLE, E_DEVICE_UNAVAILABLE, "[E_DEVICE_UNAVAILABLE] The camSel(%d)  is not available.", camSel);
+       __selection = camSel;
+
+       // Get the _CameraCapability.
+       // This is just for the performance enhancement by incrementing ref counts of _CameraCapability.
+       // It forbiddens creating and deleting the _CameraCapability object repeatedly.
+       __deviceType = (camSel == CAMERA_PRIMARY ? _CAMERA_DEVICE_PRIMARY : _CAMERA_DEVICE_SECONDARY);
+       __pCameraCapability = _CameraCapability::AddInstance(__deviceType);
+       SysTryReturn(NID_MEDIA, __pCameraCapability != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Capability instance is not available.");
+
+       int direction = 0;
+       int rotation = 0;
+       int focusPoint = 0;
+       r = pCapabilityImpl->GetValue(camSel == CAMERA_PRIMARY ? String(L"Camera.Primary.Direction") : String(L"Camera.Secondary.Direction"), direction);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pCapabilityImpl->GetValue(camSel == CAMERA_PRIMARY ? String(L"Camera.Primary.Rotation") : String(L"Camera.Secondary.Rotation"), rotation);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __physicalDirection = static_cast<CameraDirection>(direction);
+       __physicalRotation = static_cast<CameraRotation>(rotation);
+
+       r = pCapabilityImpl->GetValue(camSel == CAMERA_PRIMARY ? String(L"Camera.Primary.FocusPoint") : String(L"Camera.Secondary.FocusPoint"), focusPoint);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       __supportedFocusPointCount = focusPoint;
+
+// Create Event
+       __pCameraEvent = new (std::nothrow) _CameraEvent();
+       SysTryReturn(NID_MEDIA, __pCameraEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = __pCameraEvent->Construct(*this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pCameraEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       __pCameraEventListener = &listener;
+
+// Prepare captured buffer list
+       __pCaptureBufferQueue = new (std::nothrow) Tizen::Base::Collection::Queue();
+       SysTryCatch(NID_MEDIA, __pCaptureBufferQueue != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = __pCaptureBufferQueue->Construct(_MAX_CAPTURE_BUFFER_COUNT);         // For async panorama shot.
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+// Prepare preview buffer list
+       __pPreviewBufferQueue = new (std::nothrow) Tizen::Base::Collection::Queue();
+       SysTryCatch(NID_MEDIA, __pPreviewBufferQueue != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = __pPreviewBufferQueue->Construct(_MAX_PREVIEW_BUFFER_COUNT);         // For async preview data.
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       // Get the _CameraCoordinator
+       __pCoordinator = _CameraCoordinator::AddInstance(__deviceType);
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, __pCoordinator != null, , r, "[E_OBJ_NOT_FOUND] _CameraCoordinator instance is not available.");
+
+       // Add this to _CameraCoordinator
+       r = __pCoordinator->AddCameraCoordinatorListener(*this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __handle = __pCoordinator->GetCameraHandle();
+
+       err = camera_set_state_changed_cb(__handle, StateChangedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       err = camera_set_interrupted_cb(__handle, InterruptedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       err = camera_set_focus_changed_cb(__handle, FocusStateChangedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to set the focus changed callback.", GetErrorMessage(r));
+
+       // Get the default properties
+       r = LoadDefaultConfiguration(_RELOAD_PREVIEW_RESOLUTION | _RELOAD_CAPTURE_RESOLUTION | _RELOAD_PREVIEW_FORMAT | _RELOAD_CAPTURE_FORMAT
+                                                       | _RELOAD_FOCUS_MODE |_RELOAD_ZERO_SHUTTER_LAG | _RELOAD_METERING_MODE);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       SetState(CAMERA_STATE_INITIALIZED);
+       __isConstructed = true;
+       __isUsed = true;
+       return r;
+
+CATCH:
+       if (__handle)
+       {
+               err = camera_unset_state_changed_cb(__handle);
+               err = camera_unset_interrupted_cb(__handle);
+               err = camera_unset_focus_changed_cb(__handle);
+       }
+
+       if (__pCoordinator != null)
+       {
+               __pCoordinator->RemoveCameraCoordinatorListener(*this);
+       }
+
+       if (__pCameraEventListener != null)
+       {
+               __pCameraEvent->RemoveListener(*__pCameraEventListener);
+               __pCameraEventListener = null;
+       }
+
+       if (__pCameraEvent != null)
+       {
+               delete __pCameraEvent;
+               __pCameraEvent = null;
+       }
+
+       if (__pCaptureBufferQueue != null)
+       {
+               __pCaptureBufferQueue->RemoveAll(true);
+               delete __pCaptureBufferQueue;
+               __pCaptureBufferQueue = null;
+       }
+
+       return r;
+}
+
+result
+_CameraImpl::PowerOn(void)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Camera powerON");
+
+       SysTryReturn(NID_MEDIA, __isPoweredOn == false, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was already powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state(%d), Camera is not in initialized state.", state);
+
+       __isPoweredOn = true;
+
+       err = camera_set_display(__handle, ::CAMERA_DISPLAY_TYPE_NONE, null);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Temporarily forbidden the preview callback.", GetErrorMessage(r));
+
+       // re-configuration for new camera handle. active conf.
+       r = ReloadConfiguration(_RELOAD_BRIGHTNESS  | _RELOAD_CONTRAST  | _RELOAD_EXPOSURE  | _RELOAD_MAX_ZOOM_LEVEL
+                                                       | _RELOAD_PREVIEW_RESOLUTION  | _RELOAD_CAPTURE_RESOLUTION  | _RELOAD_PREVIEW_FORMAT
+                                                       | _RELOAD_CAPTURE_FORMAT  | _RELOAD_FPS  | _RELOAD_EFFECT  | _RELOAD_WB  | _RELOAD_QUALITY  | _RELOAD_ISO
+                                                       | _RELOAD_EXIF_ORIENTATION  | _RELOAD_EXIF_GPS_COORDINATES
+                                                       | _RELOAD_FLIP  | _RELOAD_PREVIEW_ROTATION  | _RELOAD_FLASH
+                                                       | _RELOAD_EXTRA);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera reload configuration failed", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       __isPoweredOn = false;
+       return r;
+}
+
+result
+_CameraImpl::PowerOff(void)
+{
+       result r = E_SUCCESS;
+       camera_state_e mmState = ::CAMERA_STATE_NONE;
+       SysLog(NID_MEDIA, "Camera powerOFF");
+
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+
+       mmState = GetMmState();
+       switch (mmState)
+       {
+       case ::CAMERA_STATE_PREVIEW:
+               r = __pCoordinator->StopMmPreview();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+
+       case ::CAMERA_STATE_CAPTURING:
+               // Camera's destroy while capturing should be done by waiting until the state is changed to CAPTURED..
+               {
+                       const int timeoutCount = 100;
+                       const long sleepTime = 50;
+                       int i = 0;
+                       while (GetMmState() == ::CAMERA_STATE_CAPTURING && ( i++ <  timeoutCount) )
+                       {
+                               r = Tizen::Base::Runtime::Thread::Sleep(sleepTime);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_DEVICE_FAILED, E_DEVICE_FAILED, "[E_DEVICE_FAILED] Sleep failed while waiting the state changing to CAPTURED.");
+                               SysLog(NID_MEDIA, "Sleep try %dst", i);
+                       }
+                       SysTryCatch(NID_MEDIA, i < timeoutCount, r = E_DEVICE_BUSY, E_DEVICE_BUSY, "[E_DEVICE_BUSY] Sleep failed while waiting the state changing to CAPTURED.");
+                       SysLog(NID_MEDIA, "PowerOff succeeded from capturing state in %d msec.", (int)sleepTime*i);
+
+                       mmState = GetMmState();
+                       // The captured buffer inserted via CaptureCb should be deleted.
+                       ByteBuffer* pBuffer = null;
+                       while ((pBuffer = DequeueDataN(_CAMERA_BUFFER_CAPTURE)) != null)
+                       {
+                               delete pBuffer;
+                               pBuffer = null;
+                       }
+               }
+               //The state is changed synchronously
+               SetState(CAMERA_STATE_CAPTURED);
+
+               r = __pCoordinator->StartMmPreview();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = __pCoordinator->StopMmPreview();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+
+       case ::CAMERA_STATE_CAPTURED:
+               r = __pCoordinator->StartMmPreview();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = __pCoordinator->StopMmPreview();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+
+       case ::CAMERA_STATE_CREATED:
+               //fall through
+       case ::CAMERA_STATE_NONE:
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. mmState:%d", mmState);
+               goto CATCH;
+               break;
+       }
+
+       __isPoweredOn = false;
+       __zoomLevel = 0;
+       SetState(CAMERA_STATE_INITIALIZED);
+       return r;
+
+CATCH:
+       return r;
+}
+
+bool
+_CameraImpl::IsPoweredOn(void) const
+{
+       return __isPoweredOn;
+}
+
+result
+_CameraImpl::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo, bool previewedData)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       camera_state_e mmState = ::CAMERA_STATE_NONE;
+       CameraState state = CAMERA_STATE_ERROR;
+       Rectangle tempDisplayRect;
+       int tempDisplayHandle = _BufferInfoImpl::INVALID_BUFFER_HANDLE;
+       CameraRotation tempDisplayRotationType = CAMERA_ROTATION_NONE;
+       camera_display_type_e tempDisplayType = ::CAMERA_DISPLAY_TYPE_NONE;
+
+       SysLog(NID_MEDIA, "Camera StartPreview. pBufferInfo:%d, previewedData:%d", (int) pBufferInfo, previewedData);
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_CAPTURED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera state[%d] is not ready to start preview.", state);
+
+       // Set preview callback
+       if (previewedData || (__previewProcessing & _PREVIEW_PRE_PROCESSING))
+       {
+               err = camera_set_preview_cb(__handle, PreviewCb, this);
+       }
+       else
+       {
+               err = camera_unset_preview_cb(__handle);
+       }
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       mmState = GetMmState();
+
+       if ( pBufferInfo != null )
+       {
+               const _BufferInfoImpl* pBufferInfoImpl = null;
+               int displayHandle = _BufferInfoImpl::INVALID_BUFFER_HANDLE;
+               Rectangle rect;
+               camera_display_type_e displayType = CAMERA_DISPLAY_TYPE_NONE;
+
+               pBufferInfoImpl = _BufferInfoImpl::GetInstance(*pBufferInfo);
+               SysTryCatch(NID_MEDIA, pBufferInfoImpl != null, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.  BufferInfo is not found.");
+               if (pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION))
+               {
+                       displayHandle = pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION);
+                       displayType = ::CAMERA_DISPLAY_TYPE_X11;
+               }
+               else if (pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_CANVAS_TEXTURE))
+               {
+                       displayHandle = pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_CANVAS_TEXTURE);
+                       displayType = ::CAMERA_DISPLAY_TYPE_X11;
+               }
+               else if (pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE))
+               {
+                       displayHandle = pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE);
+                       displayType = ::CAMERA_DISPLAY_TYPE_EVAS;
+               }
+               SysTryCatch(NID_MEDIA, displayHandle != _BufferInfoImpl::INVALID_BUFFER_HANDLE, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  displayHandle:%d is wrong", displayHandle);
+
+               if ((displayHandle != __previewRegionHandle) || (state != CAMERA_STATE_CAPTURED))
+               {
+                       rect = pBufferInfoImpl->GetBounds();
+
+                       err = camera_set_display(__handle, displayType, (camera_display_h)displayHandle);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Camera set display failed. displayHandle:%d, previewedData:%d", GetErrorMessage(r), displayHandle, previewedData);
+
+                       if ( displayType == ::CAMERA_DISPLAY_TYPE_X11 )
+                       {
+                               err = camera_set_x11_display_mode(__handle, ::CAMERA_DISPLAY_MODE_FULL);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Camera set display mode failed. displayHandle:%d, previewedData:%d", GetErrorMessage(r), displayHandle, previewedData);
+
+                               err = camera_set_x11_display_visible(__handle, true);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Camera enabling display visible failed. displayHandle:%d, previewedData:%d", GetErrorMessage(r), displayHandle, previewedData);
+
+#if defined (_CAMERA_EVAS_PIXMAP_)
+                               SysLog(NID_MEDIA, "Evas pixamp buffer is used. It doesn't rotate the display.");
+
+                               err = camera_set_x11_display_rotation(__handle, ::CAMERA_ROTATION_NONE);                // No rotation.
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Camera rotate display 0 failed. displayHandle:%d, previewedData:%d", GetErrorMessage(r), displayHandle, previewedData);
+                               tempDisplayRotationType = CAMERA_ROTATION_NONE;
+#else
+                               //Only for h/w back buffer. Currently not used.
+                               CameraRotation displayRotation = CAMERA_ROTATION_NONE;
+                               _BufferInfoImpl::Rotation bufferInfoRotation = pBufferInfoImpl->GetRotation();
+                               SysLog(NID_MEDIA, "X11. BufferInfo's rotation is %d", bufferInfoRotation);
+
+                               _BufferInfoImpl::Orientation orientation = pBufferInfoImpl->GetOrientation();
+                               SysLog(NID_MEDIA, "X11. Orientation is %d", orientation);
+
+                               // Rotate the display corresponding the LCD orientationation.
+                               // This makes the unity of preview shape and the preview callback. This is osp camera concept.
+                               if ( bufferInfoRotation == _BufferInfoImpl::ROTATION_0 )                // If the OverlayRegion type is NORMAL
+                               {
+                                       r = _CameraUtil::GetDisplayRotation(__physicalDirection, orientation, displayRotation);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Camera display rotation failed in normal mode. physicalDirection:%d, orientationation:%d"
+                                               , GetErrorMessage(r), __physicalDirection, orientation);
+                               }
+                               else                                    // If the OverlayRegion type is AUTO
+                               {
+                                       r = _CameraUtil::GetDisplayRotation(__physicalDirection, __physicalRotation, orientation, displayRotation);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Camera display rotation failed in automatic mode. physicalDirection:%d, physicalRotation:%d, orientationation:%d"
+                                               , GetErrorMessage(r), __physicalDirection, __physicalRotation, orientation);
+                               }
+
+                               camera_rotation_e mmRotation = ::CAMERA_ROTATION_NONE;
+                               r = _CameraUtil::GetMmRotation( displayRotation, mmRotation);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                               SysLog(NID_MEDIA, "X11. Try rotation Rotation MM value : %d", mmRotation);
+                               err = camera_set_x11_display_rotation(__handle, mmRotation);            // Auto adjust rotation - Primary Camera 270, Secondary Camera 90
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera rotate display failed. displayHandle:%d, previewedData:%d", GetErrorMessage(r), displayHandle, previewedData);
+
+                               tempDisplayRotationType = displayRotation;
+#endif
+                       }
+                       tempDisplayRect = rect;
+                       tempDisplayHandle = displayHandle;
+                       tempDisplayType = displayType;
+
+                       __previewRegionRect = tempDisplayRect;  //currently not used.
+                       __previewRegionHandle = tempDisplayHandle;
+                       __previewDisplayType = tempDisplayType;
+                       __displayRotationType = tempDisplayRotationType;
+               }
+       }
+       else
+       {
+               err = camera_set_display(__handle, ::CAMERA_DISPLAY_TYPE_NONE, null);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera set display(null) failed. previewedData:%d", GetErrorMessage(r), previewedData);
+               __previewRegionHandle = _BufferInfoImpl::INVALID_BUFFER_HANDLE;
+       }
+
+       switch (mmState)
+       {
+       case ::CAMERA_STATE_CREATED:
+       case ::CAMERA_STATE_CAPTURED:
+               r = __pCoordinator->StartMmPreview();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera start.", GetErrorMessage(r));
+               break;
+
+       default:
+               SysTryCatch(NID_MEDIA, false, r = E_INVALID_STATE , E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. The mmState is %d:", mmState);
+               break;
+       }
+
+       if (previewedData)
+       {
+               __previewProcessing = __previewProcessing | _PREVIEW_POST_PROCESSING;
+       }
+       else
+       {
+               __previewProcessing = __previewProcessing & (~_PREVIEW_POST_PROCESSING);
+       }
+
+
+       SetState(CAMERA_STATE_PREVIEW);
+       return r;
+
+CATCH:
+       err = camera_unset_preview_cb(__handle);
+       __previewRegionHandle = _BufferInfoImpl::INVALID_BUFFER_HANDLE;
+       __previewDisplayType = ::CAMERA_DISPLAY_TYPE_NONE;
+       __displayRotationType = CAMERA_ROTATION_NONE;
+       return r;
+}
+
+result
+_CameraImpl::StopPreview(void)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       SysLog(NID_MEDIA, "Camera stop preview");
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_PREVIEW, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state(%d). Camera is not in preview state.", state);
+
+       r = __pCoordinator->StopMmPreview();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] camera stop  preview.");
+
+       if(__previewDisplayType == CAMERA_DISPLAY_TYPE_EVAS)
+       {
+               if(__previewRegionHandle != _BufferInfoImpl::INVALID_BUFFER_HANDLE)
+               {
+                       evas_object_image_data_set((Evas_Object*)__previewRegionHandle, null);
+               }
+       }
+
+       SetState(CAMERA_STATE_INITIALIZED);
+       return r;
+}
+
+result
+_CameraImpl::Capture(void)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       SysLog(NID_MEDIA, "Camera Capture");
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_PREVIEW, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state(%d). Camera is not in preview state.", state);
+
+       if ( __pCoordinator->GetMode() != _CAMERA_MODE_IMAGE )
+       {
+               r = __pCoordinator->ChangeMode(_CAMERA_MODE_IMAGE, true);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       r = __pCoordinator->StartCapture(CaptureCb, CaptureCompletedCb, this);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Start capture failed.", GetErrorMessage(r));
+
+       SetState(CAMERA_STATE_CAPTURING);
+       return r;
+}
+
+CameraState
+_CameraImpl::GetState(void) const
+{
+       if (__state == CAMERA_STATE_PREVIEW || __state == CAMERA_STATE_AUTO_FOCUSING ||  __state == CAMERA_STATE_CAPTURING)
+       {
+               camera_state_e mmState = GetMmState();
+               if (mmState == ::CAMERA_STATE_CREATED) // If the preview is stopped by some internal policy.
+               {
+                       return CAMERA_STATE_INITIALIZED;
+               }
+       }
+       return __state;
+}
+
+result
+_CameraImpl::SetBrightness(int brightness)
+{
+       result r = E_SUCCESS;
+       _CameraOperationType operation = _COP_NONE;
+       CameraState state = CAMERA_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter. brightness:%d", brightness);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryReturn(NID_MEDIA, (brightness >= MIN_CAMERA_BRIGHTNESS &&  brightness <= MAX_CAMERA_BRIGHTNESS), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                               "[E_OUT_OF_RANGE] The brightness(%d) is out of range. The brightness must be in the range between 0 ~ 9.", brightness);
+
+       if (__isPoweredOn)
+       {
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_BRIGHTNESS : _COP_SECONDARY_BRIGHTNESS);
+               r = SetProperty(operation, _MIN_PROPERTY, _MAX_PROPERTY, brightness);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. brightness:%d", GetErrorMessage(r), brightness);
+       }
+
+       __brightness = brightness;
+       return r;
+}
+
+int
+_CameraImpl::GetBrightness(void) const
+{
+       return __brightness;
+}
+
+result
+_CameraImpl::SetContrast(int contrast)
+{
+       result r = E_SUCCESS;
+       _CameraOperationType operation = _COP_NONE;
+       CameraState state = CAMERA_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter. contrast:%d", contrast);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryReturn(NID_MEDIA, contrast >= MIN_CAMERA_CONTRAST && contrast <= MAX_CAMERA_CONTRAST, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                               "[E_OUT_OF_RANGE] The contrast(%d) is out of range. The contrast must be in the range between 0 ~ 9.", contrast);
+
+       if (__isPoweredOn)
+       {
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_CONTRAST : _COP_SECONDARY_CONTRAST);
+               r = SetProperty(operation, _MIN_PROPERTY, _MAX_PROPERTY, contrast);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. contrast:%d", GetErrorMessage(r), contrast);
+       }
+
+       __contrast = contrast;
+       return r;
+}
+
+int
+_CameraImpl::GetContrast(void) const
+{
+       return __contrast;
+}
+
+result
+_CameraImpl::ZoomIn(void)
+{
+       result r = E_SUCCESS;
+       int zoomLevel = 0;
+       CameraState state = CAMERA_STATE_ERROR;
+       _CameraOperationType operation = _COP_NONE;
+       SysLog(NID_MEDIA, "Camera zoomIn");
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_PREVIEW
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       bool supported = false;
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ZOOM_LEVEL : _COP_SECONDARY_ZOOM_LEVEL);
+       supported = _CameraCapability::IsSupported(operation);
+       SysTryReturn(NID_MEDIA, supported == true, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The operation:%d is not supported.", operation);
+
+       zoomLevel = __zoomLevel + 1;
+       SysTryReturn(NID_MEDIA, zoomLevel <= __maxZoomLevel && zoomLevel >= __minZoomLevel ,
+               E_DEVICE_FAILED, E_DEVICE_FAILED, "[E_DEVICE_FAILED] No more ZoomIn. zoomLevel:%d", zoomLevel);
+
+       r = SetProperty(operation, __minZoomLevel, __maxZoomLevel, zoomLevel);
+
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __zoomLevel = zoomLevel;
+       return r;
+}
+
+result
+_CameraImpl::ZoomOut(void)
+{
+       result r = E_SUCCESS;
+       int zoomLevel = 0;
+       CameraState state = CAMERA_STATE_ERROR;
+       _CameraOperationType operation = _COP_NONE;
+       SysLog(NID_MEDIA, "Camera zoomOut");
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_PREVIEW
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       bool supported = false;
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ZOOM_LEVEL : _COP_SECONDARY_ZOOM_LEVEL);
+       supported = _CameraCapability::IsSupported(operation);
+       SysTryReturn(NID_MEDIA, supported == true, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The operation:%d is not supported.", operation);
+
+       zoomLevel = __zoomLevel - 1;
+       SysTryReturn(NID_MEDIA, zoomLevel <= __maxZoomLevel, E_DEVICE_FAILED, E_DEVICE_FAILED, "[E_DEVICE_FAILED] No more ZoomOut. zoomLevel:%d", zoomLevel);
+       SysTryReturn(NID_MEDIA, zoomLevel >= __minZoomLevel, E_DEVICE_FAILED, E_DEVICE_FAILED, "[E_DEVICE_FAILED] No more ZoomIn. ZoomOut:%d", zoomLevel);
+
+       r = SetProperty(operation, __minZoomLevel, __maxZoomLevel, zoomLevel);
+
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __zoomLevel = zoomLevel;
+       return r;
+}
+
+int
+_CameraImpl::GetMaxZoomLevel(void) const
+{
+       result r = E_SUCCESS;
+       int returnMaxZoomLevel = 0;
+       int minZoom = 0;
+       int maxZoom = 0;
+       _CameraOperationType operation = _COP_NONE;
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ZOOM_LEVEL : _COP_SECONDARY_ZOOM_LEVEL);
+       r = GetProperty(operation, minZoom, maxZoom);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. minZoom:%d, maxZoom:%d", GetErrorMessage(r), minZoom, maxZoom);
+
+       returnMaxZoomLevel = maxZoom - minZoom;
+       SysTryCatch(NID_MEDIA, returnMaxZoomLevel > 0, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Retrived zoom values are wrong. minZoom:%d, maxZoom:%d", GetErrorMessage(r), minZoom, maxZoom);
+
+       SysLog(NID_MEDIA, "Max zoom level is %d", returnMaxZoomLevel);
+       return returnMaxZoomLevel;
+
+CATCH:
+       return MEDIA_INVALID_VALUE;
+}
+
+int
+_CameraImpl::GetZoomLevel(void) const
+{
+       return __zoomLevel;
+}
+
+result
+_CameraImpl::SetPreviewResolution(const Tizen::Graphics::Dimension& resolution)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. resolution(%d,%d)", resolution.width, resolution.height);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED, E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] Camera is in an invalid state. This method is working in CAMERA_STATE_INITIALIZED state. Current state is :%d", state);
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pList (GetSupportedPreviewResolutionListN(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryCatch(NID_MEDIA, pList->Contains(resolution), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+               "[E_OUT_OF_RANGE]The resolution(%d,%d) is out of range. This resolution is not supported in the device.\n", resolution.width, resolution.height);
+
+       err = camera_set_preview_resolution(__handle, resolution.width, resolution.height);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __previewResolution.width = resolution.width;
+       __previewResolution.height = resolution.height;
+
+CATCH:
+       return r;
+}
+
+Tizen::Graphics::Dimension
+_CameraImpl::GetPreviewResolution(void) const
+{
+       return __previewResolution;
+}
+
+Tizen::Base::Collection::IList*
+_CameraImpl::GetSupportedPreviewResolutionListN(void) const
+{
+       result r = E_SUCCESS;
+       _CameraOperationType operation = _COP_NONE;
+
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_PREVIEW_RESOLUTION : _COP_SECONDARY_PREVIEW_RESOLUTION);
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pResolutionList (GetPropertyListN(operation, _RESULT_DIMENSION_LIST), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pResolutionList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryCatch(NID_MEDIA, pResolutionList->GetCount() > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       return pResolutionList.release();
+
+CATCH:
+       return null;
+}
+
+result
+_CameraImpl::SetCaptureResolution(const Tizen::Graphics::Dimension& resolution)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. resolution(%d,%d)", resolution.width, resolution.height);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pList (GetSupportedCaptureResolutionListN(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryCatch(NID_MEDIA, pList->Contains(resolution), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+               "[E_OUT_OF_RANGE]. This resolution(%d,%d)is out of range. This resolution is not supported in the device.\n", resolution.width, resolution.height);
+
+       err = camera_set_capture_resolution(__handle, resolution.width, resolution.height);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __captureResolution.width = resolution.width;
+       __captureResolution.height = resolution.height;
+
+CATCH:
+       return r;
+}
+
+
+Tizen::Graphics::Dimension
+_CameraImpl::GetCaptureResolution(void) const
+{
+       return __captureResolution;
+}
+
+
+Tizen::Base::Collection::IList*
+_CameraImpl::GetSupportedCaptureResolutionListN(void) const
+{
+       result r = E_SUCCESS;
+       _CameraOperationType operation = _COP_NONE;
+
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_CAPTURE_RESOLUTION : _COP_SECONDARY_CAPTURE_RESOLUTION);
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pResolutionList (GetPropertyListN(operation, _RESULT_DIMENSION_LIST), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pResolutionList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryCatch(NID_MEDIA, pResolutionList->GetCount() > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       return pResolutionList.release();
+
+CATCH:
+       return null;
+}
+
+result
+_CameraImpl::SetEffect(CameraEffect effect)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+
+       SysLog(NID_MEDIA, "Enter. effect:%d", effect);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryReturn(NID_MEDIA, effect >= CAMERA_EFFECT_NONE && effect <= CAMERA_EFFECT_NIGHT, E_INVALID_ARG, E_INVALID_ARG
+                          , "[E_INVALID_ARG] Invalid argument(effect) is used. effect=%d.", effect);
+
+       if (__isPoweredOn)
+       {
+               _CameraOperationType operation = _COP_NONE;
+
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_EFFECT : _COP_SECONDARY_EFFECT);
+
+               std::unique_ptr <IList, _ListPtrUtil::Remover> pEffectList (GetPropertyListN(operation, itemType), _ListPtrUtil::remover);
+               SysTryCatch(NID_MEDIA, pEffectList.get() != null, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The operation:%d is not supported.", operation);
+               SysTryCatch(NID_MEDIA, pEffectList->GetCount() > 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+               SysTryCatch(NID_MEDIA, pEffectList->Contains(Integer(effect)), r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This effect(%d) is not supported in the device.\n",  effect);
+
+               camera_attr_effect_mode_e attr = ::CAMERA_ATTR_EFFECT_NONE;
+               r = _CameraUtil::GetMmEffect(effect, attr);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. effect:%d", GetErrorMessage(r), effect);
+
+               err = camera_attr_set_effect(__handle, attr);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. effect:%d", GetErrorMessage(r), effect);
+
+       }
+       __effect = effect;
+
+CATCH:
+       return r;
+}
+
+CameraEffect
+_CameraImpl::GetEffect(void) const
+{
+       return __effect;
+}
+
+result
+_CameraImpl::SetFlashMode(CameraFlashMode flashMode)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+       SysLog(NID_MEDIA, "Enter. flashMode:%d", flashMode);
+
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       _CameraOperationType operation = _COP_NONE;
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_FLASH_MODE : _COP_SECONDARY_FLASH_MODE);
+       camera_attr_flash_mode_e attr = ::CAMERA_ATTR_FLASH_MODE_OFF;
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pFlashModeList (GetPropertyListN(operation, itemType), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pFlashModeList.get() != null, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The operation:%d is not supported.", operation);
+       SysTryCatch(NID_MEDIA, pFlashModeList->GetCount() > 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pFlashModeList->Contains(Integer(flashMode)) || flashMode == CAMERA_FLASH_MODE_OFF,
+               r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This flashMode(%d) is not supported in the device.\n",  flashMode);
+
+       r = _CameraUtil::GetMmFlashMode(flashMode, attr);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. flashMode:%d", GetErrorMessage(r), flashMode);
+
+       err = camera_attr_set_flash_mode(__handle, attr);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. flashMode:%d", GetErrorMessage(r), flashMode);
+
+       __flashMode = flashMode;
+
+CATCH:
+       return r;
+}
+
+
+CameraFlashMode
+_CameraImpl::GetFlashMode(void) const
+{
+       return __flashMode;
+}
+
+result
+_CameraImpl::SetExposure(int exposure)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       _CameraOperationType operation = _COP_NONE;
+       SysLog(NID_MEDIA, "Enter. exposure:%d", exposure);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryReturn(NID_MEDIA, exposure >= MIN_CAMERA_EXPOSURE && exposure <= MAX_CAMERA_EXPOSURE, E_OUT_OF_RANGE, E_OUT_OF_RANGE
+                          , "[E_OUT_OF_RANGE] This exposure(%d)is out of range. The exposure MUST be in the range between 0 ~ 9.", exposure);
+
+       if (__isPoweredOn)
+       {
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_EXPOSURE : _COP_SECONDARY_EXPOSURE);
+               r = SetProperty(operation, _MIN_PROPERTY, _MAX_PROPERTY, exposure);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. exposure:%d", GetErrorMessage(r), exposure);
+       }
+
+       __exposure = exposure;
+       return r;
+}
+
+int
+_CameraImpl::GetExposure(void) const
+{
+       return __exposure;
+}
+
+result
+_CameraImpl::SetWhiteBalance(CameraWhiteBalance whiteBalance)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+       SysLog(NID_MEDIA, "Enter. whiteBalance:%d", whiteBalance);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryReturn(NID_MEDIA, whiteBalance >= CAMERA_WHITE_BALANCE_AUTO && whiteBalance <= CAMERA_WHITE_BALANCE_TUNGSTEN,
+                               E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(whiteBalance) is used. whiteBalance:%d", whiteBalance);
+
+       if (__isPoweredOn)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_WHITE_BALANCE : _COP_SECONDARY_WHITE_BALANCE);
+
+               std::unique_ptr <IList, _ListPtrUtil::Remover> pWbList (GetPropertyListN(operation, itemType), _ListPtrUtil::remover);
+               SysTryCatch(NID_MEDIA, pWbList.get() != null, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The operation:%d is not supported.", operation);
+               SysTryCatch(NID_MEDIA, pWbList->GetCount() > 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+               SysTryCatch(NID_MEDIA, pWbList->Contains(Integer(whiteBalance)), r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This whiteBalance(%d) is not supported in the device.\n",  whiteBalance);
+
+               camera_attr_whitebalance_e attr = ::CAMERA_ATTR_WHITE_BALANCE_NONE;
+               r = _CameraUtil::GetMmWhiteBalance(whiteBalance, attr);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. whiteBalance:%d", GetErrorMessage(r), whiteBalance);
+
+               err = camera_attr_set_whitebalance(__handle, attr);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. whiteBalance:%d", GetErrorMessage(r), whiteBalance);
+       }
+       __wb = whiteBalance;
+
+CATCH:
+       return r;
+}
+
+CameraWhiteBalance
+_CameraImpl::GetWhiteBalance(void) const
+{
+       return __wb;
+}
+
+result
+_CameraImpl::SetQuality(CameraQuality quality)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. quality:%d", quality);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state.This method is not working in this state. Current state is :%d", state);
+
+       SysTryReturn(NID_MEDIA, quality >= CAMERA_QUALITY_NORMAL && quality <= CAMERA_QUALITY_MAX, E_OUT_OF_RANGE, E_OUT_OF_RANGE
+               , "[E_OUT_OF_RANGE]  This quality(%d)is out of range.", quality);
+
+       if (__isPoweredOn)
+       {
+               int attr = 0;
+               r = _CameraUtil::GetMmQuality(quality, attr);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. quality:%d", GetErrorMessage(r), quality);
+
+               err = camera_attr_set_image_quality(__handle, attr);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. quality:%d", GetErrorMessage(r), quality);
+       }
+       __quality = quality;
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+CameraQuality
+_CameraImpl::GetQuality(void) const
+{
+       return __quality;
+}
+
+result
+_CameraImpl::SetFocusMode(CameraFocusMode focusMode)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       String key = (__selection == CAMERA_PRIMARY ? CAMERA_PRIMARY_FOCUS_MODE : CAMERA_SECONDARY_FOCUS_MODE);
+       SysLog(NID_MEDIA, "Enter. focusMode:%d", focusMode);
+
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+       SysTryReturn(NID_MEDIA, focusMode > CAMERA_FOCUS_MODE_NONE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(focusMode) is used. focusMode=%d", focusMode);
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pSupportedList (GetPropertyListN(key), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pSupportedList.get() != null, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pSupportedList->GetCount() > 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pSupportedList->Contains(Integer(focusMode))
+               , r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This mode(%d) is not supported in the device.\n",  focusMode);
+
+       // Set the __focusCallback to false not to call the focus callback in case of CAF.
+       r = ChangeFocusModeTo(__focusMode, focusMode);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. current focus mode is %d, new focus mode is %d", GetErrorMessage(r), __focusMode, focusMode);
+
+       __focusCallback = false;
+       __focusMode = focusMode;
+
+CATCH:
+       return r;
+}
+
+CameraFocusMode
+_CameraImpl::GetFocusMode(void) const
+{
+       return __focusMode;
+}
+
+result
+_CameraImpl::SetAutoFocus(bool callback)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter. callback:%d, focus mode:%d", callback, __focusMode);
+
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+       SysTryReturn(NID_MEDIA, __focusMode >= CAMERA_FOCUS_MODE_NORMAL && __focusMode <= CAMERA_FOCUS_MODE_CONTINUOUS_AUTO
+               , E_DEVICE_FAILED, E_DEVICE_FAILED, "[E_DEVICE_FAILED] In the focus mode:%d, this method is not working.", __focusMode);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_PREVIEW, E_INVALID_STATE, E_INVALID_STATE,
+               "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       r = HandleAutoFocus(__focusMode);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. focus mode is %d, callback:%s", GetErrorMessage(r), __focusMode, callback);
+
+       __focusCallback = callback;
+       return r;
+
+CATCH:
+       return r;
+}
+
+bool
+_CameraImpl::ReadyToAutoFocusCallback(void) const
+{
+       return __focusCallback;
+}
+
+result
+_CameraImpl::SetAutoFocusPoint(const Tizen::Base::Collection::IList& pointList)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int pointCount = 0;
+       int i = 0;
+       pointCount = pointList.GetCount();
+       SysLog(NID_MEDIA, "Enter. pointList count :%d", pointCount);
+
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_PREVIEW
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryReturn(NID_MEDIA, __focusMode == CAMERA_FOCUS_MODE_NORMAL || __focusMode == CAMERA_FOCUS_MODE_MACRO
+               , E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE , "[E_UNSUPPORTED_TYPE ] The method is not supported in the current focus mode(%d).", __focusMode);
+
+       SysTryCatch(NID_MEDIA, pointCount >= 0 && pointCount <= __supportedFocusPointCount
+               , r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(pointCount) is used. pointCount=%d");
+
+       if (pointCount > 0)
+       {
+               // Total input points
+               while (i < pointCount && i < MAX_FOCUS_POINT)
+               {
+                       Object* pObj = null;
+                       Point* pPoint = null;
+
+                       pObj = const_cast<Object*>(pointList.GetAt(i));
+                       SysTryCatch(NID_MEDIA, pObj != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(item) is used. %d item is not found.", i);
+
+                       pPoint = dynamic_cast<Point*>(pObj);
+                       SysTryCatch(NID_MEDIA, pPoint != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(item's format) is used. %d item's format is invalid.", i);
+
+                       err = camera_attr_set_af_area(__handle, pPoint->x, pPoint->y);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       SysLog(NID_MEDIA, "%dst af area(%d, %d) was set successfully", i, pPoint->x, pPoint->y);
+
+                       // Preserve the points
+                       __focusPoints[0][i] = pPoint->x;
+                       __focusPoints[1][i] = pPoint->y;
+
+                       i++;
+               }
+
+               if ( i < MAX_FOCUS_POINT )
+               {
+                       __focusPoints[0][i] = _INVALID_FOCUS_COORDINATE;
+                       __focusPoints[1][i] = _INVALID_FOCUS_COORDINATE;
+               }
+
+               __isFocusAreaSet = true;
+       }
+       else            //If pointCount is zero, Set focus point to defualt area.
+       {
+               if (__isFocusAreaSet)
+               {
+                       err = camera_attr_clear_af_area(__handle);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       SysLog(NID_MEDIA, "the focus area is changed to the center.");
+               }
+               for(int j = 0; j < MAX_FOCUS_POINT; j++)
+               {
+                       __focusPoints[0][j] = _INVALID_FOCUS_COORDINATE;
+                       __focusPoints[1][j] = _INVALID_FOCUS_COORDINATE;
+               }
+               __isFocusAreaSet = false;
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IList*
+_CameraImpl::GetAutoFocusPointN(void) const
+{
+       result r = E_SUCCESS;
+       int i = 0;
+
+       //Create new list
+       std::unique_ptr <_MediaSafeArrayList, _ListPtrUtil::Remover> pFocusPointList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pFocusPointList.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pFocusPointList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       while (__focusPoints[0][i] != _INVALID_FOCUS_COORDINATE && __focusPoints[1][i] != _INVALID_FOCUS_COORDINATE)
+       {
+               std::unique_ptr <Object> pPoint (new (std::nothrow) Point(__focusPoints[0][i], __focusPoints[1][i]));
+               SysTryCatch(NID_MEDIA, pPoint.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pFocusPointList->AddPtr(std::move(pPoint));
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               i++;
+       }
+       return pFocusPointList.release();
+
+CATCH:
+       return null;
+}
+
+result
+_CameraImpl::SetCaptureFormat(const Tizen::Graphics::PixelFormat format)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       camera_pixel_format_e attr = ::CAMERA_PIXEL_FORMAT_INVALID;
+       SysLog(NID_MEDIA, "Enter. format:%d", format);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       std::unique_ptr <IListT<Tizen::Graphics::PixelFormat>, _ListPtrUtil::Remover> pList (GetSupportedCaptureFormatListN(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryCatch(NID_MEDIA, pList->Contains(format), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT]. This format(%d) is not supported in the device.\n", format);
+
+       r = _CameraUtil::GetMmPixelFormat(format, attr);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. pixel format:%d", GetErrorMessage(r), format);
+
+       err = camera_set_capture_format(__handle, attr);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __captureFormat = format;
+
+CATCH:
+       return r;
+}
+
+Tizen::Graphics::PixelFormat
+_CameraImpl::GetCaptureFormat(void) const
+{
+       return __captureFormat;
+}
+
+
+Tizen::Base::Collection::IListT<Tizen::Graphics::PixelFormat>*
+_CameraImpl::GetSupportedCaptureFormatListN(void) const
+{
+       result r = E_SUCCESS;
+       _CameraOperationType operation = _COP_NONE;
+
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_CAPTURE_FORMAT : _COP_SECONDARY_CAPTURE_FORMAT);
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pIntegerList (GetPropertyListN(operation, _RESULT_INTEGER_LIST), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       std::unique_ptr <Tizen::Base::Collection::ArrayListT<Tizen::Graphics::PixelFormat>, _ListPtrUtil::Remover> pFormatList (new (std::nothrow) ArrayListT<Tizen::Graphics::PixelFormat>(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pFormatList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. %d item is not found.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's format is invalid.", i);
+
+               r = pFormatList->Add((Tizen::Graphics::PixelFormat)pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "Pixel format : %d was added.", pInteger->ToInt());
+       }
+
+       return pFormatList.release();
+
+CATCH:
+       return null;
+}
+
+result
+_CameraImpl::SetPreviewFormat(const Tizen::Graphics::PixelFormat format)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       camera_pixel_format_e attr = ::CAMERA_PIXEL_FORMAT_INVALID;
+       SysLog(NID_MEDIA, "Enter. format:%d", format);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_CAPTURED , E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       std::unique_ptr <IListT<Tizen::Graphics::PixelFormat>, _ListPtrUtil::Remover> pList (GetSupportedPreviewFormatListN(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryCatch(NID_MEDIA, pList->Contains(format), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+               "[E_UNSUPPORTED_FORMAT]. This format(%d) is not supported in the device.\n", format);
+
+       r = _CameraUtil::GetMmPixelFormat(format, attr);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. pixel format:%d", GetErrorMessage(r), format);
+
+       r = __pCoordinator->SetCameraSourceFormat(attr);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __previewFormat = format;
+
+CATCH:
+       return r;
+}
+
+Tizen::Graphics::PixelFormat
+_CameraImpl::GetPreviewFormat(void) const
+{
+       return __previewFormat;
+}
+
+
+Tizen::Base::Collection::IListT<Tizen::Graphics::PixelFormat>*
+_CameraImpl::GetSupportedPreviewFormatListN(void) const
+{
+       result r = E_SUCCESS;
+       _CameraOperationType operation = _COP_NONE;
+
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_PREVIEW_FORMAT : _COP_SECONDARY_PREVIEW_FORMAT);
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pIntegerList (GetPropertyListN(operation, _RESULT_INTEGER_LIST), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       std::unique_ptr <Tizen::Base::Collection::ArrayListT<Tizen::Graphics::PixelFormat>, _ListPtrUtil::Remover> pFormatList (new (std::nothrow) ArrayListT<Tizen::Graphics::PixelFormat>(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pFormatList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. %d item is not found.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's format is invalid.", i);
+
+               r = pFormatList->Add((Tizen::Graphics::PixelFormat)pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "Pixel format : %d was added.", pInteger->ToInt());
+       }
+
+       return pFormatList.release();
+
+CATCH:
+       return null;
+}
+
+result
+_CameraImpl::SetIsoLevel(CameraIsoLevel isoLevel)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+
+       camera_attr_iso_e attr = ::CAMERA_ATTR_ISO_AUTO;
+       SysLog(NID_MEDIA, "Enter. isoLevel:%d", isoLevel);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryReturn(NID_MEDIA, isoLevel >= CAMERA_ISO_DEFAULT && isoLevel <= CAMERA_ISO_MAX , E_OUT_OF_RANGE, E_OUT_OF_RANGE
+               , "[E_OUT_OF_RANGE] This isoLevel(%d) is out of range.", isoLevel);
+
+       if (__isPoweredOn)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ISO_LEVEL : _COP_SECONDARY_ISO_LEVEL);
+
+               std::unique_ptr <IList, _ListPtrUtil::Remover> pIsoList (GetPropertyListN(operation, itemType), _ListPtrUtil::remover);
+               SysTryCatch(NID_MEDIA, pIsoList.get() != null, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The operation:%d is not supported.", operation);
+               SysTryCatch(NID_MEDIA, pIsoList->GetCount() > 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+               SysTryCatch(NID_MEDIA, pIsoList->Contains(Integer(isoLevel)) || isoLevel == CAMERA_ISO_DEFAULT || isoLevel == CAMERA_ISO_MIN
+                        || isoLevel == CAMERA_ISO_MAX, r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This isoLevel(%d) is not supported in the device.\n",  isoLevel);
+
+               r = _CameraUtil::GetMmIso(isoLevel, attr);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. isoLevel :%d", GetErrorMessage(r), isoLevel);
+
+               err = camera_attr_set_iso(__handle, attr);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. isoLevel :%d", GetErrorMessage(r), isoLevel);
+       }
+       __isoLevel = isoLevel;
+
+CATCH:
+       return r;
+}
+
+
+CameraIsoLevel
+_CameraImpl::GetIsoLevel(void) const
+{
+       return __isoLevel;
+}
+
+result
+_CameraImpl::SetPreviewFrameRate(int fps)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       camera_attr_fps_e attr = ::CAMERA_ATTR_FPS_AUTO;
+       SysLog(NID_MEDIA, "Enter. fps:%d", fps);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED, E_INVALID_STATE, E_INVALID_STATE,
+               "[E_INVALID_STATE] Camera is in an invalid state. This method is working in CAMERA_STATE_INITIALIZED state. Current state is :%d", (
+                                       int) state);
+
+       std::unique_ptr <IListT<int>, _ListPtrUtil::Remover> pList (GetSupportedPreviewFrameRateListN(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryCatch(NID_MEDIA, pList->Contains(fps), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+               "[E_OUT_OF_RANGE]. This fps(%d) is out of range.", fps);
+
+       r = _CameraUtil::GetMmFps(fps, attr);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. fps:%d", GetErrorMessage(r), fps);
+
+       err = camera_attr_set_preview_fps(__handle, attr);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __fps = fps;
+
+CATCH:
+       return r;
+}
+
+int
+_CameraImpl::GetPreviewFrameRate(void) const
+{
+       return __fps;
+}
+
+Tizen::Base::Collection::IListT <int>*
+_CameraImpl::GetSupportedPreviewFrameRateListN(void) const
+{
+       result r = E_SUCCESS;
+       _CameraOperationType operation = _COP_NONE;
+
+       operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_PREVIEW_FRAMERATE : _COP_SECONDARY_PREVIEW_FRAMERATE);
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pIntegerList (GetPropertyListN(operation, _RESULT_INTEGER_LIST), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       std::unique_ptr <Tizen::Base::Collection::ArrayListT<int>, _ListPtrUtil::Remover> pListT (new (std::nothrow) ArrayListT<int>(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pListT.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pListT->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. %d item is not found.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's fps is invalid.", i);
+
+               r = pListT->Add(pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "FPS : %d was added.", pInteger->ToInt());
+       }
+
+       return pListT.release();
+
+CATCH:
+       return null;
+}
+
+Tizen::Base::Collection::IListT<int>*
+_CameraImpl::GetSupportedPreviewFrameRateListN(const Tizen::Graphics::Dimension& dim) const
+{
+       result r = E_SUCCESS;
+       Object *pObj = null;
+       _CameraDeviceType device = _CAMERA_DEVICE_NONE;
+       _ResultType  itemType = _RESULT_NONE;
+
+       device = (__selection == CAMERA_PRIMARY ? _CAMERA_DEVICE_PRIMARY : _CAMERA_DEVICE_SECONDARY);
+       pObj = _CameraCapability::GetSupportedPreviewFrameRateN(device, _QUERY_LIST, dim, itemType);
+       std::unique_ptr <ArrayList, _ListPtrUtil::Remover> pIntegerList (dynamic_cast<ArrayList*>(pObj), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       std::unique_ptr <Tizen::Base::Collection::ArrayListT<int>, _ListPtrUtil::Remover> pListT (new (std::nothrow) ArrayListT<int>(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pListT.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pListT->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. %d item is not found.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's fps is invalid.", i);
+
+               r = pListT->Add(pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "FPS : %d was added.", pInteger->ToInt());
+       }
+
+       return pListT.release();
+
+CATCH:
+       return null;
+}
+
+result
+_CameraImpl::SetExifOrientation(CameraExifOrientation orientation)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter. orientation:%d", orientation);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryCatch(NID_MEDIA, CAMERA_EXIF_ORIENTATION_TOP_LEFT <= orientation && orientation <= CAMERA_EXIF_ORIENTATION_LEFT_BOTTOM,
+               r = E_OUT_OF_RANGE, r, "[E_OUT_OF_RANGE]  This orientation(%d) is out of range.", orientation);
+
+       if ( __isPoweredOn )
+       {
+               __pCoordinator->SetCameraOrientation(orientation);
+       }
+       __exifOrientation = orientation;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CameraImpl::SetExifGpsCoordinates(double latitude, double longitude, float altitude)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. latitude:%f, longitude:%f, altitude:%f", latitude, longitude, altitude);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       SysTryCatch(NID_MEDIA, -90.0 <= latitude && latitude <= 90.0 , r = E_OUT_OF_RANGE, r, "[E_OUT_OF_RANGE] This latitude(%f) is out of range.", latitude);
+       SysTryCatch(NID_MEDIA, -180.0 <= longitude && longitude <= 180.0 , r = E_OUT_OF_RANGE, r, "[E_OUT_OF_RANGE] This longitude(%f) is out of range.", longitude);
+
+       if ( __isPoweredOn )
+       {
+               err = camera_attr_set_geotag(__handle, latitude, longitude, (double)altitude);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. latitude:%f, longitude:%f, altitude:%f", GetErrorMessage(r), latitude, longitude, altitude);
+       }
+       __exifLatitude = latitude;
+       __exifLongitude = longitude;
+       __exifAltitude = altitude;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CameraImpl::DisableExifGpsCoordinates(void)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Disable exif gps co-ordinates");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. This method is not working in this state. Current state is :%d", state);
+
+       err = camera_attr_remove_geotag(__handle);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __exifLatitude = _CAMERA_EXIF_GPS_INVALID_LATITUDE;
+       __exifLongitude = _CAMERA_EXIF_GPS_INVALID_LONGITUDE;
+       __exifAltitude = 0;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CameraImpl::SetFlip(CameraFlipType flip)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       camera_flip_e attr = ::CAMERA_FLIP_NONE;
+       String key = (__selection == CAMERA_PRIMARY ? CAMERA_PRIMARY_FLIP : CAMERA_SECONDARY_FLIP);
+       SysLog(NID_MEDIA, "Enter. flip:%d", flip);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED, E_INVALID_STATE, E_INVALID_STATE,
+               "[E_INVALID_STATE] Camera is in an invalid state. This method is working in CAMERA_STATE_INITIALIZED state. Current state is :%d", state);
+       SysTryReturn(NID_MEDIA, flip >= CAMERA_FLIP_NONE && flip <= CAMERA_FLIP_VERTICAL , E_INVALID_ARG , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(flip) is used. flip=%d.", flip);
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pSupportedList (GetPropertyListN(key), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pSupportedList.get() != null, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pSupportedList->GetCount() > 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pSupportedList->Contains(Integer(flip)), r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This flip(%d) is not supported in the device.\n",  flip);
+
+       r = _CameraUtil::GetMmFlip(__selection, flip, attr);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. flip:%d", GetErrorMessage(r), flip);
+
+       err = camera_attr_set_stream_flip(__handle, attr);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. flip:%d", GetErrorMessage(r), flip);
+
+       __flip = flip;
+
+CATCH:
+       return r;
+}
+
+CameraFlipType
+_CameraImpl::GetFlip(void) const
+{
+       return __flip;
+}
+
+result
+_CameraImpl::SetPreviewRotation(CameraRotation rotation)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       camera_rotation_e attr = ::CAMERA_ROTATION_NONE;
+       String key = (__selection == CAMERA_PRIMARY ? CAMERA_PRIMARY_PREVIEW_ROTATION : CAMERA_SECONDARY_PREVIEW_ROTATION);
+       SysLog(NID_MEDIA, "Enter. rotation:%d", rotation);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED, E_INVALID_STATE, E_INVALID_STATE,
+               "[E_INVALID_STATE] Camera is in an invalid state. This method is working in CAMERA_STATE_INITIALIZED state. Current state is :%d", state);
+       SysTryReturn(NID_MEDIA, rotation >= CAMERA_ROTATION_NONE && rotation <= CAMERA_ROTATION_270, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(rotation) is used. rotation=%d.", rotation);
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pSupportedList (GetPropertyListN(key), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pSupportedList.get() != null, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pSupportedList->GetCount() > 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pSupportedList->Contains(Integer(rotation)), r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This rotation(%d) is not supported in the device.\n",  rotation);
+
+       r = _CameraUtil::GetMmRotation(rotation, attr);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), rotation);
+
+       err = camera_attr_set_stream_rotation(__handle, attr);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera rotate stream failed. displayHandle:%d, previewedData:%d", GetErrorMessage(r), __previewRegionHandle, __previewProcessing);
+
+       __previewRotation = rotation;
+
+CATCH:
+       return r;
+}
+
+CameraRotation
+_CameraImpl::GetPreviewRotation(void) const
+{
+       return __previewRotation;
+}
+
+result
+_CameraImpl::SetMeteringMode(CameraMeteringMode meteringMode)
+{
+       result r = E_SUCCESS;
+       CameraState state = CAMERA_STATE_ERROR;
+       int err = MM_SUCCESS;
+       camera_attr_exposure_mode_e attr = ::CAMERA_ATTR_EXPOSURE_MODE_OFF;
+       String key = (__selection == CAMERA_PRIMARY ? CAMERA_PRIMARY_METERING_MODE : CAMERA_SECONDARY_METERING_MODE);
+       SysLog(NID_MEDIA, "Enter. meteringMode:%d", meteringMode);
+
+       SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera was not powered on.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == CAMERA_STATE_INITIALIZED || state == CAMERA_STATE_PREVIEW || state == CAMERA_STATE_CAPTURED
+               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This method is not working in this state. Current state is :%d", state);
+       SysTryReturn(NID_MEDIA, meteringMode >= CAMERA_METERING_MODE_NONE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This mode %d cannot be set.", meteringMode);
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pSupportedList (GetPropertyListN(key), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pSupportedList.get() != null, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pSupportedList->GetCount() > 0, r = E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION]");
+       SysTryCatch(NID_MEDIA, pSupportedList->Contains(Integer(meteringMode)) || meteringMode == CAMERA_METERING_MODE_NONE
+               , r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This mode(%d) is not supported in the device.\n",  meteringMode);
+
+       r = _CameraUtil::GetMmMeteringMode(meteringMode, attr);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), meteringMode);
+
+       err = camera_attr_set_exposure_mode(__handle, attr);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera metering mode failed. meteringMode:%d", GetErrorMessage(r), meteringMode);
+
+       __meteringMode = meteringMode;
+
+CATCH:
+       return r;
+}
+
+CameraMeteringMode
+_CameraImpl::GetMeteringMode(void) const
+{
+       return __meteringMode;
+}
+
+result
+_CameraImpl::ConvertResult(int err) const
+{
+       result r = E_SYSTEM;
+       if (err != ::CAMERA_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "MM Err:0x%x", err);
+       }
+
+       // Global error
+       if (err == ::CAMERA_ERROR_NONE)
+       {
+               r = E_SUCCESS;
+       }
+       else if (err == ::CAMERA_ERROR_INVALID_PARAMETER)
+       {
+               r = E_INVALID_ARG;
+       }
+       else if (err == ::CAMERA_ERROR_INVALID_STATE)
+       {
+               r = E_INVALID_STATE;
+       }
+       else if (err == ::CAMERA_ERROR_OUT_OF_MEMORY)
+       {
+               r = E_OUT_OF_MEMORY;
+       }
+       else if (err == ::CAMERA_ERROR_DEVICE)
+       {
+               r = E_DEVICE_FAILED;
+       }
+       else if (err == ::CAMERA_ERROR_INVALID_OPERATION
+                       || err == ::CAMERA_ERROR_SECURITY_RESTRICTED)
+       {
+               r = E_SYSTEM;
+       }
+       else if (err == ::CAMERA_ERROR_DEVICE_BUSY
+                       || err == ::CAMERA_ERROR_SOUND_POLICY)
+       {
+               r = E_DEVICE_BUSY;
+       }
+       else if (err == ::CAMERA_ERROR_DEVICE_NOT_FOUND)
+       {
+               r = E_DEVICE_UNAVAILABLE;
+       }
+       else
+       {
+               r = E_UNKNOWN;
+       }
+
+       return r;
+}
+
+camera_state_e
+_CameraImpl::GetMmState(void) const
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       camera_state_e mmState = ::CAMERA_STATE_NONE;
+
+       err = camera_get_state(__handle, &mmState);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return mmState;
+
+CATCH:
+       return ::CAMERA_STATE_NONE;
+}
+
+void
+_CameraImpl::SetState(CameraState state)
+{
+       __state = state;
+}
+
+_CameraEvent*
+_CameraImpl::GetEvent(void) const
+{
+       return __pCameraEvent;
+}
+
+CameraSelection
+_CameraImpl::GetSelection(void) const
+{
+       return __selection;
+}
+
+int
+_CameraImpl::GetPreviewProcessing(void) const
+{
+       return __previewProcessing;
+}
+
+result
+_CameraImpl::EnqueueData(_CameraBuffer& cameraBuffer)
+{
+       result r = E_SUCCESS;
+       _CameraBuffer* pCameraBuffer = null;
+       _CameraBufferType bufferType = cameraBuffer.GetBufferType();
+
+       SysTryCatch(NID_MEDIA, cameraBuffer.GetLimit() > 0, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
+
+       pCameraBuffer = new (std::nothrow) _CameraBuffer();
+       SysTryCatch(NID_MEDIA, pCameraBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pCameraBuffer->Construct(cameraBuffer);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
+
+       switch (bufferType)
+       {
+       case _CAMERA_BUFFER_CAPTURE:
+               r = __pCaptureBufferQueue->Enqueue(*pCameraBuffer);
+               break;
+
+       case _CAMERA_BUFFER_PREVIEW:
+               r = __pPreviewBufferQueue->Enqueue(*pCameraBuffer);
+               break;
+
+       default:
+               r = E_INVALID_ARG;
+               SysLogException(NID_MEDIA, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(bufferType) is used. bufferType=%d.", bufferType);
+               break;
+       }
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
+
+       return r;
+
+CATCH:
+       if (pCameraBuffer != null)
+       {
+               delete pCameraBuffer;
+       }
+
+       return r;
+}
+
+
+_CameraBuffer*
+_CameraImpl::DequeueDataN(_CameraBufferType bufferType)
+{
+       result r = E_SUCCESS;
+       _CameraBuffer* pBuffer = null;
+
+       switch (bufferType)
+       {
+       case _CAMERA_BUFFER_CAPTURE:
+               pBuffer = static_cast<_CameraBuffer*>(__pCaptureBufferQueue->Dequeue());
+               break;
+
+       case _CAMERA_BUFFER_PREVIEW:
+               pBuffer = static_cast<_CameraBuffer*>(__pPreviewBufferQueue->Dequeue());
+               break;
+
+       case _CAMERA_BUFFER_NONE:
+       default:
+               break;
+       }
+       SysTryCatch(NID_MEDIA, pBuffer != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] Propagating. bufferType:%d", GetErrorMessage(E_OBJ_NOT_FOUND), bufferType);
+
+       return pBuffer;
+
+CATCH:
+       SysLogException(NID_MEDIA, E_UNDERFLOW, "[E_UNDERFLOW] Queue is empty.");
+       return null;
+}
+
+int
+_CameraImpl::GetDataCount(_CameraBufferType bufferType)
+{
+       int count = 0;
+       switch (bufferType)
+       {
+       case _CAMERA_BUFFER_CAPTURE:
+               count = __pCaptureBufferQueue->GetCount();
+               break;
+
+       case _CAMERA_BUFFER_PREVIEW:
+               count = __pPreviewBufferQueue->GetCount();
+               break;
+
+       case _CAMERA_BUFFER_NONE:
+       default:
+               break;
+       }
+       return count;
+}
+
+_CameraCoordinator*
+_CameraImpl::GetCoordinator(void)
+{
+       return __pCoordinator;
+}
+
+bool
+_CameraImpl::IsZeroShutterLag(void) const
+{
+       return __zeroShutterLag;
+}
+
+result
+_CameraImpl::SetProperty(_CameraOperationType operation, int min, int max, int value)
+{
+       result r = E_SUCCESS;
+       bool supported = false;
+       int mmMin = 0;
+       int mmMax = 0;
+       int mmValue = 0;
+       int err = MM_SUCCESS;
+
+       SysLog(NID_MEDIA, "Enter. operation:%d, min:%d, max:%d, value:%d", operation, min, max, value);
+
+       SysTryReturn(NID_MEDIA, max - min > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(Min, Max) is used. Min:%d, Max:%d wrong. value is :%d", min, max, value);
+       SysTryReturn(NID_MEDIA, value >= min && value <= max, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(Min, Max) is used. Min:%d, Max:%d value is :%d", min, max, value);
+
+       supported = _CameraCapability::IsSupported(operation);
+       SysTryReturn(NID_MEDIA, supported == true, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The operation:%d is not supported.", operation);
+
+       switch (operation)
+       {
+       case _COP_PRIMARY_BRIGHTNESS:
+       case _COP_SECONDARY_BRIGHTNESS:
+               err = camera_attr_get_brightness_range(__handle, &mmMin, &mmMax);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera get attribute range failed. operation:%d, value:%d", GetErrorMessage(r), operation, value);
+
+               mmValue = (int) ((double) (mmMax - mmMin) / (double) (max - min) * (double) value);
+               if (mmValue < mmMin)
+               {
+                       mmValue = mmMin;
+               }
+               else if (mmValue > mmMax)
+               {
+                       mmValue = mmMax;
+               }
+               err = camera_attr_set_brightness(__handle, mmValue);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera set attribute range failed. operation:%d, value:%d, mmValue:%d", GetErrorMessage(r), operation, value, mmValue);
+               break;
+
+       case _COP_PRIMARY_CONTRAST:
+       case _COP_SECONDARY_CONTRAST:
+               err = camera_attr_get_contrast_range(__handle, &mmMin, &mmMax);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera get attribute range failed. operation:%d, value:%d", GetErrorMessage(r), operation, value);
+
+               mmValue = (int) ((double) (mmMax - mmMin) / (double) (max - min) * (double) value);
+               if (mmValue < mmMin)
+               {
+                       mmValue = mmMin;
+               }
+               else if (mmValue > mmMax)
+               {
+                       mmValue = mmMax;
+               }
+               err = camera_attr_set_contrast(__handle, mmValue);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera set attribute range failed. operation:%d, value:%d, mmValue:%d", GetErrorMessage(r), operation, value, mmValue);
+               break;
+
+       case _COP_PRIMARY_EXPOSURE:
+       case _COP_SECONDARY_EXPOSURE:
+               err = camera_attr_get_exposure_range(__handle, &mmMin, &mmMax);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera get attribute range failed. operation:%d, value:%d", GetErrorMessage(r), operation, value);
+
+               mmValue = (int) ((double) (mmMax - mmMin) / (double) (max - min) * (double) value);
+               if (mmValue < mmMin)
+               {
+                       mmValue = mmMin;
+               }
+               else if (mmValue > mmMax)
+               {
+                       mmValue = mmMax;
+               }
+               err = camera_attr_set_exposure(__handle, mmValue);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera set attribute range failed. operation:%d, value:%d, mmValue:%d", GetErrorMessage(r), operation, value, mmValue);
+               break;
+
+       case _COP_PRIMARY_ZOOM_LEVEL:
+       case _COP_SECONDARY_ZOOM_LEVEL:
+               err = camera_attr_get_zoom_range(__handle, &mmMin, &mmMax);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera get attribute range failed. operation:%d, value:%d", GetErrorMessage(r), operation, value);
+
+               mmValue = (int) ((double) (mmMax - mmMin) / (double) (max - min) * (double) value);
+               if (mmValue < mmMin)
+               {
+                       mmValue = mmMin;
+               }
+               else if (mmValue > mmMax)
+               {
+                       mmValue = mmMax;
+               }
+               err = camera_attr_set_zoom(__handle, mmValue);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera set attribute range failed. operation:%d, value:%d, mmValue:%d", GetErrorMessage(r), operation, value, mmValue);
+               break;
+
+       default:
+               break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CameraImpl::GetProperty(_CameraOperationType operation, int& mmMin, int& mmMax) const
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       switch (operation)
+       {
+       case _COP_PRIMARY_ZOOM_LEVEL:
+       case _COP_SECONDARY_ZOOM_LEVEL:
+               err = camera_attr_get_zoom_range(__handle, &mmMin, &mmMax);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera get attribute range failed. operation:%d", GetErrorMessage(r), operation);
+               break;
+
+       default:
+               break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IList*
+_CameraImpl::GetPropertyListN(_CameraOperationType operation, _ResultType itemQueryType) const
+{
+       result r = E_SUCCESS;
+       _ResultType itemType = _RESULT_NONE;
+
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pList (_CameraCapability::GetListN(operation, itemType), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pList.get() != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryCatch(NID_MEDIA, itemType == itemQueryType, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  itemQueryType%d, itemType:%d are not same", itemQueryType, itemType);
+
+       return pList.release();
+
+CATCH:
+       return null;
+}
+
+Tizen::Base::Collection::IList*
+_CameraImpl::GetPropertyListN(const Tizen::Base::String& key) const
+{
+       result r = E_SUCCESS;
+       _CapabilityImpl* pCapability = null;
+
+       std::unique_ptr <ArrayList, _ListPtrUtil::Remover> pList (new (std::nothrow) ArrayList(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pList.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pCapability = _CapabilityImpl::GetInstance();
+       SysTryCatch(NID_MEDIA, pCapability != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CapabilityImpl instance is not available.");
+       r = pCapability->GetValueN(key, *(pList.get()));                //TODO check
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList.release();
+
+CATCH:
+       return null;
+}
+
+result
+_CameraImpl::ReloadConfiguration(int reload)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. reload:0x%x", reload);
+
+       if (reload & _RELOAD_PREVIEW_RESOLUTION)
+       {
+               err = camera_set_preview_resolution(__handle, __previewResolution.width, __previewResolution.height);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_CAPTURE_RESOLUTION)
+       {
+               err = camera_set_capture_resolution(__handle, __captureResolution.width, __captureResolution.height);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_PREVIEW_FORMAT)
+       {
+               camera_pixel_format_e attr = ::CAMERA_PIXEL_FORMAT_INVALID;
+               r = _CameraUtil::GetMmPixelFormat(__previewFormat, attr);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. pixel format:%d", GetErrorMessage(r), __previewFormat);
+
+               err = camera_set_preview_format(__handle, attr);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_INTERNAL_PREVIEW_FORMAT)
+       {
+               err = camera_set_preview_format(__handle, __pCoordinator->GetCameraSourceFormat());
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_CAPTURE_FORMAT)
+       {
+               camera_pixel_format_e attr = ::CAMERA_PIXEL_FORMAT_INVALID;
+               r = _CameraUtil::GetMmPixelFormat(__captureFormat, attr);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. pixel format:%d", GetErrorMessage(r), __captureFormat);
+
+               err = camera_set_capture_format(__handle, attr);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_FPS)
+       {
+               camera_attr_fps_e attr = ::CAMERA_ATTR_FPS_AUTO;
+               r = _CameraUtil::GetMmFps(__fps, attr);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. fps:%d", GetErrorMessage(r), __fps);
+
+               err = camera_attr_set_preview_fps(__handle, attr);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_BRIGHTNESS)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_BRIGHTNESS : _COP_SECONDARY_BRIGHTNESS);
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       r = SetProperty(operation, _MIN_PROPERTY, _MAX_PROPERTY, __brightness);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       if (reload & _RELOAD_CONTRAST)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_CONTRAST : _COP_SECONDARY_CONTRAST);
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       r = SetProperty(operation, _MIN_PROPERTY, _MAX_PROPERTY, __contrast);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       if (reload & _RELOAD_EXPOSURE)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_EXPOSURE : _COP_SECONDARY_EXPOSURE);
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       r = SetProperty(operation, _MIN_PROPERTY, _MAX_PROPERTY, __exposure);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       if (reload & _RELOAD_MAX_ZOOM_LEVEL)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ZOOM_LEVEL : _COP_SECONDARY_ZOOM_LEVEL);
+               int minZoom = 0;
+               int maxZoom = 0;
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       r = GetProperty(operation, minZoom, maxZoom);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               __maxZoomLevel = maxZoom - minZoom;
+       }
+       if (reload & _RELOAD_ZOOM_LEVEL)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ZOOM_LEVEL : _COP_SECONDARY_ZOOM_LEVEL);
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       int zoomLevel = 0;
+                       while (zoomLevel < __zoomLevel)
+                       {
+                               zoomLevel++;
+                               r = SetProperty(operation, __minZoomLevel, __maxZoomLevel, zoomLevel);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+       }
+       if (reload & _RELOAD_EFFECT)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_EFFECT : _COP_SECONDARY_EFFECT);
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       camera_attr_effect_mode_e attr = ::CAMERA_ATTR_EFFECT_NONE;
+                       r = _CameraUtil::GetMmEffect(__effect, attr);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. effect:%d", GetErrorMessage(r), __effect);
+
+                       err = camera_attr_set_effect(__handle, attr);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       if (reload & _RELOAD_WB)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_WHITE_BALANCE : _COP_SECONDARY_WHITE_BALANCE);
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       camera_attr_whitebalance_e attr = ::CAMERA_ATTR_WHITE_BALANCE_NONE;
+                       r = _CameraUtil::GetMmWhiteBalance(__wb, attr);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. whiteBalance:%d", GetErrorMessage(r), __wb);
+
+                       err = camera_attr_set_whitebalance(__handle, attr);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       if ((reload & _RELOAD_QUALITY) && (__quality != CAMERA_QUALITY_NORMAL))
+       {
+               int attr = 0;
+               r = _CameraUtil::GetMmQuality(__quality, attr);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. quality:%d", GetErrorMessage(r), __quality);
+
+               err = camera_attr_set_image_quality(__handle, attr);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_ISO)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ISO_LEVEL : _COP_SECONDARY_ISO_LEVEL);
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       camera_attr_iso_e attr = ::CAMERA_ATTR_ISO_AUTO;
+
+                       r = _CameraUtil::GetMmIso(__isoLevel, attr);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. iso:%d", GetErrorMessage(r), __isoLevel);
+
+                       err = camera_attr_set_iso(__handle, attr);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       if ((reload & _RELOAD_EXIF_ORIENTATION) && (__exifOrientation != CAMERA_EXIF_ORIENTATION_NONE))         //TODO check whether the exif data is lasting or one-time.
+       {
+               __pCoordinator->SetCameraOrientation(__exifOrientation);
+       }
+       if (reload & _RELOAD_EXIF_GPS_COORDINATES)
+       {
+               if ( __exifLatitude < _CAMERA_EXIF_GPS_INVALID_LATITUDE && __exifLongitude < _CAMERA_EXIF_GPS_INVALID_LONGITUDE )
+               {
+                       err = camera_attr_set_geotag(__handle, __exifLatitude, __exifLongitude, (double)__exifAltitude);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else
+               {
+                       err = camera_attr_remove_geotag(__handle);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       if (reload & _RELOAD_FLASH)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_FLASH_MODE : _COP_SECONDARY_FLASH_MODE);
+
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       camera_attr_flash_mode_e attr = ::CAMERA_ATTR_FLASH_MODE_OFF;
+                       r = _CameraUtil::GetMmFlashMode(__flashMode, attr);
+
+                       err = camera_attr_set_flash_mode(__handle, attr);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       if (reload & _RELOAD_FLIP)      // Flip shoud be called before rotation set.
+       {
+               String key = (__selection == CAMERA_PRIMARY ? CAMERA_PRIMARY_FLIP : CAMERA_SECONDARY_FLIP);
+               std::unique_ptr <IList, _ListPtrUtil::Remover> pSupportedList (GetPropertyListN(key), _ListPtrUtil::remover);
+
+               if (pSupportedList.get() != null)
+               {
+                       if (pSupportedList->GetCount() > 0)
+                       {
+                               camera_flip_e attr = ::CAMERA_FLIP_NONE;
+                               r = _CameraUtil::GetMmFlip(__selection, __flip, attr);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. flip:%d", GetErrorMessage(r), __flip);
+
+                               err = camera_attr_set_stream_flip(__handle, attr);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+       }
+       if (reload & _RELOAD_PREVIEW_ROTATION)
+       {
+               String key = (__selection == CAMERA_PRIMARY ? CAMERA_PRIMARY_PREVIEW_ROTATION : CAMERA_SECONDARY_PREVIEW_ROTATION);
+               std::unique_ptr <IList, _ListPtrUtil::Remover> pSupportedList (GetPropertyListN(key), _ListPtrUtil::remover);
+
+               if (pSupportedList.get() != null)
+               {
+                       if (pSupportedList->GetCount() > 0)
+                       {
+                               camera_rotation_e attr = ::CAMERA_ROTATION_NONE;
+                               r = _CameraUtil::GetMmRotation(__previewRotation, attr);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. rotation:%d", GetErrorMessage(r), __previewRotation);
+
+                               err = camera_attr_set_stream_rotation(__handle, attr);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+       }
+       if (reload & _RELOAD_PREVIEW_PREPARE)
+       {
+               if ((__previewProcessing & _PREVIEW_PRE_PROCESSING) || (__previewProcessing & _PREVIEW_POST_PROCESSING))
+               {
+                       err = camera_set_preview_cb(__handle, PreviewCb, this);
+               }
+               else
+               {
+                       err = camera_unset_preview_cb(__handle);
+               }
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Preview callback setting failed. Process:%b", GetErrorMessage(r), __previewProcessing);
+
+               if ( __previewRegionHandle != _BufferInfoImpl::INVALID_BUFFER_HANDLE )
+               {
+                       err = camera_set_display(__handle, __previewDisplayType, (camera_display_h)__previewRegionHandle);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera set display failed. displayHandle:%d, Process:%b",
+                               GetErrorMessage(r), __previewRegionHandle, __previewProcessing);
+
+                       if ( __previewDisplayType == ::CAMERA_DISPLAY_TYPE_X11 )
+                       {
+                               err = camera_set_x11_display_mode(__handle, ::CAMERA_DISPLAY_MODE_FULL);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera set display mode failed. displayHandle:%d, Process:%b",
+                                       GetErrorMessage(r), __previewRegionHandle, __previewProcessing);
+
+                               err = camera_set_x11_display_visible(__handle, true);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera enabling display visible failed. displayHandle:%d, Process:%b",
+                                       GetErrorMessage(r), __previewRegionHandle, __previewProcessing);
+                               /*
+                               camera_rotation_e attr = ::CAMERA_ROTATION_NONE;
+                               r = _CameraUtil::GetMmRotation(__displayRotationType, attr);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                               err = camera_set_x11_display_rotation(__handle, attr);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera rotate display failed. displayHandle:%d, Process:%b, __displayRotationType:%d",
+                                       GetErrorMessage(r), __previewRegionHandle, __previewProcessing, __displayRotationType);
+                               */
+                       }
+               }
+               else
+               {
+                       err = camera_set_display(__handle, ::CAMERA_DISPLAY_TYPE_NONE, null);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera set display(null) failed. Process:%b", GetErrorMessage(r), __previewProcessing);
+               }
+       }
+       if (reload & _RELOAD_FOCUS_MODE)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_FOCUS_MODE : _COP_SECONDARY_FOCUS_MODE);
+
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       r = ChangeFocusModeTo(__focusMode, __focusMode);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. focus mode is %d", GetErrorMessage(r), __focusMode);
+               }
+       }
+       if (reload & _RELOAD_METERING_MODE)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_METERING_MODE : _COP_SECONDARY_METERING_MODE);
+
+               if ( _CameraCapability::IsSupported(operation))
+               {
+                       camera_attr_exposure_mode_e attr = ::CAMERA_ATTR_EXPOSURE_MODE_OFF;
+                       r = _CameraUtil::GetMmMeteringMode(__meteringMode, attr);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. metering:%d", GetErrorMessage(r), __meteringMode);
+
+                       err = camera_attr_set_exposure_mode(__handle, attr);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. metering:%d", GetErrorMessage(r), __meteringMode);
+               }
+       }
+       if (reload & _RELOAD_EXTRA)
+       {
+               err = camera_attr_enable_tag(__handle, true);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera enabling tag failed.", GetErrorMessage(r));
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CameraImpl::LoadDefaultConfiguration(int reload)
+{
+       result r = E_SUCCESS;
+       Object* pObj = null;
+       SysLog(NID_MEDIA, "Enter.");
+
+       // Preview resolution
+       if (reload & _RELOAD_PREVIEW_RESOLUTION)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               _ResultType itemType = _RESULT_NONE;
+               Dimension* pDim = null;
+
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_PREVIEW_RESOLUTION : _COP_SECONDARY_PREVIEW_RESOLUTION);
+               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
+               SysTryCatch(NID_MEDIA, itemType == _RESULT_DIMENSION, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pDim = dynamic_cast<Dimension*>(pObj);
+               SysTryCatch(NID_MEDIA, pDim != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The item is wrong. preview resolution.");
+               __deviceDefaultPreviewResolution = *pDim;
+               delete pObj;
+               pObj = null;
+
+               __previewResolution = __deviceDefaultPreviewResolution;
+       }
+
+       // Capture resolution
+       if (reload & _RELOAD_CAPTURE_RESOLUTION)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               _ResultType itemType = _RESULT_NONE;
+               Dimension* pDim = null;
+
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_CAPTURE_RESOLUTION : _COP_SECONDARY_CAPTURE_RESOLUTION);
+               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
+               SysTryCatch(NID_MEDIA, itemType == _RESULT_DIMENSION, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pDim = dynamic_cast<Dimension*>(pObj);
+               SysTryCatch(NID_MEDIA, pDim != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The item is wrong. capture resolution.");
+               __deviceDefaultCaptureResolution = *pDim;
+               delete pObj;
+               pObj = null;
+
+               __captureResolution = __deviceDefaultCaptureResolution;
+       }
+
+       // Preview format
+       if (reload & _RELOAD_PREVIEW_FORMAT)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               _ResultType itemType = _RESULT_NONE;
+               Integer *pInteger = null;
+
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_PREVIEW_FORMAT : _COP_SECONDARY_PREVIEW_FORMAT);
+               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
+               SysTryCatch(NID_MEDIA, itemType == _RESULT_INTEGER, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The item is wrong. preview format.");
+               __deviceDefaultPreviewFormat = (Tizen::Graphics::PixelFormat)pInteger->ToInt();
+               delete pObj;
+               pObj = null;
+
+               __previewFormat = __deviceDefaultPreviewFormat;
+       }
+
+       // Capture format
+       if (reload & _RELOAD_CAPTURE_FORMAT)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               _ResultType itemType = _RESULT_NONE;
+               Integer *pInteger = null;
+
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_CAPTURE_FORMAT : _COP_SECONDARY_CAPTURE_FORMAT);
+               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
+               SysTryCatch(NID_MEDIA, itemType == _RESULT_INTEGER, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The item is wrong. capture format.");
+               __deviceDefaultCaptureFormat = (Tizen::Graphics::PixelFormat)pInteger->ToInt();
+               delete pObj;
+               pObj = null;
+
+               __captureFormat = __deviceDefaultCaptureFormat;
+       }
+
+       // Focus mode
+       if (reload & _RELOAD_FOCUS_MODE)
+       {
+               String key = (__selection == CAMERA_PRIMARY ? CAMERA_PRIMARY_FOCUS_MODE : CAMERA_SECONDARY_FOCUS_MODE);
+               std::unique_ptr <IList, _ListPtrUtil::Remover> pSupportedList (GetPropertyListN(key), _ListPtrUtil::remover);
+
+               if (pSupportedList.get() != null)
+               {
+                       if (pSupportedList->GetCount() > 0)
+                       {
+                               __focusMode = CAMERA_FOCUS_MODE_NORMAL;
+                       }
+               }
+               else
+               {
+                       __focusMode = CAMERA_FOCUS_MODE_NONE;
+               }
+       }
+
+       // Zero shutter lag
+       if (reload & _RELOAD_ZERO_SHUTTER_LAG)
+       {
+               _CameraOperationType operation = _COP_NONE;
+               _ResultType itemType = _RESULT_NONE;
+               Integer *pInteger = null;
+
+               operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ZERO_SHUTTER_LAG: _COP_SECONDARY_ZERO_SHUTTER_LAG);
+               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
+               SysTryCatch(NID_MEDIA, itemType == _RESULT_INTEGER, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The type is wrong. itemType:%d", itemType);
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The item is wrong. Zero shutter lag.");
+               __zeroShutterLag = (bool)pInteger->ToInt();
+               delete pObj;
+               pObj = null;
+       }
+
+       //Metering mode
+       if (reload & _RELOAD_METERING_MODE)
+       {
+               String key = (__selection == CAMERA_PRIMARY ? CAMERA_PRIMARY_METERING_MODE : CAMERA_SECONDARY_METERING_MODE);
+               std::unique_ptr <IList, _ListPtrUtil::Remover> pSupportedList (GetPropertyListN(key), _ListPtrUtil::remover);
+
+               if (pSupportedList.get() != null)
+               {
+                       if (pSupportedList->GetCount() > 0)
+                       {
+                               __meteringMode = CAMERA_METERING_MODE_AVERAGE;
+                       }
+               }
+               else
+               {
+                       __meteringMode = CAMERA_METERING_MODE_NONE;
+               }
+       }
+
+       return r;
+
+CATCH:
+       if (pObj != null)
+       {
+               delete pObj;
+       }
+       return r;
+}
+
+result
+_CameraImpl::ChangeFocusModeTo(CameraFocusMode currentMode, CameraFocusMode destMode)
+{
+       result r = E_SUCCESS;
+       int tableTotalCount = 0;
+       int i = 0;
+       int err = MM_SUCCESS;
+
+       tableTotalCount = sizeof(_CAMERA_FOCUS_MODE_TRANSIT) / sizeof(_CAMERA_FOCUS_MODE_TRANSIT[0]);
+       SysLog(NID_MEDIA, " currentMode:%d, destMode:%d, tableTotalCount:%d", currentMode, destMode, tableTotalCount);
+
+       for (i = 0; i < tableTotalCount; i++)
+       {
+               if (currentMode == _CAMERA_FOCUS_MODE_TRANSIT[i].currentMode && destMode == _CAMERA_FOCUS_MODE_TRANSIT[i].destMode)
+               {
+                       SysLog(NID_MEDIA, "Exist the matching mode field. loop i:%d, current mode:%d, destMode:%d, operation0:%d", i, currentMode, destMode, _CAMERA_FOCUS_MODE_TRANSIT[i].focusOperation0);
+                       switch (_CAMERA_FOCUS_MODE_TRANSIT[i].focusOperation0)
+                       {
+                       case _FOCUS_MODE_OP_NONE:
+                               break;
+                       case _FOCUS_MODE_OP_CONTINUOUS:
+                               break;
+                       case _FOCUS_MODE_OP_CANCEL:
+                               err = camera_cancel_focusing(__handle);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to cancel focus.", GetErrorMessage(r));
+                               break;
+                       default:
+                               break;
+                       }
+
+                       // Set the mm's focus mode.
+                       camera_attr_af_mode_e attr = ::CAMERA_ATTR_AF_NONE;
+                       r = _CameraUtil::GetMmFocusMode(destMode, attr);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. focus mode:%d", GetErrorMessage(r), destMode);
+
+                       err = camera_attr_set_af_mode (__handle, attr);
+                       r = ConvertResult(err);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to set the focus mode", GetErrorMessage(r));
+
+                       switch (_CAMERA_FOCUS_MODE_TRANSIT[i].focusOperation1)
+                       {
+                       case _FOCUS_MODE_OP_NONE:
+                               break;
+                       case _FOCUS_MODE_OP_CONTINUOUS:
+                               err = camera_start_focusing(__handle, true);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to start continuous focusing", GetErrorMessage(r));
+                               break;
+                       case _FOCUS_MODE_OP_CANCEL:
+                               break;
+                       default:
+                               break;
+                       }
+                       break;
+               }
+       }
+       SysTryCatch(NID_MEDIA, i != tableTotalCount, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Not found. ");
+       return r;
+
+CATCH:
+       SysLog(NID_MEDIA, "[%s] Real currentMode:%d, param destMode:%d", GetErrorMessage(r), currentMode, destMode);
+       return r;
+}
+
+result
+_CameraImpl::HandleAutoFocus(CameraFocusMode currentMode)
+{
+       result r = E_SUCCESS;
+       int tableTotalCount = 0;
+       int i = 0;
+       int err = MM_SUCCESS;
+
+       tableTotalCount = sizeof(_CAMERA_FOCUS_OPERATIONT) / sizeof(_CAMERA_FOCUS_OPERATIONT[0]);
+       SysLog(NID_MEDIA, "Current mode:%d", currentMode);
+
+       for (i = 0; i < tableTotalCount; i++)
+       {
+               if (currentMode == _CAMERA_FOCUS_OPERATIONT[i].currentMode)
+               {
+                       SysLog(NID_MEDIA, "Exist the matching mode field. loop i:%d, current mode:%d, operation:%d", i, currentMode, _CAMERA_FOCUS_OPERATIONT[i].focusOperation);
+                       switch (_CAMERA_FOCUS_OPERATIONT[i].focusOperation)
+                       {
+                       case _FOCUS_OP_NONE:
+                               break;
+                       case _FOCUS_OP_ONCE:
+                               err = camera_start_focusing(__handle, false);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to start focus once.", GetErrorMessage(r));
+                               break;
+                       default:
+                               break;
+                       }
+
+                       if (_CAMERA_FOCUS_OPERATIONT[i].state >= CAMERA_STATE_INITIALIZED && _CAMERA_FOCUS_OPERATIONT[i].state <= CAMERA_STATE_ERROR)
+                       {
+                               SetState(_CAMERA_FOCUS_OPERATIONT[i].state);
+                               SysLog(NID_MEDIA, "Set the state to %d", _CAMERA_FOCUS_OPERATIONT[i].state);
+                       }
+                       break;
+               }
+       }
+       SysTryCatch(NID_MEDIA, i != tableTotalCount, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Not found. ");
+       return r;
+
+CATCH:
+       SysLog(NID_MEDIA, "[%s] Current mode:%d", GetErrorMessage(r), currentMode);
+       return r;
+}
+
+result
+_CameraImpl::OnCameraCoordinatorModeChangePrepared(_CameraMode mode)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Mode:%d", mode);
+
+       r = ReloadConfiguration(_RELOAD_PREVIEW_RESOLUTION  | _RELOAD_CAPTURE_RESOLUTION  | _RELOAD_INTERNAL_PREVIEW_FORMAT
+               | _RELOAD_CAPTURE_FORMAT  | _RELOAD_FPS  |  _RELOAD_FLIP  | _RELOAD_PREVIEW_ROTATION  | _RELOAD_PREVIEW_PREPARE);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
+
+       SysLog(NID_MEDIA, "Pre mode changed operation succeeded.");
+       return r;
+}
+
+result
+_CameraImpl::OnCameraCoordinatorModeChanged(_CameraMode mode)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Mode:%d", mode);
+
+       r = ReloadConfiguration(_RELOAD_BRIGHTNESS  | _RELOAD_CONTRAST  | _RELOAD_EXPOSURE  | _RELOAD_MAX_ZOOM_LEVEL  | _RELOAD_ZOOM_LEVEL  | _RELOAD_EFFECT
+               | _RELOAD_WB  | _RELOAD_QUALITY  | _RELOAD_ISO  | _RELOAD_EXIF_ORIENTATION  | _RELOAD_EXIF_GPS_COORDINATES
+               | _RELOAD_FLASH  | _RELOAD_FOCUS_MODE | _RELOAD_METERING_MODE
+               | _RELOAD_EXTRA);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
+
+       SysLog(NID_MEDIA, "Post mode changed operation succeeded.");
+       return r;
+}
+
+void
+_CameraImpl::StateChangedCb(camera_state_e previous, camera_state_e current, bool byPolicy, void *pUserData)
+{
+       _CameraImpl* pImpl = static_cast<_CameraImpl*>( pUserData);
+       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[%s] _CameraImpl instance is not available.", GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
+}
+
+void
+_CameraImpl::CaptureCb(camera_image_data_s* pImage, camera_image_data_s *pPostview, camera_image_data_s* pThumbnail, void* pUserData)
+{
+       result r = E_SUCCESS;
+       _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
+       MediaPixelFormat format = MEDIA_PIXEL_FORMAT_NONE;
+       double ratio = 0.0;
+       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl is null.");
+       SysTryReturn(NID_MEDIA, pImpl->GetState() == CAMERA_STATE_CAPTURING, , E_INVALID_STATE, "[E_INVALID_STATE] The camera is already capturing");
+       SysTryCatch(NID_MEDIA, pImage != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] image is null.");
+       SysLog(NID_MEDIA, "Enter. image size:%d, format:%d", pImage->size, pImage->format);
+
+       _CameraUtil::GetOspMediaPixelFormat(pImage->format, format, ratio);
+       if (format == MEDIA_PIXEL_FORMAT_NONE)          // if the encoded data
+       {
+               _CameraBuffer cameraBuffer;
+               CodecType codec = CODEC_NONE;
+
+               _CameraUtil::GetOspCodecType(pImage->format, codec);
+               r = cameraBuffer.Construct(pImage->size, _CAMERA_BUFFER_CAPTURE, codec, true, pImage->width, pImage->height);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d, format%d", GetErrorMessage(r), pImage->size, pImage->format);
+
+               r = cameraBuffer.SetArray((byte*) pImage->data, 0, pImage->size);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. data:%d, size:%d", GetErrorMessage(r), (int) pImage->data, pImage->size);
+               cameraBuffer.Flip();
+
+               r = pImpl->EnqueueData(cameraBuffer);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. data:%d, size:%d", GetErrorMessage(r), (int) pImage->data, pImage->size);
+       }
+       else            // if the raw data
+       {
+               _CameraBuffer cameraBuffer;
+
+               r = cameraBuffer.Construct(pImage->size, _CAMERA_BUFFER_CAPTURE, format, pImage->width, pImage->height);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d, format%d", GetErrorMessage(r), pImage->size, pImage->format);
+
+               r = cameraBuffer.SetArray((byte*) pImage->data, 0, pImage->size);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. data:%d, size:%d", GetErrorMessage(r), (int) pImage->data, pImage->size);
+               cameraBuffer.Flip();
+
+               r = pImpl->EnqueueData(cameraBuffer);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. data:%d, size:%d", GetErrorMessage(r), (int) pImage->data, pImage->size);
+       }
+
+       return;
+CATCH:
+       SysLogException(NID_MEDIA, E_INVALID_DATA, "[E_INVALID_DATA] Invalid data is captured.");
+       return;
+}
+
+void
+_CameraImpl::CaptureCompletedCb(void *pUserData)
+{
+       result r = E_SUCCESS;
+       ByteBuffer* pBuffer = null;
+       _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
+       SysLog(NID_MEDIA, "CaptureCompletedCb");
+
+       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+//     SysTryReturn(NID_MEDIA, pImpl->GetState() == CAMERA_STATE_CAPTURING, , E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. The camera is already power-offed");
+
+       pBuffer = pImpl->DequeueDataN(_CAMERA_BUFFER_CAPTURE);
+       if (pBuffer != null)
+       {
+               SysLog(NID_MEDIA, "Captured data sending. size is %d", pBuffer->GetLimit());
+               if (pBuffer->GetLimit() > 0)
+               {
+                       r = pImpl->GetEvent()->SendEvent(_CAMERA_EVENT_CAPTURED, CAMERA_ERROR_NONE, E_SUCCESS, pBuffer);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else
+               {
+                       SysLogException(NID_MEDIA, E_INVALID_DATA, "[E_INVALID_DATA] The captured data is invalid.");
+                       r = pImpl->GetEvent()->SendEvent(_CAMERA_EVENT_CAPTURED, CAMERA_ERROR_DEVICE_FAILED, E_INVALID_DATA, pBuffer);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               delete pBuffer;
+               pBuffer = null;
+       }
+       else
+       {
+               SysLogException(NID_MEDIA, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Out of memory for capturing anymore.");
+               r = pImpl->GetEvent()->SendEvent(_CAMERA_EVENT_CAPTURED, CAMERA_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, null);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return;
+CATCH:
+       if (pBuffer != null)
+       {
+               delete pBuffer;
+       }
+       return;
+}
+
+void
+_CameraImpl::SetPreprocessingCb(_CameraPreprocessingCallback pPreProcessCbFunc, void* pPreProcessUserData)
+{
+       if (pPreProcessCbFunc != null)
+       {
+               __previewProcessing = __previewProcessing | _PREVIEW_PRE_PROCESSING;
+       }
+       else
+       {
+               __previewProcessing = __previewProcessing & (~_PREVIEW_PRE_PROCESSING);
+       }
+
+       __pPreProcessCbFunc = pPreProcessCbFunc;
+       __pPreProcessUserData = pPreProcessUserData;
+}
+
+void
+_CameraImpl::GetPreprocessingCb(_CameraPreprocessingCallback& pPreProcessCbFunc, void*& pPreProcessUserData)
+{
+       pPreProcessCbFunc = __pPreProcessCbFunc;
+       pPreProcessUserData= __pPreProcessUserData;
+}
+
+void
+_CameraImpl::PreviewCb(camera_preview_data_s *pFrame, void *pUserData)
+{
+       result r = E_SUCCESS;
+       int queueCount = 0;
+       _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
+
+       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+       SysTryReturn(NID_MEDIA, pFrame != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] camera_preview_data_s instance is not available.");
+       SysLog(NID_MEDIA, "Enter. preview format:%d, width:%d, height:%d, num_of_planes:%d", pFrame->format, pFrame->width, pFrame->height, pFrame->num_of_planes);
+
+       queueCount = pImpl->GetDataCount(_CAMERA_BUFFER_PREVIEW);
+       if (queueCount < _MAX_PREVIEW_BUFFER_COUNT)
+       {
+               int previewProcessing = pImpl->GetPreviewProcessing();
+               if (previewProcessing & _PREVIEW_PRE_PROCESSING)
+               {
+                       //for Preprocessing
+                       int size[4] = {0,};
+                       byte* data[4] = {0,};
+                       if (pFrame->num_of_planes == 1)
+                       {
+                               size[0] = pFrame->data.single_plane.size;
+                               data[0] = pFrame->data.single_plane.yuv;
+
+                       }
+                       else if (pFrame->num_of_planes == 2)
+                       {
+                               size[0] = pFrame->data.double_plane.y_size;
+                               size[1] = pFrame->data.double_plane.uv_size;
+                               data[0] = pFrame->data.double_plane.y;
+                               data[1] = pFrame->data.double_plane.uv;
+                       }
+                       else if (pFrame->num_of_planes == 3)
+                       {
+                               size[0] = pFrame->data.triple_plane.y_size;
+                               size[1] = pFrame->data.triple_plane.u_size;
+                               size[2] = pFrame->data.triple_plane.v_size;
+                               data[0] = pFrame->data.triple_plane.y;
+                               data[1] = pFrame->data.triple_plane.u;
+                               data[2] = pFrame->data.triple_plane.v;
+                       }
+                       MediaPixelFormat mediaFormat = MEDIA_PIXEL_FORMAT_NONE;
+                       double ratio = 0.0;
+                       _CameraUtil::GetOspMediaPixelFormat(pFrame->format, mediaFormat, ratio);
+
+                       _CameraPreprocessingCallback pPreProcessCbFunc = null;
+                       void* pPreProcessUserData = null;
+                       pImpl->GetPreprocessingCb(pPreProcessCbFunc, pPreProcessUserData);
+
+                       (pPreProcessCbFunc)(mediaFormat, data, size, pPreProcessUserData);
+               }
+
+               if (previewProcessing & _PREVIEW_POST_PROCESSING)
+               {
+                       int mmPreviewSize = 0;
+                       _CameraBuffer mmCameraBuffer;
+                       MediaPixelFormat format = MEDIA_PIXEL_FORMAT_NONE;
+                       double ratio = 0.0;
+
+                       _CameraUtil::GetOspMediaPixelFormat(pFrame->format, format, ratio);
+
+                       if (pFrame->num_of_planes == 1)
+                       {
+                               int yuvSize = pFrame->data.single_plane.size;
+                               mmPreviewSize = yuvSize;
+
+                               r = mmCameraBuffer.Construct( yuvSize, _CAMERA_BUFFER_PREVIEW, format, pFrame->width, pFrame->height);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), mmPreviewSize);
+
+                               r = mmCameraBuffer.SetArray((byte*)pFrame->data.single_plane.yuv, 0, yuvSize);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), mmPreviewSize);
+
+                               mmCameraBuffer.Flip();
+                       }
+                       else if (pFrame->num_of_planes == 2)
+                       {
+                               int ySize = pFrame->data.double_plane.y_size;
+                               int uvSize = pFrame->data.double_plane.uv_size;
+                               mmPreviewSize = ySize + uvSize;
+
+                               r = mmCameraBuffer.Construct(mmPreviewSize, _CAMERA_BUFFER_PREVIEW, format, pFrame->width, pFrame->height);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), mmPreviewSize);
+
+                               r = mmCameraBuffer.SetArray((byte*)pFrame->data.double_plane.y, 0, ySize);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), ySize);
+
+                               r = mmCameraBuffer.SetArray((byte*)pFrame->data.double_plane.uv, 0, uvSize);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), uvSize);
+
+                               mmCameraBuffer.Flip();
+                       }
+                       else if (pFrame->num_of_planes == 3)
+                       {
+                               int ySize = pFrame->data.triple_plane.y_size;
+                               int uSize = pFrame->data.triple_plane.u_size;
+                               int vSize = pFrame->data.triple_plane.v_size;
+                               mmPreviewSize = ySize + uSize + vSize;
+
+                               r = mmCameraBuffer.Construct(mmPreviewSize, _CAMERA_BUFFER_PREVIEW, format, pFrame->width, pFrame->height);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), mmPreviewSize);
+
+                               r = mmCameraBuffer.SetArray((byte*)pFrame->data.triple_plane.y, 0, ySize);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), ySize);
+
+                               r = mmCameraBuffer.SetArray((byte*)pFrame->data.triple_plane.u, 0, uSize);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), uSize);
+
+                               r = mmCameraBuffer.SetArray((byte*)pFrame->data.triple_plane.v, 0, vSize);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), vSize);
+
+                               mmCameraBuffer.Flip();
+                       }
+
+                       r = pImpl->EnqueueData(mmCameraBuffer);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), mmPreviewSize);
+
+                       r = pImpl->GetEvent()->SendEvent(_CAMERA_EVENT_PREVIEWED_DATA, CAMERA_ERROR_NONE, E_SUCCESS, null);             // For the performance, we don't copy the preview data to the event argument.
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+       return;
+
+CATCH:
+       SysLogException(NID_MEDIA, E_INVALID_DATA, "[E_INVALID_DATA] Invalid data is streamed..");
+       if (queueCount < pImpl->GetDataCount(_CAMERA_BUFFER_PREVIEW))     // if the queue is increased.
+       {
+               ByteBuffer* pBuffer = null;
+               pBuffer = pImpl->DequeueDataN(_CAMERA_BUFFER_PREVIEW);
+               if (pBuffer)
+               {
+                       delete pBuffer;
+               }
+       }
+       return;
+}
+
+void
+_CameraImpl::InterruptedCb(camera_policy_e policy, camera_state_e previous, camera_state_e current, void *pUserData)
+{
+       result r = E_SUCCESS;
+       _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
+       SysLog(NID_MEDIA, "InterruptedCb called, policy is %d, previous state is %d, current state is %d, pUserData address is %x  ", policy, previous, current, pUserData );
+       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+       SysTryReturn(NID_MEDIA, pImpl->IsPoweredOn() == true, , E_INVALID_OPERATION  ,"The camera is already power-offed");
+       r = pImpl->GetEvent()->SendEvent(_CAMERA_EVENT_ERROR, CAMERA_ERROR_DEVICE_INTERRUPTED, E_DEVICE_FAILED, null);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "Sending camera interrupted failed [%s] .", GetErrorMessage(r));
+CATCH:
+       return;
+}
+
+void
+_CameraImpl::FocusStateChangedCb(camera_focus_state_e state, void *pUserData)
+{
+       result r = E_SUCCESS;
+       _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
+       CameraErrorReason cameraErrorReason = CAMERA_ERROR_NONE;
+       result cameraResult = E_SUCCESS;
+       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+
+       CameraFocusMode focusMode = pImpl->GetFocusMode();
+
+       switch (state)
+       {
+       case ::CAMERA_FOCUS_STATE_ONGOING:
+               if (pImpl->ReadyToAutoFocusCallback())
+               {
+                       if (focusMode == CAMERA_FOCUS_MODE_CONTINUOUS_AUTO)
+                       {
+                               cameraErrorReason = CAMERA_ERROR_NONE;
+                               cameraResult = E_OPERATION_CANCELED;
+                               r = pImpl->GetEvent()->SendEvent(_CAMERA_EVENT_AUTO_FOCUSED, cameraErrorReason, cameraResult, null);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+               break;
+       case ::CAMERA_FOCUS_STATE_RELEASED:
+               break;
+       case ::CAMERA_FOCUS_STATE_FAILED:
+               cameraErrorReason = CAMERA_ERROR_DEVICE_FAILED;
+               cameraResult = E_DEVICE_FAILED;
+               if (pImpl->ReadyToAutoFocusCallback())
+               {
+                       r = pImpl->GetEvent()->SendEvent(_CAMERA_EVENT_AUTO_FOCUSED, cameraErrorReason, cameraResult, null);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else            // No auto focus event is fired.
+               {
+                       if (pImpl->GetState() == CAMERA_STATE_AUTO_FOCUSING)
+                       {
+                               pImpl->SetState(CAMERA_STATE_PREVIEW);
+                       }
+               }
+               break;
+       case ::CAMERA_FOCUS_STATE_FOCUSED:
+               if (pImpl->ReadyToAutoFocusCallback())
+               {
+                       r = pImpl->GetEvent()->SendEvent(_CAMERA_EVENT_AUTO_FOCUSED, cameraErrorReason, cameraResult, null);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else            // No auto focus event is fired.
+               {
+                       if (pImpl->GetState() == CAMERA_STATE_AUTO_FOCUSING)
+                       {
+                               pImpl->SetState(CAMERA_STATE_PREVIEW);
+                       }
+               }
+               break;
+
+       default:
+               break;
+       }
+
+CATCH:
+       return;
+}
+
+bool
+_CameraImpl::IsAlive(void)
+{
+       return __isUsed;
+}
+
+_CameraImpl*
+_CameraImpl::GetInstance(Camera *pCamera)
+{
+       if ( pCamera != null)
+       {
+               return pCamera->__pImpl;
+       }
+       return null;
+}
+
+const _CameraImpl*
+_CameraImpl::GetInstance(const Camera *pCamera)
+{
+       if ( pCamera != null)
+       {
+               return pCamera->__pImpl;
+       }
+       return null;
+}
+
+}}   // Tizen::Media
diff --git a/src/FMedia_CameraImpl.h b/src/FMedia_CameraImpl.h
new file mode 100755 (executable)
index 0000000..4ed5401
--- /dev/null
@@ -0,0 +1,1471 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraImpl.h
+ * @brief                      This header file contains the declarations of the %_CameraImpl class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_IMPL_H_
+#define _FMEDIA_INTERNAL_CAMERA_IMPL_H_
+
+#include <camera.h>
+#include <FBaseColIList.h>
+#include <FBaseColIListT.h>
+#include <FBaseObject.h>
+#include <FBaseColQueue.h>
+#include <FGrpBufferInfo.h>
+#include <FGrpDimension.h>
+#include <FGrpPixelFormat.h>
+#include <FGrpRectangle.h>
+#include <FMediaCameraTypes.h>
+#include <FMediaTypes.h>
+#include "FMedia_CameraTypes.h"
+#include "FMedia_CapabilityTypes.h"
+#include "FMedia_ICameraCoordinatorListener.h"
+#include "FMedia_CameraBuffer.h"
+
+namespace Tizen { namespace Media
+{
+class Camera;
+class ICameraEventListener;
+class _CameraEvent;
+class _CameraCoordinator;
+class _CameraCapability;
+class _ImageUtilImpl;
+
+typedef void (*_CameraPreprocessingCallback)( MediaPixelFormat format, byte* data[4], int size[4], void* user);
+
+/**
+ * @class      _CameraImpl
+ * @brief      This class implements the APIs of %Camera class.
+ *
+ */
+class _CameraImpl
+       : public Tizen::Base::Object
+       , public _ICameraCoordinatorListener
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
+        * initialize this instance.
+        * @see                 Construct()
+        */
+       _CameraImpl(void);
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread
+        * where the Construct() method is called.
+        *
+        * @see                 Construct()
+        */
+       virtual ~_CameraImpl(void);
+
+
+       /**
+       * Initializes this instance of Camera with the specified parameters. @n
+       * This method creates an instance of Camera in the subsystem. Only one instance is created at a given time.
+       *
+       * @return               An error code
+       * @param[in]    listener                                An event listener instance
+       * @param[in]    camSel                                  The Camera to be used
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       result Construct(ICameraEventListener& listener, CameraSelection camSel);
+
+       /**
+       * Powers the camera on.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       * @exception    E_DEVICE_FAILED                 The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The reserved configurations are set in this method.
+       * @see                  PowerOff()
+       */
+       result PowerOn(void);
+
+       /**
+       * Powers the camera off.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       * @exception    E_DEVICE_FAILED                 The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @see                  PowerOn()
+       */
+       result PowerOff(void);
+
+       /**
+       * Checks whether the camera is powered on.
+       *
+       * @return               @c true if the camera is powered on, @n
+       *                               else @c false
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  PowerOn(), PowerOff()
+       */
+       bool IsPoweredOn(void) const;
+
+       /**
+       * Starts displaying the preview image on the camera device. @n
+       * If the value of @c pBufferInfo is @c null, no preview image is displayed. In this case, the application can
+       * draw the preview image with the data passed on by the ICameraEventListener::OnCameraPreviewed() method.
+       *
+       * If the value of @c previewedData is @c true, the previewed image data is passed to the
+       * ICameraEventListener::OnCameraPreviewed() method periodically based on the frame-rate, otherwise the
+       * callback is not invoked. The default value of @c previewedData is @c false.
+       *
+       * @return               An error code
+       * @param[in]    pBufferInfo                             The buffer information for the camera preview display
+       * @param[in]    previewedData                   Set to @c true if the previewed data is delivered to the callback method, @n
+       *                                                                               else @false
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       * @exception    E_DEVICE_FAILED                 The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The overlay region retrieved by the buffer information should be the topmost window when this method is
+       *                               called.
+       * @remarks              The ICameraEventListener::OnCameraPreviewed() method can be delayed or dropped depending on
+       *                               the system's performance. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+
+       * @see                  StopPreview(), ICameraEventListener::OnCameraPreviewed()
+       */
+       result StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo, bool previewedData = false);
+
+       /**
+       * Stops displaying the preview image on the camera device.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       * @exception    E_DEVICE_FAILED                 The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks        For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  StartPreview()
+       */
+       result StopPreview(void);
+
+       /**
+       * Captures the current image data from the camera sensor. @n
+       * After capturing the image, the camera's state changes to ::CAMERA_STATE_CAPTURED. @n
+       * The camera's preview should be restarted by calling the StartPreview() method. @n
+       * The captured image is passed through ICameraEventListener::OnCameraCaptured().
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks        For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  ICameraEventListener::OnCameraCaptured()
+       */
+       result Capture(void);
+
+       /**
+       * Gets the state of the camera in CameraState.
+       *
+       * @return               The current state of the camera
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  StartPreview(), StopPreview(), SetAutoFocus(), Capture()
+       */
+       CameraState GetState(void) const;
+
+       /**
+       * Sets the brightness level of the camera input data.
+       *
+       * @return               An error code
+       * @param[in]    brightness                                      The brightness level to set @n
+       *                                                                                       The range of this parameter is from @c 0 to @c 9.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified @c brightness is out of range.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The default brightness level is @c 5. @n
+       *                               The device's supported range for the brightness level is from @c 0 to @c 9. @n
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetBrightness()
+       */
+       result SetBrightness(int brightness);
+
+       /**
+       * Gets the brightness level of the camera input data.
+       *
+       * @return               The current brightness level @n
+       *                               The returned value ranges from @c 0 to @c 9.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The device's supported range for the brightness level is from @c 0 to @c 9. @n
+       * @see                  SetBrightness()
+       */
+       int GetBrightness(void) const;
+
+       /**
+       * Sets the contrast level of the Camera input data.
+       *
+       * @return               An error code
+       * @param[in]    contrast                                        The contrast level to set @n
+       *                                                                                       The range of this parameter is from @c 0 to @c 9.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified contrast is out of range.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The default contrast level is @c 5. @n
+       *                               The device's supported range for the contrast level is from @c 0 to @c 9. @n
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetContrast()
+       */
+       result SetContrast(int contrast);
+
+       /**
+       * Gets the contrast level of the camera input data.
+       *
+       * @return               The current contrast level @n
+       *                               The returned value ranges from @c 0 to @c 9.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The device's supported range for the contrast level is from @c 0 to @c 9.
+       * @see                  SetContrast()
+       */
+       int GetContrast(void) const;
+
+       /**
+       * Increases the zoom level of the camera.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              This method returns E_UNSUPPORTED_OPERATION in the emulator.
+       *                               If CameraZoomType supports only ::CAMERA_ZOOM_TYPE_SMART, the zoom ratio can differ according
+       *                               to the preview, capture, and recording resolutions.
+       *                               The supported zoom types can be obtained by using the
+       *                               MediaCapability::GetValueN(CAMERA_PRIMARY_ZOOM_TYPE) method. @n@n
+       *                          For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  ZoomOut(),GetZoomLevel(),GetMaxZoomLevel()
+       */
+       result ZoomIn(void);
+
+       /**
+       * Decreases the zoom level of the camera.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              This method returns E_UNSUPPORTED_OPERATION in the emulator.
+       *                               If CameraZoomType supports only ::CAMERA_ZOOM_TYPE_SMART, zoom ratio can differ according to
+       *                               the preview, capture, and recording resolutions.
+       *                               The supported zoom types can be obtained by using the
+       *                               MediaCapability::GetValueN(CAMERA_PRIMARY_ZOOM_TYPE) method. @n@n
+       *                          For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  ZoomIn(),GetZoomLevel(),GetMaxZoomLevel()
+       */
+       result ZoomOut(void);
+
+       /**
+       * Gets the zoom level of the camera.
+       *
+       * @return               The current zoom level
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @remarks              The zoom level is different for each camera device.
+       * @remarks              This method throws E_UNSUPPORTED_OPERATION in the emulator.
+       * @see                  ZoomIn(), ZoomOut(),GetMaxZoomLevel()
+       */
+       int GetZoomLevel(void) const;
+
+       /**
+       * Gets the maximum zoom level supported by this Camera.
+       *
+       * @return               The maximum zoom level
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @remarks              The zoom level is different for each camera device.
+       * @remarks              This method returns E_UNSUPPORTED_OPERATION in the emulator. @n
+       *                               This method works correctly when PowerOn() is executed.
+       * @see                  ZoomIn(), ZoomOut(), GetZoomLevel()
+       */
+       int GetMaxZoomLevel(void) const;
+
+       /**
+       * Changes the current resolution of the preview.
+       *
+       * @return               An error code
+       * @param[in]    resolution                                The preview resolution @n
+       *                                                                                       It should be one of the listed dimensions that are extracted using GetSupportedPreviewResolutionListN().
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The position or size is out of range.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_UNSUPPORTED_OPERATION         This operation is not supported.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @remarks              This method works in the ::CAMERA_STATE_INITIALIZED state. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetPreviewResolution()
+       */
+       result SetPreviewResolution(const Tizen::Graphics::Dimension& resolution);
+
+       /**
+       * Retrieves the current resolution of the preview.
+       *
+       * @return               The current preview resolution
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetPreviewResolution()
+       */
+       Tizen::Graphics::Dimension GetPreviewResolution(void) const;
+
+       /**
+       * Retrieves the supported preview resolution list of the Camera class. @n
+       * Each item in the returned list contains a pointer of Tizen::Graphics::Dimension value.
+       *
+       * @return          A list of dimensions that represent the preview resolutions supported by the Camera class,  @n
+       *                               else @c null if no preview resolution is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remark               The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value and each item in the list must be deleted by the caller. @n
+       *                               This method works correctly when Camera::PowerOn() is executed.
+       * @see                  SetPreviewResolution(), GetPreviewResolution()
+       */
+       Tizen::Base::Collection::IList* GetSupportedPreviewResolutionListN(void) const;
+
+
+       /**
+       * Sets the capturing resolution of the camera. @n
+       * Initially, the default resolution is set using the internal configuration.
+       *
+       * @return               An error code
+       * @param[in]    resolution                                      The display resolution @n
+       *                                                                                       The display resolution should be one of the values extracted using GetSupportedCaptureResolutionListN().
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_OUT_OF_RANGE                          The specified resolution is out of range.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks                      For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetCaptureResolution(), GetSupportedCaptureResolutionListN()
+       */
+       result SetCaptureResolution(const Tizen::Graphics::Dimension& resolution);
+
+       /**
+       * Gets the resolution for capturing the data of the camera.
+       *
+       * @return               The current resolution for capturing the data of the camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetCaptureResolution(),GetSupportedCaptureResolutionListN()
+       */
+       Tizen::Graphics::Dimension GetCaptureResolution(void) const;
+
+       /**
+       * Gets a list of the capturing resolutions supported by the Camera class. @n
+       * Each item of the list has a pointer of the Tizen::Graphics::Dimension value.
+       *
+       * @return               A list of the capture resolutions supported by the Camera class @n
+       *                               else @c null if no capture resolution is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remark               The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value and each item in the list must be deleted by the caller. @n
+       *                               This method works correctly when PowerOn() is executed.
+       * @see                  SetCaptureResolution(), GetCaptureResolution()
+       */
+       Tizen::Base::Collection::IList* GetSupportedCaptureResolutionListN(void) const;
+
+       /**
+       * Sets the effect for the input data of the camera.
+       *
+       * @return               An error code
+       * @param[in]    effect                                          The effect for the input data of the camera
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_UNSUPPORTED_TYPE                The effect type is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The default effect is ::CAMERA_EFFECT_NONE.
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetEffect()
+       */
+       result SetEffect(CameraEffect effect);
+
+       /**
+       * Gets the effect for the input data of the camera.
+       *
+       * @return               The effect for the input data of the camera
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetEffect()
+       */
+       CameraEffect GetEffect(void) const;
+
+       /**
+       * Sets the camera's flash mode.
+       *
+       * @return               An error code
+       * @param[in]    flashMode                                       flash mode to switch on the flash light.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified flash mode is invalid.
+       * @exception    E_DEVICE_BUSY                           The camera is under use by other application.
+       * @exception    E_DEVICE_UNAVAILABLE            The camera becomes unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_UNSUPPORTED_OPERATION     The target device does not support flash configuration feature.
+       * @exception    E_UNSUPPORTED_TYPE          The specified @c flashMode is not supported.
+       * @remarks              Normally the flash splashes before the camera captures a picture. @n
+       *                               ::CAMERA_FLASH_MODE_CONTINUOUS keeps the flash turned on after the method is called until ::CAMERA_FLASH_MODE_OFF is set. @n
+       *                               This method returns E_UNSUPPORTED_OPERATION in the Emulator.
+       * @see                  GetFlashMode()
+       */
+       result SetFlashMode(CameraFlashMode flashMode);
+
+       /**
+       * Gets the flash mode of the camera.
+       *
+       * @return               The flash mode of the camera
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       *                               If the %Camera doesn't support the flash mode, this method always returns ::CAMERA_FLASH_MODE_OFF.
+       * @see                  SetFlashMode()
+       */
+       CameraFlashMode GetFlashMode(void) const;
+
+       /**
+       * Sets the exposure level of the camera.
+       *
+       * @return               An error code
+       * @param[in]    exposure                                        The camera exposure level @n
+       *                                                                                       The range of this parameter is from @c 0 to @c 9.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified exposure level is out of range.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The default exposure level is @c 5.
+       *                               The supported range for exposure level is from @c 0 to @c 9.
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetExposure()
+       */
+       result SetExposure(int exposure);
+
+       /**
+       * Gets the exposure level of the camera.
+       *
+       * @return               An integer value representing the exposure level of the camera @n
+       *                               The returned value ranges from @c 0 to @c 9.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The supported range for exposure level is from @c 0 to @c 9.
+       * @see                  SetExposure()
+       */
+       int GetExposure(void) const;
+
+       /**
+       * Sets the white balance level of the camera.
+       *
+       * @return               An error code
+       * @param[in]    whiteBalance                            The camera white balance level
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_UNSUPPORTED_TYPE                The @c whiteBalance type is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The default white balance is ::CAMERA_WHITE_BALANCE_AUTO.
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetWhiteBalance()
+       */
+
+       result SetWhiteBalance(CameraWhiteBalance whiteBalance);
+
+       /**
+       * Gets the white balance level of the camera.
+       *
+       * @return               The white balance level of the camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetWhiteBalance()
+       */
+       CameraWhiteBalance GetWhiteBalance(void) const;
+
+       /**
+       * Sets the capturing quality of the camera.
+       *
+       * @return               An error code
+       * @param[in]    quality                                         The camera's quality level
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The specified @c quality is not supported.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION         This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The default quality is ::CAMERA_QUALITY_NORMAL.
+       *                               This method works correctly when PowerOn() is executed. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetQuality()
+       */
+       result SetQuality(CameraQuality quality);
+
+       /**
+       * Gets the capturing quality of the camera.
+       *
+       * @return               The Camera quality level
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetQuality()
+       */
+       CameraQuality GetQuality(void) const;
+
+       /**
+       * Sets the focus mode of the camera.
+       *
+       * @return               An error code
+       * @param[in]    focusMode                               focus mode
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_UNSUPPORTED_TYPE                The @c focusMode type is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks      ::CAMERA_FOCUS_MODE_NONE always throws E_INVALID_ARG.
+       * @see          GetFocusMode()
+       */
+       result SetFocusMode(CameraFocusMode focusMode);
+
+       /**
+       * Gets the focus mode of the camera.
+       *
+       * @return               The %Camera focus mode
+       * @see          SetFocusMode()
+       */
+       CameraFocusMode GetFocusMode(void) const;
+
+       /**
+       * Enables or disables the auto focus mode of the camera.
+       *
+       * @return               An error code
+       * @param[in]    callback                                        Set to @c true to enable auto focus callback, @n
+       *                                                                                       else @c false
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              If @c callback is set to @c false, the ICameraEventListener::OnCameraAutoFocused() method is not called.
+       *                               This method throws E_UNSUPPORTED_OPERATION in the emulator. @n@n
+       *                          For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  ICameraEventListener::OnCameraAutoFocused()
+       */
+       result SetAutoFocus(bool callback);
+
+       /**
+       * Check the object is ready to call the auto focus callback or not.
+       *
+       * @return               true if it calls the callback, otherwise false.
+       */
+       bool ReadyToAutoFocusCallback(void) const;
+
+       /**
+       * Sets the auto focus point list.
+       *
+       * @return           An error code
+       * @param[in]        pointList                                          auto focus point list which consists of Tizen::Graphics::Point pointers
+       * @exception        E_SUCCESS                                                                The method is successful.
+       * @exception        E_INVALID_STATE                                           This instance is in an invalid state for this method.
+       * @exception        E_DEVICE_BUSY                                             The device cannot be approached because of other operations.
+       * @exception        E_DEVICE_UNAVAILABLE                    The device is unavailable.
+       * @exception        E_DEVICE_FAILED                                           The device operation has failed.
+       * @exception        E_INVALID_ARG                               The specified input parameter is invalid.
+       * @exception        E_UNSUPPORTED_OPERATION         The device does not support the focus point.
+       * @exception        E_UNSUPPORTED_TYPE                        This method is not supported for the current focus mode.
+       * @exception        E_OUT_OF_MEMORY                                                    The memory is insufficient.
+       * @remarks              This method works fine when the current focus mode is CAMERA_FOCUS_MODE_NORMAL or CAMRA_FOCUS_MODE_MACRO.
+       * @see                 GetAutoFocusPointN()
+       */
+       result SetAutoFocusPoint(const Tizen::Base::Collection::IList& pointList);
+
+       /**
+       * Gets the auto focus point list. @n
+       * Each item of the list has a pointer of the Tizen::Graphics::Point value.
+       *
+       * @return               A list of dimensions that represent the auto focus point, @n
+       *                               else @c null if no auto focus point is set or an exception occurs
+       * @exception    E_SUCCESS                                                                The method is successful.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks           The specific error code can be accessed using the GetLastResult() method. @n
+       *                                       The return value and each item in the list must be deleted by the caller.
+       * @see                 SetAutoFocusPoint()
+       */
+       Tizen::Base::Collection::IList* GetAutoFocusPointN(void) const;
+
+       /**
+       * Sets the capturing format of the camera. @n
+       * Initially, the default format is set using the internal configuration.
+       *
+       * @return               An error code
+       * @param[in]    format                                          The camera's capture format @n
+       *                                                                                       It should be one of the pixel formats extracted using GetSupportedCaptureFormatListN().
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_UNSUPPORTED_FORMAT            The specified format is not supported.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              This method works correctly when PowerOn() is executed.
+       * @see                  GetCaptureFormat(), GetSupportedCaptureFormatListN()
+       */
+       result SetCaptureFormat(const Tizen::Graphics::PixelFormat format);
+
+       /**
+       * Gets the capturing format of the camera.
+       *
+       * @return               The capturing format of the camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetCaptureFormat(), GetSupportedCaptureFormatListN()
+       */
+       Tizen::Graphics::PixelFormat GetCaptureFormat(void) const;
+
+       /**
+       * Gets the supported capturing format list for the Camera class. @n
+       * Each list item has a Tizen::Graphics::PixelFormat value.
+       *
+       * @return               A list of the formats supported by the Camera class, @n
+       *                               else @c null if no capture format is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remark               The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted. @n
+       *                               This method works correctly when PowerOn() is executed.
+       * @see                  SetCaptureFormat(), GetCaptureFormat()
+       */
+       Tizen::Base::Collection::IListT<Tizen::Graphics::PixelFormat>* GetSupportedCaptureFormatListN(void) const;
+
+       /**
+       * Sets the preview format of the camera. @n
+       * Initially, the default format is set using the internal configuration.
+       *
+       * @return               An error code
+       * @param[in]    format                                          The camera's preview format @n
+       *                                                                                       It should be one of the pixel formats extracted using GetSupportedPreviewFormatListN().
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_UNSUPPORTED_FORMAT            The specified format is not supported.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              This method works in ::CAMERA_STATE_INITIALIZED state. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetPreviewFormat(), GetSupportedPreviewFormatListN()
+       */
+       result SetPreviewFormat(const Tizen::Graphics::PixelFormat format);
+
+       /**
+       * Gets the preview format of the camera.
+       *
+       * @return               The preview format of the camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetPreviewFormat(), GetSupportedPreviewFormatListN()
+       */
+       Tizen::Graphics::PixelFormat GetPreviewFormat(void) const;
+
+       /**
+       * Gets the supported preview format list for the Camera class. @n
+       * Each list item has a Tizen::Graphics::PixelFormat value.
+       *
+       * @return               A list of the preview format supported by the Camera class, @n
+       *                               else @c null if no preview format is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remark               The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted. @n
+       *                               This method works correctly when PowerOn() is executed.
+       * @see                  SetPreviewFormat(), GetPreviewFormat()
+       */
+       Tizen::Base::Collection::IListT<Tizen::Graphics::PixelFormat>* GetSupportedPreviewFormatListN(void) const;
+
+
+       /**
+       * Sets the ISO level of the camera.
+       *
+       * @return               An error code
+       * @param[in]    isoLevel                                        The camera's ISO level @n
+       *                                                                                       The default ISO level is set from the internal configuration.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified ISO level is out of range.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION         This operation is not supported.
+       * @exception    E_UNSUPPORTED_TYPE                The specified @c isoLevel is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              In some devices this method works in the ::CAMERA_STATE_PREVIEW state.
+       *                               This method throws E_UNSUPPORTED_OPERATION in the emulator. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetIsoLevel()
+       */
+       result SetIsoLevel(CameraIsoLevel isoLevel);
+
+       /**
+       * Gets the ISO level of the camera.
+       *
+       * @return               The ISO level of the camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetIsoLevel()
+       */
+       CameraIsoLevel GetIsoLevel(void) const;
+
+       /**
+       * Sets the preview frame rate of the camera. @n
+       * Initially, the default frame rate is set using the internal configuration.
+       *
+       * @return               An error code
+       * @param[in]    fps                                                     The frame rate per second
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The specified @c fps is out of range on this device.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION         This operation is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              This method works in ::CAMERA_STATE_INITIALIZED state. @n@n
+       *                               For more information on the relationship between this method and the PowerOn() method, and the
+       *                          state transition caused by this method, see <a href="../com.osp.cppprogramming.help/html/dev_guide/media/launching_camera.htm
+       ">Launching the Camera</a>.
+       * @see                  GetPreviewFrameRate(), GetSupportedPreviewFrameRateListN(), FRAME_RATE_AUTO
+       */
+       result SetPreviewFrameRate(int fps);
+
+       /**
+       * Retrieves the frame rate of the camera.
+       *
+       * @return               The frame rate of the camera @n
+       *                          If the frame rate is not set using SetPreviewFrameRate(), the system-dependent default frame rate is returned.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetPreviewFrameRate(), GetSupportedPreviewFrameRateListN()
+       */
+       int GetPreviewFrameRate(void) const;
+
+       /**
+       * Gets the supported preview frame rate list for the Camera class. @n
+       * Each list item has an integer value.
+       *
+       * @return               A list of the preview frame rate supported by the Camera class, @n
+       *                               else @c null if no frame rate is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remark               The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted by the caller. @n
+       *                               This method works correctly when PowerOn() is executed. @n
+       *                               This method returns fps list that can be supported by all resolutions.
+       * @see                  SetPreviewFrameRate(), GetPreviewFrameRate(), FRAME_RATE_AUTO
+       * @see                  GetSupportedPreviewFrameRateListN(const Tizen::Graphics::Dimension& dim) const
+       */
+       Tizen::Base::Collection::IListT<int>* GetSupportedPreviewFrameRateListN(void) const;
+
+       /**
+       * Gets the supported preview frame rate list of the input resolution of the Camera class. @n
+       * Each item of the list has an integer value.
+       *
+       * @return               A list of the preview frame rate of the input preview resolution, @n
+       *                               else @c null if no frame rate is supported or an exception occurs
+       * @param[in]    dim                                             The preview resolution of the camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                   The specified input resolution is invalid.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remark               The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted by the caller. @n
+       *                               This method works correctly when PowerOn() is executed.
+       * @see                  SetPreviewFrameRate(), GetPreviewFrameRate()
+       * @see                  GetSupportedPreviewFrameRateListN(void) const
+       */
+       Tizen::Base::Collection::IListT<int>* GetSupportedPreviewFrameRateListN(const Tizen::Graphics::Dimension& dim) const;
+
+       /**
+       * Sets the orientation value in the Exchangeable Image File Format (EXIF) field of the captured data.
+       *
+       * @return               An error code
+       * @param[in]    orientation                                     The orientation value to set in EXIF
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The input value is out of range.
+       * @exception    E_UNSUPPORTED_OPERATION         This operation is not supported.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              The default value of orientation is CAMERA_EXIF_ORIENTATION_TOP_LEFT. @n
+       *                               This method works correctly when PowerOn() is executed. The orientation value set by this method can be obtained using the
+       *                               Tizen::Content::ImageData::GetOrientation() method after writing the captured data to a file.
+       */
+       result SetExifOrientation(CameraExifOrientation orientation);
+
+       /**
+       * Sets the GPS coordinates in the Exchangeable Image File Format (EXIF) field for the captured data.
+       *
+       * @return               An error code
+       * @param[in]    latitude                                        The latitude value to be set in EXIF @n
+       *                                                                                       The valid range is [-90.0, 90.0].
+       * @param[in]    longitude                                       The longitude value to be set in EXIF @n
+       *                                                                                       The valid range is [-180.0, 180.0]
+       * @param[in]    altitude                                        The altitude value to be set in EXIF
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The input value is out of range.
+       * @exception    E_UNSUPPORTED_OPERATION         This operation is not supported.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method sets the GPS coordinates and enables entering the coordinates into the Exchangeable Image File Format (EXIF).
+       * @remarks              By default, the GPS coordinates are not entered in JPEG's EXIF.
+       * @remarks              The GPS coordinates that are set using this method are entered in every call to the
+       *                               Capture() method, until DisableExifGpsCoordinates() is called or this instance is destroyed. @n
+       *                               This method works correctly when PowerOn() is executed. @n
+       *                               The values set by this method can result in an error as compared to the values stored in the Exchangeable Image File Format (EXIF) field.
+       * @see                  DisableExifGpsCoordinates()
+       */
+       result SetExifGpsCoordinates(double latitude, double longitude, float altitude);
+
+       /**
+       * Disables the insertion of the GPS coordinates in the Exchangeable Image File Format (EXIF) field for the captured data.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE                          The input value is out of range.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @see            SetExifGpsCoordinates()
+       */
+       result DisableExifGpsCoordinates(void);
+
+       /**
+       * Sets the flip type for the previewed and captured data.
+       *
+       * @return               An error code
+       * @param[in]    flip                                            The camera flip type
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                           The input value is out of range.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_UNSUPPORTED_TYPE                The specified flip type is not supported.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method works in the ::CAMERA_STATE_INITIALIZED state.
+       * @remarks              Finally the last specified type is applied even with the several types applicable.
+       * @see            GetFlip()
+       */
+       result SetFlip(CameraFlipType flip);
+
+       /**
+       * Gets the flip type for the previewed and captured data.
+       *
+       * @return               The Camera flip type
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @see    SetFlip()
+       */
+       CameraFlipType GetFlip(void) const;
+
+       /**
+       * Sets the rotation for the previewed data.
+       *
+       * @return                  An error code
+       * @param[in] rotation                                                                     The camera rotation
+       * @exception E_SUCCESS                                                     The method is successful.
+       * @exception E_INVALID_STATE                                             This instance is in an invalid state for this method.
+       * @exception E_INVALID_ARG                                      The input value is out of range.
+       * @exception E_UNSUPPORTED_OPERATION     This operation is not supported.
+       * @exception E_UNSUPPORTED_TYPE                    The specified rotation type is not supported.
+       * @exception E_SYSTEM                                                           A system error has occurred.
+       * @remarks   This method works in the ::CAMERA_STATE_INITIALIZED state.
+       * @remarks   The last specified type is applied even with the several types applicable.
+       * @remarks   This method rotates the preview and recording data but not the captured image. @n
+       *                       The captured image's orientation is always following the physical rotation.
+       * @remarks   When the preview is rotated, the preview callback data's width and height can be changed. @n
+       *                       Thus the application should recognize these changes when it uses the preview data in ICameraEventListener::OnCameraPreviewed() callback.
+       * @remarks   For the intended view of preview, Tizen::Ui::Controls::OverlayRegion::OVERLAY_REGION_TYPE_NORMAL should be selected when Tizen::Ui::Controls::OverlayRegion is created.
+       * @see                                   GetPreviewRotation()
+       *
+       */
+       result SetPreviewRotation(CameraRotation rotation);
+
+       /**
+       *
+       * Gets the rotation for the previewed data.
+       *
+       * @return                  The camera rotation
+       * @exception E_SUCCESS                                          The method is successful.
+       * @exception E_INVALID_STATE                              This instance is in an invalid state for this method.
+       * @see                    SetPreviewRotation()
+       *
+       */
+       CameraRotation GetPreviewRotation(void) const;
+
+       /**
+       * Sets the metering mode of the camera.
+       *
+       * @return               An error code
+       * @param[in]    meteringMode                            metering mode
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE            The device is unavailable.
+       * @exception    E_DEVICE_FAILED                         The device operation has failed.
+       * @exception    E_UNSUPPORTED_OPERATION  This operation is not supported.
+       * @exception    E_UNSUPPORTED_TYPE                The @c meteringMode type is not supported.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks      ::CAMERA_METERING_MODE_NONE always throws E_INVALID_ARG.
+       * @see          GetMeteringMode()
+       */
+       result SetMeteringMode(CameraMeteringMode meteringMode);
+
+       /**
+       * Gets the metering mode of the camera.
+       *
+       * @return               The %Camera metering mode
+       * @see          SetMeteringMode()
+       */
+       CameraMeteringMode GetMeteringMode(void) const;
+
+       /**
+       * Gets the camera's state.
+       *
+       * @return                  The state
+       */
+       camera_state_e GetMmState(void) const;
+
+       /**
+       * Sets the state.
+       *
+       * @param[in]    state                   _AudioRecorderImpl's state
+       */
+       void SetState(CameraState state);
+
+       /**
+       * Get the event processing object.
+       *
+       * @return          The event processing object.
+       * @remarks      This event is working synchronously.
+       */
+       _CameraEvent* GetEvent(void) const;
+
+       /**
+       * Get the camera selection.
+       *
+       * @return          The camera selection.
+       */
+       CameraSelection GetSelection(void) const;
+
+       /**
+       * Gets the preview process flag
+       *
+       * @return               The preview processing flag
+       */
+       int GetPreviewProcessing(void) const;
+
+       /**
+       * Enqueues the preview or captured data.
+       *
+       * @return          An error code
+       * @exception    E_SUCCESS                                               The method is successful.
+       * @exception    E_INVALID_ARG                   A specified input parameter is invalid.
+       * @param[in]    cameraBuffer            The data prepared for enqueing.
+       * @remarks      The preview and capture data is delivered by callback. _CameraImpl class should keep the data using Queue and consume the data in the event listener. @n
+       *                       Preview frame skip is controled in this method.
+       */
+       result EnqueueData(_CameraBuffer& cameraBuffer);
+
+       /**
+       * Dequeues the preview or captured data.
+       *
+       * @return          A buffer data
+       * @param[in]    bufferType              The buffer type
+       * @remarks      The preview and capture data is delivered by callback. _CameraImpl class should keep the data using Queue and consume the data in the event listener. @n
+       *                       Preview frame skip is controled in this method. @n
+       *                       The return value must be deleted. @n
+       *                       The return value cannot be null.
+       */
+       _CameraBuffer* DequeueDataN(_CameraBufferType bufferType);
+
+       /**
+       * Gets the queue's element count.
+       *
+       * @return          A count of queue element
+       * @param[in]    bufferType              Queue type
+       */
+       int GetDataCount(_CameraBufferType bufferType);
+
+       /**
+       * Gets the camera coordinator.
+       *
+       * @return          camera coordinator
+       */
+       _CameraCoordinator* GetCoordinator(void);
+
+       /**
+       * Gets the camera's zero shutter lag capability
+       *
+       * @return          Zero shutter lag capability
+       */
+       bool IsZeroShutterLag(void) const;
+
+       /**
+       * Called when the event is received from the %_ICameraCoordinatorListener object.
+       *
+       * @return               An error code
+       * @param[in]     message        message id
+       * @param[in]     state          camera state
+       * @param[in]     pParam0        Extra data0
+       */
+       result OnCamcorderCoordinatorEventReceived(camera_state_e previous, camera_state_e current, bool byPolicy);
+
+       /**
+       * Called when the mode is prepared to change.
+       *
+       * @return               An error code
+       * @param[in]     mode           camcorder mode
+       */
+       result OnCameraCoordinatorModeChangePrepared(_CameraMode mode);
+
+       /**
+       * Called when the mode is changed.
+       *
+       * @return               An error code
+       * @param[in]     mode           camcorder mode
+       */
+       result OnCameraCoordinatorModeChanged(_CameraMode mode);
+
+       /**
+       * Sets the preprocessing callback fuction pointer.
+       *
+       * @param[in]    pPreProcessCbFunc                       preprocessing callback fuction pointer
+       * @param[in]    pPreProcessUserData                     preprocessing userdata pointer
+       */
+       void SetPreprocessingCb(_CameraPreprocessingCallback pPreProcessCbFunc, void* pPreProcessUserData);
+
+       /**
+       * Gets the preprocessing callback fuction pointer.
+       *
+       * @param[out]   pPreProcessCbFunc                       preprocessing callback fuction pointer
+       * @param[out]   pPreProcessUserData                     preprocessing userdata pointer
+       */
+       void GetPreprocessingCb(_CameraPreprocessingCallback& pPreProcessCbFunc, void*& pPreProcessUserData);
+
+       /**
+        *      Function definition for start capture.
+        *
+        *      @return         This function returns 0 on success, else on failure.
+        *      @param[in]      mmHandle                The camcorder handle
+        */
+       static int StartMmCapture(_CameraHandle mmHandle);
+
+       /**
+        *      Function definition for state chnaged callback.
+        *
+        *      @param[in]      previous                        Previous state
+        *      @param[in]      current                 Current state
+        *      @param[in]      byPolicy                        The flag which says the state was chnaged from the policy.
+        *      @param[in]      pUserData               User parameter which is received from user when callback function was set
+        *      @remarks        This function is called in the camera created thread.
+        */
+       static void StateChangedCb(camera_state_e previous, camera_state_e current, bool byPolicy, void *pUserData);
+
+       /**
+        *      Function definition for image capture callback.
+        *
+        *      @param[in]      pImage                  Reference pointer to captured image data
+        *      @param[in]      pPostview               Reference pointer to post view image data
+        *      @param[in]      pThumbnail              Reference pointer to thumbnail data
+        *      @param[in]      pUserData               User parameter which is received from user when callback function was set
+        *      @remarks        This function is issued in the context of gstreamer (video src thread).
+        */
+       static void CaptureCb(camera_image_data_s* pImage, camera_image_data_s *pPostview, camera_image_data_s* pThumbnail, void* pUserData);
+
+       /**
+        *      Function definition for capture completion callback.
+        *
+        *      @param[in]      pUserData               User parameter which is received from user when callback function was set
+        *      @remarks        This function is issued in the context of gstreamer (video src thread).
+        */
+       static void CaptureCompletedCb(void *pUserData);
+
+       /**
+        *      Function definition for preview stream callback.
+        *
+        *      @param[in]      pFrame                  frame data structure for stream
+        *      @param[in]      pUserData                       User parameter which is received from user when callback function was set
+        *      @remarks        This function is issued in the context of gstreamer (video src thread).
+        */
+       static void PreviewCb(camera_preview_data_s *pFrame, void *pUSerData);
+
+       /**
+        *      Function definition for interrupted callback.
+        *
+        *      @param[in]      policy                  The policy which made the interruption
+        *      @param[in]      previous                        Previous state
+        *      @param[in]      current                 Current state
+        *      @param[in]      pUserData               User parameter which is received from user when callback function was set
+        *      @remarks        This function is called in the camera created thread.
+        */
+       static void InterruptedCb(camera_policy_e policy, camera_state_e previous, camera_state_e current, void *pUserData);
+
+       /**
+        *      Function definition for focus changed callback.
+        *
+        *      @param[in]      state                   focus state
+        *      @param[in]      pUserData               User parameter which is received from user when callback function was set
+        *      @remarks        This function is called in the camera created thread.
+        */
+       static void FocusStateChangedCb(camera_focus_state_e state, void *pUserData);
+
+       /**
+        *      Function check fo this object is alive.
+        *
+        * @return              true if the object is alive, otherwise false.
+        */
+       static bool IsAlive(void);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return              The pointer to %_CameraImpl
+        * @param[in]   pCamera         The %Camera pointer
+        */
+       static _CameraImpl* GetInstance(Camera *pCamera);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return              The pointer to %_CameraImpl
+        * @param[in]   pCamera         The %Camera pointer
+        */
+       static const _CameraImpl* GetInstance(const Camera *pCamera);
+
+private:
+       /**
+       * Converts the error from camera.
+       *
+       * @return          An error code
+       * @param[in]    err                      camera error
+       */
+       result ConvertResult(int err) const;
+
+       /**
+       * Set the property.
+       *
+       * @return          An error code
+       * @param[in]    operation                  camcorder's operation type
+       * @param[in]    min                                      min value
+       * @param[in]    max                              max value
+       * @param[in]    value                      value to be set
+       */
+       result SetProperty(_CameraOperationType operation, int min, int max, int value);
+
+       /**
+       * Get the property.
+       *
+       * @return          An error code
+       * @param[in]    operation                  camcorder's operation type
+       * @param[out]   mmMin                              min value
+       * @param[out]   mmMax                      max value
+       */
+       result GetProperty(_CameraOperationType operation, int& mmMin, int& mmMax) const;
+
+       /**
+       * Get the property list.
+       *
+       * @return          The property list
+       * @param[in]    operation                  camcorder's operation type
+       * @param[in]    itemQueryType      item type for verifying the list
+       * @remarks      If the list's item type and itemQueryType parameter are not same, it returns null.
+       */
+       Tizen::Base::Collection::IList* GetPropertyListN(_CameraOperationType operation, _ResultType itemQueryType) const;
+
+       /**
+       * Get the property list.
+       *
+       * @return          The property list
+       * @param[in]    key                key name
+       */
+       Tizen::Base::Collection::IList* GetPropertyListN(const Tizen::Base::String& key) const;
+
+       /**
+       * Re-load configuration.
+       *
+       * @return          An error code
+       * @param[in]    reload                            reload configuration field
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @remarks      Multiple configuration field can be set using reloadConf parameter appending.
+       */
+       result ReloadConfiguration(int reload);
+
+       /**
+       * Load default configuration.
+       *
+       * @return          An error code
+       * @param[in]    reload                            reload configuration field
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       result LoadDefaultConfiguration(int reload);
+
+       /**
+       * Change the focus state.
+       *
+       * @return       An error code
+       * @param[in]    currentMode             focus' current mode
+       * @param[in]    destMode             focus' destinationed mode
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       result ChangeFocusModeTo(CameraFocusMode currentMode, CameraFocusMode destMode);
+
+       /**
+       * Handle the auto focus operations.
+       *
+       * @return       An error code
+       * @param[in]    currentMode             focus' current mode
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       result HandleAutoFocus(CameraFocusMode currentMode);
+
+       _CameraImpl(const _CameraImpl& camera);
+       _CameraImpl& operator =(const _CameraImpl& camera);
+
+       _CameraDeviceType __deviceType;
+       _CameraCoordinator* __pCoordinator;
+       _CameraCapability* __pCameraCapability;
+
+       CameraState __state;
+       _CameraHandle __handle;
+
+       _CameraEvent* __pCameraEvent;
+       ICameraEventListener* __pCameraEventListener;
+       Tizen::Base::Collection::Queue* __pCaptureBufferQueue;
+       Tizen::Base::Collection::Queue* __pPreviewBufferQueue;
+
+       bool __isConstructed;
+       bool __isPoweredOn;
+       CameraSelection __selection;
+       int __brightness;
+       int __contrast;
+       int __exposure;
+       int __zoomLevel;
+       int __minZoomLevel;
+       int __maxZoomLevel;
+       CameraEffect __effect;
+       CameraWhiteBalance __wb;
+       CameraQuality __quality;
+       CameraIsoLevel __isoLevel;
+       CameraFlashMode __flashMode;
+       bool __zeroShutterLag;
+       CameraMeteringMode __meteringMode;
+       bool __focusCallback;
+       bool __isFocusAreaSet;
+
+       Tizen::Graphics::Dimension __previewResolution;
+       Tizen::Graphics::Dimension __deviceDefaultPreviewResolution;    // device default
+       Tizen::Graphics::Dimension __captureResolution;
+       Tizen::Graphics::Dimension __deviceDefaultCaptureResolution;    // device default
+
+       Tizen::Graphics::PixelFormat __previewFormat;
+       Tizen::Graphics::PixelFormat __deviceDefaultPreviewFormat;              // device default
+       Tizen::Graphics::PixelFormat __captureFormat;
+       Tizen::Graphics::PixelFormat __deviceDefaultCaptureFormat;              // device default
+
+       CameraExifOrientation __exifOrientation;
+       static const CameraExifOrientation CAMERA_EXIF_ORIENTATION_NONE = (CameraExifOrientation)-1;
+       double __exifLatitude;
+       double __exifLongitude;
+       float   __exifAltitude;
+
+       CameraFlipType __flip;
+       CameraRotation __previewRotation;
+       int __fps;
+       CameraFocusMode __focusMode;
+
+       int __previewProcessing;
+       Tizen::Graphics::Rectangle __previewRegionRect;
+       int __previewRegionHandle;
+       camera_display_type_e __previewDisplayType;
+       CameraRotation __displayRotationType;
+       CameraDirection __physicalDirection;
+       CameraRotation __physicalRotation;
+       static const int MAX_FOCUS_POINT = 10;
+       int __focusPoints[2][MAX_FOCUS_POINT];
+       int __supportedFocusPointCount;
+
+       static bool __isUsed;
+
+       _CameraPreprocessingCallback __pPreProcessCbFunc;
+       void* __pPreProcessUserData;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_CameraManager.cpp b/src/FMedia_CameraManager.cpp
new file mode 100755 (executable)
index 0000000..823f15d
--- /dev/null
@@ -0,0 +1,257 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraManager.cpp
+ * @brief                      This file contains the implementation of the %_CameraManager class.
+ *
+ */
+#include <pthread.h>
+#include <camera.h>
+#include <FBaseSysLog.h>
+#include "FMedia_CameraManager.h"
+
+#define MM_SUCCESS 0
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+_CameraManagerSafeHashMapT* _CameraManager::__pMap = null;
+
+_CameraManagerSafeHashMapT::_CameraManagerSafeHashMapT(void)
+{
+}
+
+_CameraManagerSafeHashMapT::~_CameraManagerSafeHashMapT(void)
+{
+       RemoveItems();
+       _CameraManager::__pMap = null;
+}
+
+void
+_CameraManagerSafeHashMapT::RemoveItems(void)
+{
+       IListT <_CameraDeviceType>* pList = null;
+       _CameraManager* pManager = null;
+       result r = E_SUCCESS;
+
+       pList = GetKeysN();
+       SysTryReturn(NID_MEDIA, pList != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
+
+       for (int i = 0; i < GetCount(); i++)
+       {
+               _CameraDeviceType deviceType = _CAMERA_DEVICE_NONE;
+               r = pList->GetAt(i, deviceType);
+               if (IsFailed(r) && deviceType == _CAMERA_DEVICE_NONE)
+               {
+                       continue;
+               }
+
+               r = GetValue(deviceType, pManager);
+               if (IsFailed(r) && pManager == null)
+               {
+                       continue;
+               }
+               delete pManager;
+       }
+       pList->RemoveAll();
+       delete pList;
+       RemoveAll();
+}
+
+_CameraManager::_CameraManager()
+       : __handle(MM_INVALID_HANDLE)
+{
+}
+
+_CameraManager::~_CameraManager()
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       err = camera_destroy(__handle);
+       r = ConvertResult(err);
+       SysLog(NID_MEDIA, "[%s] destroyed.", GetErrorMessage(r));
+}
+
+result
+_CameraManager::Construct(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+       camera_device_e device = CAMERA_DEVICE_CAMERA0;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. device:%d", cameraDevice);
+
+       device = cameraDevice == _CAMERA_DEVICE_PRIMARY ? CAMERA_DEVICE_CAMERA0 :  CAMERA_DEVICE_CAMERA1;
+
+       err = camera_create(device, &__handle);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+void
+_CameraManager::InitSafeHashMapInst()
+{
+       static _CameraManagerSafeHashMapT map;
+       result r = E_SUCCESS;
+
+       r = map.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pMap = &map;
+       return;
+CATCH:
+       __pMap = null;
+}
+
+_CameraManager*
+_CameraManager::AddInstance(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+       bool out = false;
+
+       _CameraManager* pManager = null;
+
+       SysTryReturn(NID_MEDIA, cameraDevice > _CAMERA_DEVICE_NONE && cameraDevice < _CAMERA_DEVICE_MAX,
+                               null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(cameraDevice) is used. camderDevice:%d is wrong.", cameraDevice);
+
+       static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+
+       if (!__pMap)
+       {
+               pthread_once(&once_block, InitSafeHashMapInst);
+               r = GetLastResult();
+               SysTryCatch(NID_MEDIA, __pMap != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       r = __pMap->ContainsKey(cameraDevice, out);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (out)
+       {
+               r = __pMap->GetValue(cameraDevice, pManager);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS && pManager != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else
+       {
+               pManager = new (std::nothrow) _CameraManager();
+               SysTryCatch(NID_MEDIA, pManager !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+               r = pManager->Construct(cameraDevice);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = __pMap->Add(cameraDevice, pManager);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return pManager;
+
+CATCH:
+       if (pManager != null)
+       {
+               delete pManager;
+       }
+       return null;
+}
+
+void
+_CameraManager::Release(_CameraDeviceType cameraDevice)
+{
+       result r = E_SUCCESS;
+
+       if (__pMap != null)
+       {
+               _CameraManager* pManager = null;
+               r = __pMap->GetValue(cameraDevice, pManager);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               if (pManager->ReleaseRefCount() == 0)
+               {
+                       delete pManager;
+                       r = __pMap->Remove(cameraDevice);
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+}
+
+_CameraHandle
+_CameraManager::GetHandle(void) const
+{
+       return __handle;
+}
+
+result
+_CameraManager::ConvertResult(int err) const
+{
+       result r = E_SYSTEM;
+       if (err != ::CAMERA_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "MM Err:0x%x", err);
+       }
+
+       // Global error
+       if (err == ::CAMERA_ERROR_NONE)
+       {
+               r = E_SUCCESS;
+       }
+       else if (err == ::CAMERA_ERROR_INVALID_PARAMETER)
+       {
+               r = E_INVALID_ARG;
+       }
+       else if (err == ::CAMERA_ERROR_INVALID_STATE)
+       {
+               r = E_INVALID_STATE;
+       }
+       else if (err == ::CAMERA_ERROR_OUT_OF_MEMORY)
+       {
+               r = E_OUT_OF_MEMORY;
+       }
+       else if (err == ::CAMERA_ERROR_DEVICE)
+       {
+               r = E_DEVICE_FAILED;
+       }
+       else if (err == ::CAMERA_ERROR_INVALID_OPERATION
+                       || err == ::CAMERA_ERROR_SOUND_POLICY
+                       || err == ::CAMERA_ERROR_SECURITY_RESTRICTED)
+       {
+               r = E_SYSTEM;
+       }
+       else if (err == ::CAMERA_ERROR_DEVICE_BUSY)
+       {
+               r = E_DEVICE_BUSY;
+       }
+       else if (err == ::CAMERA_ERROR_DEVICE_NOT_FOUND)
+       {
+               r = E_DEVICE_UNAVAILABLE;
+       }
+       else
+       {
+               r = E_UNKNOWN;
+       }
+
+       return r;
+}
+
+}}// Tizen::Media
diff --git a/src/FMedia_CameraManager.h b/src/FMedia_CameraManager.h
new file mode 100755 (executable)
index 0000000..f33f7da
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraManager.h
+ * @brief                      This header file contains the declarations of the %_CameraManager class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_MANAGER_H_
+#define _FMEDIA_INTERNAL_CAMERA_MANAGER_H_
+
+#include <FBaseColHashMapT.h>
+#include "FMedia_CameraTypes.h"
+#include "FMedia_CameraRefHelper.h"
+
+namespace Tizen { namespace Media
+{
+
+class _CameraManagerSafeHashMapT;
+
+/**
+ * @class      _CameraManager
+ * @brief      This class implements the _CameraManager class.
+ *
+ */
+class _CameraManager
+       : public _CameraRefHelper
+{
+public:
+       /**
+       * Get the instance of _CameraManager.
+       *
+       * @return               The _CameraManager instance
+       * @param[in]    cameraDevice                    The camera device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       static _CameraManager* AddInstance(_CameraDeviceType cameraDevice);
+
+       /**
+       * Release the specific _CameraManager.
+       *
+       * @param[in]    cameraDevice                    The camera device type
+       */
+       static void Release(_CameraDeviceType cameraDevice);
+
+       /**
+       * Gets the camera's handle
+       *
+       * @return               The handle of camera
+       */
+       _CameraHandle GetHandle(void) const;
+
+private:
+       friend class _CameraManagerSafeHashMapT;
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
+        * initialize this instance.
+        * @see                 Construct()
+        */
+       _CameraManager(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread
+        * where the Construct() method is called.
+        *
+        * @see                 Construct()
+        */
+       virtual ~_CameraManager(void);
+
+       /**
+       * Initializes this instance of _CameraManager.
+       *
+       * @return               An error code
+       * @param[in]    cameraDevice                            The camera device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       result Construct(_CameraDeviceType cameraDevice);
+
+       /**
+       * Converts the error from camera to Result.
+       *
+       * @return          An error code
+       * @param[in]    err                      camera error
+       */
+       result ConvertResult(int err) const;
+
+       _CameraManager(const _CameraManager& camera);
+       _CameraManager& operator =(const _CameraManager& camera);
+
+       static void InitSafeHashMapInst(void);
+
+       _CameraHandle __handle;
+
+       static _CameraManagerSafeHashMapT* __pMap;
+};
+
+/**
+* @class       _CameraManagerSafeHashMapT
+* @brief       This class is for handling safe HashMap.
+*
+*/
+class _CameraManagerSafeHashMapT
+       : public Tizen::Base::Collection::HashMapT<_CameraDeviceType, _CameraManager*>
+       , public virtual Tizen::Base::Collection::ICollectionT <Tizen::Base::Collection::MapEntryT <_CameraDeviceType, _CameraManager*> >
+{
+public:
+       _CameraManagerSafeHashMapT(void);
+       virtual ~_CameraManagerSafeHashMapT(void);
+       void RemoveItems(void);
+
+private:
+       _CameraManagerSafeHashMapT(const _CameraManagerSafeHashMapT& rhs);
+       _CameraManagerSafeHashMapT& operator =(const _CameraManagerSafeHashMapT& rhs);
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_CameraPreProcessUtil.cpp b/src/FMedia_CameraPreProcessUtil.cpp
new file mode 100755 (executable)
index 0000000..5e5d598
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraPreProcessUtil.h
+ * @brief                      This file contains the implementation of Camera's extened functions.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include <FMediaCamera.h>
+#include "FMedia_CameraImpl.h"
+#include "FMedia_CameraPreProcessUtil.h"
+
+namespace Tizen { namespace Media
+{
+result
+SetPreProcessingCallback(Tizen::Media::Camera &cam, _CameraPreprocessingCallback pPreProcessCbFunc, void* pPreProcessUserData)
+{
+       Tizen::Media::_CameraImpl* pCamImpl = null;
+       SysLog(NID_MEDIA, "Enter.");
+
+       pCamImpl = _CameraImpl::GetInstance(&cam);
+       SysTryReturn(NID_MEDIA, pCamImpl != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Camera is not constructed.");
+
+       pCamImpl->SetPreprocessingCb(pPreProcessCbFunc, pPreProcessUserData);
+
+       return E_SUCCESS;
+}
+
+result
+UnSetPreProcessingCallback(Tizen::Media::Camera &cam)
+{
+       Tizen::Media::_CameraImpl* pCamImpl = null;
+       SysLog(NID_MEDIA, "Enter.");
+
+       pCamImpl = _CameraImpl::GetInstance(&cam);
+       SysTryReturn(NID_MEDIA, pCamImpl != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Camera is not constructed.");
+
+       pCamImpl->SetPreprocessingCb(null, null);
+
+       return E_SUCCESS;
+}
+
+}}   // Tizen::Media
diff --git a/src/FMedia_CameraRefHelper.cpp b/src/FMedia_CameraRefHelper.cpp
new file mode 100644 (file)
index 0000000..801437a
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraRefHelper.cpp
+ * @brief                      This file contains the implementation of the %_CameraRefHelper class.
+ *
+ */
+
+#include "FMedia_CameraRefHelper.h"
+
+namespace Tizen { namespace Media
+{
+
+_CameraRefHelper::_CameraRefHelper()
+       : __refCount(0)
+{
+}
+
+_CameraRefHelper::~_CameraRefHelper()
+{
+}
+
+int
+_CameraRefHelper::AddRefCount(void)
+{
+       __refCount++;
+       return __refCount;
+}
+
+int
+_CameraRefHelper::ReleaseRefCount(void)
+{
+       if ( __refCount > 0 )
+       {
+               __refCount--;
+       }
+       return __refCount;
+}
+
+}}// Tizen::Media
diff --git a/src/FMedia_CameraRefHelper.h b/src/FMedia_CameraRefHelper.h
new file mode 100644 (file)
index 0000000..3adf6f4
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraRefHelper.h
+ *
+ * This header file contains the declarations of the %_CameraRefHelper class.
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_REF_HELPER_H_
+#define _FMEDIA_INTERNAL_CAMERA_REF_HELPER_H_
+
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class      _CameraRefHelper
+ * @brief      This class implements the _CameraRefHelper class.
+ *
+ */
+class _CameraRefHelper
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Increments the reference count by one.
+        */
+       int AddRefCount(void);
+
+       /**
+       * Decrements the reference count by one.
+       *
+       * @return               The reference count after decrement
+       */
+       int ReleaseRefCount(void);
+
+protected:
+       /**
+        * This is the default constructor for this class.
+        */
+       _CameraRefHelper(void);
+
+       /**
+        * This is the destructor for this class. @n
+        */
+       virtual ~_CameraRefHelper(void);
+
+private:
+       int __refCount;
+};
+
+}}
+#endif
+
diff --git a/src/FMedia_CameraTypes.h b/src/FMedia_CameraTypes.h
new file mode 100755 (executable)
index 0000000..789b909
--- /dev/null
@@ -0,0 +1,127 @@
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//     http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+
+/**
+ * @file                       FMedia_CameraTypes.h
+ * @brief                      This header file contains the types of the camcorder.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_TYPES_H_
+#define _FMEDIA_INTERNAL_CAMERA_TYPES_H_
+
+#include <camera.h>
+
+namespace Tizen { namespace Media
+{
+
+typedef camera_h _CameraHandle;\r
+
+#define MM_INVALID_HANDLE 0
+#define MEDIA_INVALID_VALUE -1
+#define MM_SUCCESS 0
+
+// @enum _CameraSceneMode\r
+// Defines the camera scen mode
+enum _CameraSceneMode\r
+{
+       CAMERA_SCENE_NONE,
+       CAMERA_SCENE_AUTO,
+       CAMERA_SCENE_PORTRAIT,
+       CAMERA_SCENE_LANDSCAPE,
+       CAMERA_SCENE_SPORTS,
+       CAMERA_SCENE_PARTY_INDOOR,
+       CAMERA_SCENE_BEACH_SHOW,
+       CAMERA_SCENE_SUNSET,
+       CAMERA_SCENE_DUSK_DAWN,
+       CAMERA_SCENE_FALLCOLOR,
+       CAMERA_SCENE_NIGHTSHOT,
+       CAMERA_SCENE_FIREWORK,
+       CAMERA_SCENE_TEXT,
+       CAMERA_SCENE_SHOW_WINDOW,
+       CAMERA_SCENE_CANDLELIGHT,
+       CAMERA_SCENE_BACKLIGHT
+};
+
+//@enum _CameraDisplayOrientationType\r
+//Defines the camera's display orientation type
+enum _CameraDisplayOrientationType\r
+{
+       _CAMERA_DISPLAY_NONE,\r
+       _CAMERA_DISPLAY_PORTRAIT,\r
+       _CAMERA_DISPLAY_LANDSCAPE,\r
+       _CAMERA_DISPLAY_REVERSE_PORTRAIT,\r
+       _CAMERA_DISPLAY_REVERSE_LANDSCAPE,\r
+};
+
+//
+// @enum _CameraMode\r
+// Defines the camera's mode
+//
+enum _CameraMode\r
+{
+       _CAMERA_MODE_NONE,\r
+       _CAMERA_MODE_IMAGE,\r
+       _CAMERA_MODE_VIDEO,\r
+};
+
+//
+// @enum _CameraDeviceType\r
+// Defines the camera's device type
+//
+enum _CameraDeviceType\r
+{
+       _CAMERA_DEVICE_NONE,              /**< The device none */\r
+       _CAMERA_DEVICE_PRIMARY,         /**< The primary camera */\r
+       _CAMERA_DEVICE_SECONDARY,         /**< The secondary camera */\r
+       _CAMERA_DEVICE_MAX                               /**< The max boundary */\r
+};
+\r
+//
+// @enum _ResolutionType\r
+// This represents the resolutoin type for the capability.
+//
+enum _ResolutionType\r
+{
+       _RES_NONE = 0,\r
+       _RES_128X96,\r
+       _RES_160X120,\r
+       _RES_176X144,\r
+       _RES_176X176,\r
+       _RES_240X320,\r
+       _RES_320X240,\r
+       _RES_240X400,\r
+       _RES_400X240,\r
+       _RES_352X288,\r
+       _RES_480X360,\r
+       _RES_640X360,\r
+       _RES_640X480,\r
+       _RES_720X480,\r
+       _RES_800X480,\r
+       _RES_800X600,\r
+       _RES_960X720,\r
+       _RES_1280X720,\r
+       _RES_1280X960,\r
+       _RES_1392X1392,\r
+       _RES_1600X1200,\r
+       _RES_1920X1080,\r
+       _RES_MAX = 0xfe,\r
+};
+
+}}
+
+#endif
diff --git a/src/FMedia_CameraUtil.cpp b/src/FMedia_CameraUtil.cpp
new file mode 100755 (executable)
index 0000000..0cd9911
--- /dev/null
@@ -0,0 +1,1102 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CamcorderUtil.cpp
+ * @brief                      This file contains the utility of camera.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include "FMedia_CameraUtil.h"
+#include "FMedia_Ffmpeg.h"
+
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media
+{
+
+typedef struct
+{
+       camera_pixel_format_e mmFormat;
+       MediaPixelFormat mediaFormat;
+       Tizen::Graphics::PixelFormat grpFormat;
+       double sizeRatio;
+}_PixelConvertTable;
+
+const static _PixelConvertTable _PIXEL_CONVERT[] =
+{
+       { ::CAMERA_PIXEL_FORMAT_NV12, MEDIA_PIXEL_FORMAT_NV12, PIXEL_FORMAT_NV12, 1.5 },
+       { ::CAMERA_PIXEL_FORMAT_I420, MEDIA_PIXEL_FORMAT_YUV420P, PIXEL_FORMAT_YCbCr420_PLANAR, 1.5 },
+       { ::CAMERA_PIXEL_FORMAT_YUYV, MEDIA_PIXEL_FORMAT_YUYV422, (Tizen::Graphics::PixelFormat)-1, 2.0 },
+       { ::CAMERA_PIXEL_FORMAT_UYVY, MEDIA_PIXEL_FORMAT_UYVY422, PIXEL_FORMAT_UYVY, 2.0 },
+       { ::CAMERA_PIXEL_FORMAT_RGB565, MEDIA_PIXEL_FORMAT_RGB565LE, PIXEL_FORMAT_RGB565, 2.0 },
+       { ::CAMERA_PIXEL_FORMAT_RGBA, MEDIA_PIXEL_FORMAT_RGBA8888, PIXEL_FORMAT_R8G8B8A8, 4.0 },
+       { ::CAMERA_PIXEL_FORMAT_ARGB, MEDIA_PIXEL_FORMAT_BGRA8888, PIXEL_FORMAT_ARGB8888, 4.0 },
+       { ::CAMERA_PIXEL_FORMAT_JPEG, MEDIA_PIXEL_FORMAT_NONE , PIXEL_FORMAT_JPEG, 0.0},                //MediaPixelFormat does not express the compressed type.
+};
+
+void
+_CameraUtil::GetOspMediaPixelFormat(camera_pixel_format_e mmFormat, MediaPixelFormat& mediaFormat, double& sizeRatio)
+{
+       for (unsigned int i = 0; i < sizeof(_PIXEL_CONVERT)/sizeof(_PIXEL_CONVERT[0]); i++ )
+       {
+               if ( mmFormat == _PIXEL_CONVERT[i].mmFormat )
+               {
+                       mediaFormat = _PIXEL_CONVERT[i].mediaFormat;
+                       sizeRatio = _PIXEL_CONVERT[i].sizeRatio;
+                       break;
+               }
+       }
+}
+
+void
+_CameraUtil::GetOspMediaPixelFormat(Tizen::Graphics::PixelFormat grpFormat, MediaPixelFormat& mediaFormat, double& sizeRatio)
+{
+       for (unsigned int i = 0; i < sizeof(_PIXEL_CONVERT)/sizeof(_PIXEL_CONVERT[0]); i++ )
+       {
+               if ( grpFormat == _PIXEL_CONVERT[i].grpFormat )
+               {
+                       mediaFormat = _PIXEL_CONVERT[i].mediaFormat;
+                       sizeRatio = _PIXEL_CONVERT[i].sizeRatio;
+                       break;
+               }
+       }
+}
+
+result
+_CameraUtil::_CameraUtil::GetOspGrpPixelFormat(camera_pixel_format_e mmFormat, Tizen::Graphics::PixelFormat& grpFormat)
+{
+       bool findFlag = false;
+       int size = sizeof(_PIXEL_CONVERT)/sizeof(_PIXEL_CONVERT[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if ((_PIXEL_CONVERT[i].mmFormat == mmFormat) &&
+                       ((_PIXEL_CONVERT[i].grpFormat >= PIXEL_FORMAT_RGB565) && (_PIXEL_CONVERT[i].grpFormat <= PIXEL_FORMAT_UYVY)))
+               {
+                       grpFormat = _PIXEL_CONVERT[i].grpFormat;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::_CameraUtil::GetMmPixelFormat(Tizen::Graphics::PixelFormat grpFormat, camera_pixel_format_e& mmFormat)
+{
+       bool findFlag = false;
+       int size = sizeof(_PIXEL_CONVERT)/sizeof(_PIXEL_CONVERT[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_PIXEL_CONVERT[i].grpFormat == grpFormat)
+               {
+                       mmFormat = _PIXEL_CONVERT[i].mmFormat;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_pixel_format_e mmAttr;
+       CodecType value;
+}_CodecConvertTable;
+
+const static _CodecConvertTable _CODEC_CONVERT[] =
+{
+       { ::CAMERA_PIXEL_FORMAT_JPEG, CODEC_JPEG },
+};
+
+result
+_CameraUtil::GetOspCodecType(camera_pixel_format_e mmAttr, CodecType value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CODEC_CONVERT)/sizeof(_CODEC_CONVERT[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CODEC_CONVERT[i].mmAttr == mmAttr)
+               {
+                       value = _CODEC_CONVERT[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       CameraSelection selection;
+       camera_flip_e mmAttr;
+       CameraFlipType value;
+}_CameraFlipTable;
+
+static const _CameraFlipTable _CAMERA_FLIP[] =
+{
+       {CAMERA_PRIMARY, ::CAMERA_FLIP_NONE, CAMERA_FLIP_NONE},
+       {CAMERA_PRIMARY, ::CAMERA_FLIP_HORIZONTAL, CAMERA_FLIP_HORIZONTAL},
+       {CAMERA_PRIMARY, ::CAMERA_FLIP_VERTICAL, CAMERA_FLIP_VERTICAL},
+//     {CAMERA_PRIMARY, ::CAMERA_FLIP_BOTH, },
+       {CAMERA_SECONDARY, ::CAMERA_FLIP_NONE, CAMERA_FLIP_NONE},
+       {CAMERA_SECONDARY, ::CAMERA_FLIP_HORIZONTAL, CAMERA_FLIP_HORIZONTAL},
+       {CAMERA_SECONDARY, ::CAMERA_FLIP_VERTICAL, CAMERA_FLIP_VERTICAL},
+//     {CAMERA_SECONDARY, ::CAMERA_FLIP_BOTH, },
+};
+
+result
+_CameraUtil::GetMmFlip(CameraSelection selection, CameraFlipType value, camera_flip_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_FLIP)/sizeof(_CAMERA_FLIP[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_FLIP[i].selection == selection && _CAMERA_FLIP[i].value == value)
+               {
+                       mmAttr = _CAMERA_FLIP[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspFlip(camera_flip_e mmAttr, CameraFlipType& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_FLIP)/sizeof(_CAMERA_FLIP[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_FLIP[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_FLIP[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_rotation_e mmAttr;
+       CameraRotation value;
+}_CameraRotationTable;
+
+static const _CameraRotationTable _CAMERA_ROTATION[] =
+{
+       {::CAMERA_ROTATION_NONE, CAMERA_ROTATION_NONE},
+       {::CAMERA_ROTATION_90, CAMERA_ROTATION_90},
+       {::CAMERA_ROTATION_180, CAMERA_ROTATION_180},
+       {::CAMERA_ROTATION_270, CAMERA_ROTATION_270},
+};
+
+result
+_CameraUtil::GetMmRotation(CameraRotation value, camera_rotation_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_ROTATION)/sizeof(_CAMERA_ROTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_ROTATION[i].value == value)
+               {
+                       mmAttr = _CAMERA_ROTATION[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspRotation(camera_rotation_e mmAttr, CameraRotation& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_ROTATION)/sizeof(_CAMERA_ROTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_ROTATION[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_ROTATION[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_fps_e mmAttr;
+       int value;
+}_CameraFpsTable;
+
+static const _CameraFpsTable _CAMERA_FPS[] =
+{
+       {::CAMERA_ATTR_FPS_8, 8},
+       {::CAMERA_ATTR_FPS_15, 15},
+       {::CAMERA_ATTR_FPS_24, 24},
+       {::CAMERA_ATTR_FPS_25, 25},
+       {::CAMERA_ATTR_FPS_30, 30},
+// This means that below fps are not supported in osp.
+//     {::CAMERA_ATTR_FPS_AUTO, 0xffffffff},
+//     {::CAMERA_ATTR_FPS_60, 60},
+//     {::CAMERA_ATTR_FPS_120, 120},
+};
+
+result
+_CameraUtil::GetMmFps(int value, camera_attr_fps_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_FPS)/sizeof(_CAMERA_FPS[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_FPS[i].value == value)
+               {
+                       mmAttr = _CAMERA_FPS[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspFps(camera_attr_fps_e mmAttr, int& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_FPS)/sizeof(_CAMERA_FPS[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_FPS[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_FPS[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_effect_mode_e mmAttr;
+       CameraEffect value;
+}_CameraEffectTable;
+
+static const _CameraEffectTable _CAMERA_EFFECT[] =
+{
+//     {::CAMERA_ATTR_EFFECT_NONE, CAMERA_EFFECT_COLOR},
+       {::CAMERA_ATTR_EFFECT_NONE, CAMERA_EFFECT_NONE},
+       {::CAMERA_ATTR_EFFECT_MONO, CAMERA_EFFECT_BW},
+       {::CAMERA_ATTR_EFFECT_SEPIA, CAMERA_EFFECT_SEPIA},
+       {::CAMERA_ATTR_EFFECT_NEGATIVE, CAMERA_EFFECT_NEGATIVE},
+//     {::CAMERA_ATTR_EFFECT_BLUE, },
+//     {::CAMERA_ATTR_EFFECT_GREEN, },
+//     {::CAMERA_ATTR_EFFECT_AQUA, },
+//     {::CAMERA_ATTR_EFFECT_VIOLET, },
+//     {::CAMERA_ATTR_EFFECT_ORANGE, },
+//     {::CAMERA_ATTR_EFFECT_GRAY, CAMERA_EFFECT_BW},
+//     {::CAMERA_ATTR_EFFECT_RED, },
+//     {::CAMERA_ATTR_EFFECT_ANTIQUE, },
+//     {::CAMERA_ATTR_EFFECT_WARM, },
+//     {::CAMERA_ATTR_EFFECT_PINK, },
+//     {::CAMERA_ATTR_EFFECT_YELLOW, },
+//     {::CAMERA_ATTR_EFFECT_PURPLE, },
+//     {::CAMERA_ATTR_EFFECT_EMBOSS, },
+//     {::CAMERA_ATTR_EFFECT_OUTLINE, },
+       {::CAMERA_ATTR_EFFECT_SOLARIZATION, CAMERA_EFFECT_SOLARIZE},
+//     {::CAMERA_ATTR_EFFECT_SKETCH, },
+//     {, CAMERA_EFFECT_NIGHT},
+};
+
+result
+_CameraUtil::GetMmEffect(CameraEffect value, camera_attr_effect_mode_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_EFFECT)/sizeof(_CAMERA_EFFECT[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_EFFECT[i].value == value)
+               {
+                       mmAttr = _CAMERA_EFFECT[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspEffect(camera_attr_effect_mode_e mmAttr, CameraEffect& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_EFFECT)/sizeof(_CAMERA_EFFECT[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_EFFECT[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_EFFECT[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_whitebalance_e mmAttr;
+       CameraWhiteBalance value;
+}_CameraWbTable;
+
+static const _CameraWbTable _CAMERA_WB[] =
+{
+//     {::CAMERA_ATTR_WHITE_BALANCE_NONE, },
+       {::CAMERA_ATTR_WHITE_BALANCE_AUTOMATIC, CAMERA_WHITE_BALANCE_AUTO},
+       {::CAMERA_ATTR_WHITE_BALANCE_DAYLIGHT, CAMERA_WHITE_BALANCE_SUNNY},
+       {::CAMERA_ATTR_WHITE_BALANCE_CLOUDY, CAMERA_WHITE_BALANCE_CLOUDY},
+       {::CAMERA_ATTR_WHITE_BALANCE_FLUORESCENT, CAMERA_WHITE_BALANCE_FLUORESCENT},
+       {::CAMERA_ATTR_WHITE_BALANCE_INCANDESCENT, CAMERA_WHITE_BALANCE_TUNGSTEN},
+//     {::CAMERA_ATTR_WHITE_BALANCE_SHADE, },
+//     {::CAMERA_ATTR_WHITE_BALANCE_HORIZON, },
+//     {::CAMERA_ATTR_WHITE_BALANCE_FLASH, },
+//     {::CAMERA_ATTR_WHITE_BALANCE_CUSTOM, },
+};
+
+result
+_CameraUtil::GetMmWhiteBalance(CameraWhiteBalance value, camera_attr_whitebalance_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_WB)/sizeof(_CAMERA_WB[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_WB[i].value == value)
+               {
+                       mmAttr = _CAMERA_WB[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspWhiteBalance(camera_attr_whitebalance_e mmAttr, CameraWhiteBalance& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_WB)/sizeof(_CAMERA_WB[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_WB[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_WB[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_scene_mode_e mmAttr;
+       _CameraSceneMode value;
+}_CameraSceneTable;
+
+static const _CameraSceneTable _CAMERA_SCENE[] =
+{
+       {::CAMERA_ATTR_SCENE_MODE_NORMAL, CAMERA_SCENE_NONE},
+//     {::, CAMERA_SCENE_AUTO},
+       {::CAMERA_ATTR_SCENE_MODE_PORTRAIT, CAMERA_SCENE_PORTRAIT},
+       {::CAMERA_ATTR_SCENE_MODE_LANDSCAPE, CAMERA_SCENE_LANDSCAPE},
+       {::CAMERA_ATTR_SCENE_MODE_SPORTS, CAMERA_SCENE_SPORTS},
+       {::CAMERA_ATTR_SCENE_MODE_PARTY_N_INDOOR, CAMERA_SCENE_PARTY_INDOOR},
+       {::CAMERA_ATTR_SCENE_MODE_BEACH_N_INDOOR, CAMERA_SCENE_BEACH_SHOW},
+       {::CAMERA_ATTR_SCENE_MODE_SUNSET, CAMERA_SCENE_SUNSET},
+       {::CAMERA_ATTR_SCENE_MODE_DUSK_N_DAWN, CAMERA_SCENE_DUSK_DAWN},
+       {::CAMERA_ATTR_SCENE_MODE_FALL_COLOR, CAMERA_SCENE_FALLCOLOR},
+       {::CAMERA_ATTR_SCENE_MODE_NIGHT_SCENE, CAMERA_SCENE_NIGHTSHOT},
+       {::CAMERA_ATTR_SCENE_MODE_FIREWORK, CAMERA_SCENE_FIREWORK},
+       {::CAMERA_ATTR_SCENE_MODE_TEXT, CAMERA_SCENE_TEXT},
+       {::CAMERA_ATTR_SCENE_MODE_SHOW_WINDOW, CAMERA_SCENE_SHOW_WINDOW},
+       {::CAMERA_ATTR_SCENE_MODE_CANDLE_LIGHT, CAMERA_SCENE_CANDLELIGHT},
+       {::CAMERA_ATTR_SCENE_MODE_BACKLIGHT, CAMERA_SCENE_BACKLIGHT},
+};
+
+result
+_CameraUtil::GetMmScene(_CameraSceneMode value, camera_attr_scene_mode_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_SCENE)/sizeof(_CAMERA_SCENE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_SCENE[i].value == value)
+               {
+                       mmAttr = _CAMERA_SCENE[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspScene(camera_attr_scene_mode_e mmAttr, _CameraSceneMode& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_SCENE)/sizeof(_CAMERA_SCENE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_SCENE[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_SCENE[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_af_mode_e mmAttr;
+       CameraFocusMode value;
+       bool additionalMode;
+       CameraFocusMode additionalValue;
+}_CameraFocusModeTable;
+
+static const _CameraFocusModeTable _CAMERA_FOCUS_MODE[] =
+{
+//     {::CAMERA_ATTR_AF_NONE, CAMERA_FOCUS_MODE_NONE, false, CAMERA_FOCUS_MODE_NONE},
+       {::CAMERA_ATTR_AF_NORMAL, CAMERA_FOCUS_MODE_NORMAL, true, CAMERA_FOCUS_MODE_CONTINUOUS_AUTO},
+       {::CAMERA_ATTR_AF_MACRO, CAMERA_FOCUS_MODE_MACRO, false, CAMERA_FOCUS_MODE_NONE},
+//     {::CAMERA_ATTR_INFINITE, CAMERA_FOCUS_MODE_INFINITE, false, },
+};
+
+result
+_CameraUtil::GetMmFocusMode(CameraFocusMode value, camera_attr_af_mode_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_FOCUS_MODE)/sizeof(_CAMERA_FOCUS_MODE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_FOCUS_MODE[i].value == value
+                       || (_CAMERA_FOCUS_MODE[i].additionalValue != CAMERA_FOCUS_MODE_NONE && _CAMERA_FOCUS_MODE[i].additionalValue == value))
+               {
+                       mmAttr = _CAMERA_FOCUS_MODE[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspFocusMode(camera_attr_af_mode_e mmAttr, CameraFocusMode& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_FOCUS_MODE)/sizeof(_CAMERA_FOCUS_MODE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_FOCUS_MODE[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_FOCUS_MODE[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspFocusMode(camera_attr_af_mode_e mmAttr, CameraFocusMode& value, bool& additionalMode, CameraFocusMode& additionalValue)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_FOCUS_MODE)/sizeof(_CAMERA_FOCUS_MODE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_FOCUS_MODE[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_FOCUS_MODE[i].value;
+
+                       if (_CAMERA_FOCUS_MODE[i].additionalMode == true)
+                       {
+                               additionalMode = true;
+                               additionalValue = _CAMERA_FOCUS_MODE[i].additionalValue;
+                       }
+
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_iso_e mmAttr;
+       CameraIsoLevel value;
+}_CameraIsoTable;
+
+static const _CameraIsoTable _CAMERA_ISO[] =
+{
+       {::CAMERA_ATTR_ISO_AUTO, CAMERA_ISO_AUTO},
+       {::CAMERA_ATTR_ISO_50, CAMERA_ISO_50},
+       {::CAMERA_ATTR_ISO_100, CAMERA_ISO_100},
+       {::CAMERA_ATTR_ISO_200, CAMERA_ISO_200},
+       {::CAMERA_ATTR_ISO_400, CAMERA_ISO_400},
+       {::CAMERA_ATTR_ISO_800, CAMERA_ISO_800},
+       {::CAMERA_ATTR_ISO_1600, CAMERA_ISO_1600},
+//     {::CAMERA_ATTR_ISO_3200, },
+       {::CAMERA_ATTR_ISO_AUTO, CAMERA_ISO_DEFAULT},
+       {::CAMERA_ATTR_ISO_100, CAMERA_ISO_MIN},
+       {::CAMERA_ATTR_ISO_800, CAMERA_ISO_MAX},
+       //Todo : Max ISO of U1 target is 800. Someday,
+       // We will implement that ISO MAX is setted to the highest thing among surpported ISO.
+};
+
+result
+_CameraUtil::GetMmIso(CameraIsoLevel value, camera_attr_iso_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_ISO)/sizeof(_CAMERA_ISO[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_ISO[i].value == value)
+               {
+                       mmAttr = _CAMERA_ISO[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspIso(camera_attr_iso_e mmAttr, CameraIsoLevel& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_ISO)/sizeof(_CAMERA_ISO[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_ISO[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_ISO[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_exposure_mode_e mmAttr;
+       CameraMeteringMode value;
+}_CameraMeteringModeTable;
+
+static const _CameraMeteringModeTable _CAMERA_METERING_MODE[] =
+{
+       {::CAMERA_ATTR_EXPOSURE_MODE_OFF, CAMERA_METERING_MODE_NONE},
+       {::CAMERA_ATTR_EXPOSURE_MODE_ALL, CAMERA_METERING_MODE_AVERAGE},
+       {::CAMERA_ATTR_EXPOSURE_MODE_CENTER, CAMERA_METERING_MODE_CENTER_WEIGHTED},
+       {::CAMERA_ATTR_EXPOSURE_MODE_SPOT, CAMERA_METERING_MODE_SPOT},
+//     {::CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, CAMERA_METERING_MODE_CUSTOM},
+};
+
+result
+_CameraUtil::GetMmMeteringMode(CameraMeteringMode value, camera_attr_exposure_mode_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_METERING_MODE)/sizeof(_CAMERA_METERING_MODE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_METERING_MODE[i].value == value)
+               {
+                       mmAttr = _CAMERA_METERING_MODE[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspMeteringMode(camera_attr_exposure_mode_e mmAttr, CameraMeteringMode& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_METERING_MODE)/sizeof(_CAMERA_METERING_MODE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_METERING_MODE[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_METERING_MODE[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_flash_mode_e mmAttr;
+       CameraFlashMode value;
+}_CameraFlashModeTable;
+
+static const _CameraFlashModeTable _FLASH_MODE[] =
+{
+       {::CAMERA_ATTR_FLASH_MODE_OFF, CAMERA_FLASH_MODE_OFF},
+       {::CAMERA_ATTR_FLASH_MODE_ON, CAMERA_FLASH_MODE_ON},
+       {::CAMERA_ATTR_FLASH_MODE_AUTO, CAMERA_FLASH_MODE_AUTO},
+       {::CAMERA_ATTR_FLASH_MODE_REDEYE_REDUCTION, CAMERA_FLASH_MODE_RED_EYE_REDUCTION},
+//     {::CAMERA_ATTR_FLASH_MODE_SLOW_SYNC, CAMERA_FLASH_MODE_SLOW_SYNC},
+//     {::CAMERA_ATTR_FLASH_MODE_FRONT_CURTAIN, CAMERA_FLASH_MODE_FRONT_CURTAIN},
+//     {::CAMERA_ATTR_FLASH_MODE_REAR_CURTAIN, CAMERA_FLASH_MODE_REAR_CURTAIN},
+       {::CAMERA_ATTR_FLASH_MODE_PERMANENT, CAMERA_FLASH_MODE_CONTINUOUS},
+};
+
+result
+_CameraUtil::GetMmFlashMode(CameraFlashMode value, camera_attr_flash_mode_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_FLASH_MODE)/sizeof(_FLASH_MODE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_FLASH_MODE[i].value == value)
+               {
+                       mmAttr = _FLASH_MODE[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspFlashMode(camera_attr_flash_mode_e mmAttr, CameraFlashMode& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_FLASH_MODE)/sizeof(_FLASH_MODE[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_FLASH_MODE[i].mmAttr == mmAttr)
+               {
+                       value = _FLASH_MODE[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       int mmAttr;
+       CameraQuality value;
+}_CameraQualityTable;
+
+static const _CameraQualityTable _CAMERA_QUALITY[] =
+{
+       {30, CAMERA_QUALITY_NORMAL},
+       {50, CAMERA_QUALITY_FINE},
+       {100, CAMERA_QUALITY_SUPER_FINE},
+//     {, CAMERA_QUALITY_MAX},
+};
+
+result
+_CameraUtil::GetMmQuality(CameraQuality value, int& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_QUALITY)/sizeof(_CAMERA_QUALITY[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_QUALITY[i].value == value)
+               {
+                       mmAttr = _CAMERA_QUALITY[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspQuality(int mmAttr, CameraQuality& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_QUALITY)/sizeof(_CAMERA_QUALITY[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_QUALITY[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_QUALITY[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       camera_attr_tag_orientation_e mmAttr;
+       CameraExifOrientation orientation;
+       CameraRotation rotation;
+}_CameraExifOrientationTable;
+
+static const _CameraExifOrientationTable _CAMERA_EXIF_ORIENTATION[] =
+{
+       {::CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT, CAMERA_EXIF_ORIENTATION_TOP_LEFT, CAMERA_ROTATION_NONE},
+       {::CAMERA_ATTR_TAG_ORIENTATION_TOP_RIGHT, CAMERA_EXIF_ORIENTATION_TOP_RIGHT, (CameraRotation)-1},
+       {::CAMERA_ATTR_TAG_ORIENTATION_BOTTOM_RIGHT, CAMERA_EXIF_ORIENTATION_BOTTOM_RIGHT, CAMERA_ROTATION_180},
+       {::CAMERA_ATTR_TAG_ORIENTATION_BOTTOM_LEFT, CAMERA_EXIF_ORIENTATION_BOTTOM_LEFT, (CameraRotation)-1},
+       {::CAMERA_ATTR_TAG_ORIENTATION_LEFT_TOP, CAMERA_EXIF_ORIENTATION_LEFT_TOP, (CameraRotation)-1},
+       {::CAMERA_ATTR_TAG_ORIENTATION_RIGHT_TOP, CAMERA_EXIF_ORIENTATION_RIGHT_TOP, CAMERA_ROTATION_90},
+       {::CAMERA_ATTR_TAG_ORIENTATION_RIGHT_BOTTOM, CAMERA_EXIF_ORIENTATION_RIGHT_BOTTOM, (CameraRotation)-1},
+       {::CAMERA_ATTR_TAG_ORIENTATION_LEFT_BOTTOM, CAMERA_EXIF_ORIENTATION_LEFT_BOTTOM, CAMERA_ROTATION_270},
+};
+
+result
+_CameraUtil::GetMmExifOrientation(CameraExifOrientation value, camera_attr_tag_orientation_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_EXIF_ORIENTATION)/sizeof(_CAMERA_EXIF_ORIENTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_EXIF_ORIENTATION[i].orientation == value)
+               {
+                       mmAttr = _CAMERA_EXIF_ORIENTATION[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetMmExifOrientation(CameraRotation value, camera_attr_tag_orientation_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_EXIF_ORIENTATION)/sizeof(_CAMERA_EXIF_ORIENTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_EXIF_ORIENTATION[i].rotation == value)
+               {
+                       mmAttr = _CAMERA_EXIF_ORIENTATION[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_CameraUtil::GetOspExifOrientation(camera_attr_tag_orientation_e mmAttr, CameraExifOrientation& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_EXIF_ORIENTATION)/sizeof(_CAMERA_EXIF_ORIENTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_EXIF_ORIENTATION[i].mmAttr == mmAttr)
+               {
+                       value = _CAMERA_EXIF_ORIENTATION[i].orientation;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+_ResolutionType
+_CameraUtil::ConvertResolutionType(const Tizen::Graphics::Dimension &resolution)
+{
+       _ResolutionType resolutionType = _RES_NONE;
+
+       if ( resolution.width == 128 && resolution.height == 96 )
+       {
+               resolutionType = _RES_128X96;
+       }
+       else if ( resolution.width == 160 && resolution.height == 120 )
+       {
+               resolutionType = _RES_160X120;
+       }
+       else if ( resolution.width == 176 && resolution.height == 144 )
+       {
+               resolutionType = _RES_176X144;
+       }
+       else if ( resolution.width == 176 && resolution.height == 176 )
+       {
+               resolutionType = _RES_176X176;
+       }
+       else if ( resolution.width == 240 && resolution.height == 320 )
+       {
+               resolutionType = _RES_240X320;
+       }
+       else if ( resolution.width == 320 && resolution.height == 240 )
+       {
+               resolutionType = _RES_320X240;
+       }
+       else if ( resolution.width == 240 && resolution.height == 400 )
+       {
+               resolutionType = _RES_240X400;
+       }
+       else if ( resolution.width == 400 && resolution.height == 240 )
+       {
+               resolutionType = _RES_400X240;
+       }
+       else if ( resolution.width == 352 && resolution.height == 288 )
+       {
+               resolutionType = _RES_352X288;
+       }
+       else if ( resolution.width == 480 && resolution.height == 360 )
+       {
+               resolutionType = _RES_480X360;
+       }
+       else if ( resolution.width == 640 && resolution.height == 360 )
+       {
+               resolutionType = _RES_640X360;
+       }
+       else if ( resolution.width == 640 && resolution.height == 480 )
+       {
+               resolutionType = _RES_640X480;
+       }
+       else if ( resolution.width == 720 && resolution.height == 480 )
+       {
+               resolutionType = _RES_720X480;
+       }
+       else if ( resolution.width == 800 && resolution.height == 480 )
+       {
+               resolutionType = _RES_800X480;
+       }
+       else if ( resolution.width == 800 && resolution.height == 600 )
+       {
+               resolutionType = _RES_800X600;
+       }
+       else if ( resolution.width == 960 && resolution.height == 720 )
+       {
+               resolutionType = _RES_960X720;
+       }
+       else if ( resolution.width == 1280 && resolution.height == 720 )
+       {
+               resolutionType = _RES_1280X720;
+       }
+       else if ( resolution.width == 1280 && resolution.height == 960 )
+       {
+               resolutionType = _RES_1280X960;
+       }
+       else if ( resolution.width == 1392 && resolution.height == 1392 )
+       {
+               resolutionType = _RES_1392X1392;
+       }
+       else if ( resolution.width == 1600 && resolution.height == 1200 )
+       {
+               resolutionType = _RES_1600X1200;
+       }
+       else if ( resolution.width == 1920 && resolution.height == 1080 )
+       {
+               resolutionType = _RES_1920X1080;
+       }
+
+       return resolutionType;
+}
+
+typedef struct
+{
+       CameraDirection physicalDirection;
+       _BufferInfoImpl::Orientation orientation;
+       CameraRotation displayRotation;
+}_CameraNormalRotationTable;
+
+// If the OverlayRegion type is NORMAL. _BufferInfoImpl::ROTATION_0
+static const _CameraNormalRotationTable _CAMERA_NORMAL_ROTATION[] =
+{
+       // Primary camera
+       {CAMERA_DIRECTION_BACK, _BufferInfoImpl::ORIENTATION_PORTRAIT, CAMERA_ROTATION_NONE},
+       {CAMERA_DIRECTION_BACK, _BufferInfoImpl::ORIENTATION_LANDSCAPE_REVERSE, CAMERA_ROTATION_90},
+       {CAMERA_DIRECTION_BACK, _BufferInfoImpl::ORIENTATION_PORTRAIT_REVERSE, CAMERA_ROTATION_180},
+       {CAMERA_DIRECTION_BACK, _BufferInfoImpl::ORIENTATION_LANDSCAPE, CAMERA_ROTATION_270},
+       // Secondary camera
+       {CAMERA_DIRECTION_FRONT, _BufferInfoImpl::ORIENTATION_PORTRAIT, CAMERA_ROTATION_NONE},
+       {CAMERA_DIRECTION_FRONT, _BufferInfoImpl::ORIENTATION_LANDSCAPE_REVERSE, CAMERA_ROTATION_90},
+       {CAMERA_DIRECTION_FRONT, _BufferInfoImpl::ORIENTATION_PORTRAIT_REVERSE, CAMERA_ROTATION_180},
+       {CAMERA_DIRECTION_FRONT, _BufferInfoImpl::ORIENTATION_LANDSCAPE, CAMERA_ROTATION_270},
+};
+
+result
+_CameraUtil::GetDisplayRotation(CameraDirection physicalDirection, _BufferInfoImpl::Orientation orientation, CameraRotation& displayRotation)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_NORMAL_ROTATION)/sizeof(_CAMERA_NORMAL_ROTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_NORMAL_ROTATION[i].physicalDirection == physicalDirection && _CAMERA_NORMAL_ROTATION[i].orientation == orientation)
+               {
+                       displayRotation = _CAMERA_NORMAL_ROTATION[i].displayRotation;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       CameraDirection physicalDirection;
+       CameraRotation physicalRotation;
+       _BufferInfoImpl::Orientation orientation;
+       CameraRotation displayRotation;
+}_CameraAutoRotationTable;
+
+enum
+{
+       ANY_VALUE = 0xfe
+};
+
+// In case of internal automatic rotation.   not _BufferInfoImpl::ROTATION_0
+static const _CameraAutoRotationTable _CAMERA_AUTO_ROTATION[] =
+{
+       // Primary camera
+       {CAMERA_DIRECTION_BACK, CAMERA_ROTATION_NONE, _BufferInfoImpl::Orientation(ANY_VALUE), CAMERA_ROTATION_NONE},
+       {CAMERA_DIRECTION_BACK, CAMERA_ROTATION_90, _BufferInfoImpl::Orientation(ANY_VALUE), CAMERA_ROTATION_270},
+       {CAMERA_DIRECTION_BACK, CAMERA_ROTATION_180, _BufferInfoImpl::Orientation(ANY_VALUE), CAMERA_ROTATION_180},
+       {CAMERA_DIRECTION_BACK, CAMERA_ROTATION_270, _BufferInfoImpl::Orientation(ANY_VALUE), CAMERA_ROTATION_90},
+       // Secondary camera
+#if defined (_OSP_EMUL_)
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_270, _BufferInfoImpl::ORIENTATION_PORTRAIT, CAMERA_ROTATION_90},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_270, _BufferInfoImpl::ORIENTATION_LANDSCAPE_REVERSE, CAMERA_ROTATION_270},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_270, _BufferInfoImpl::ORIENTATION_PORTRAIT_REVERSE, CAMERA_ROTATION_90},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_270, _BufferInfoImpl::ORIENTATION_LANDSCAPE, CAMERA_ROTATION_270},
+#else
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_90, _BufferInfoImpl::ORIENTATION_PORTRAIT, CAMERA_ROTATION_270},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_90, _BufferInfoImpl::ORIENTATION_LANDSCAPE_REVERSE, CAMERA_ROTATION_90},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_90, _BufferInfoImpl::ORIENTATION_PORTRAIT_REVERSE, CAMERA_ROTATION_NONE},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_90, _BufferInfoImpl::ORIENTATION_LANDSCAPE, CAMERA_ROTATION_90},
+
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_270, _BufferInfoImpl::ORIENTATION_PORTRAIT, CAMERA_ROTATION_90},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_270, _BufferInfoImpl::ORIENTATION_LANDSCAPE_REVERSE, CAMERA_ROTATION_270},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_270, _BufferInfoImpl::ORIENTATION_PORTRAIT_REVERSE, CAMERA_ROTATION_180},
+       {CAMERA_DIRECTION_FRONT, CAMERA_ROTATION_270, _BufferInfoImpl::ORIENTATION_LANDSCAPE, CAMERA_ROTATION_270},
+#endif
+};
+
+result
+_CameraUtil::GetDisplayRotation(CameraDirection physicalDirection, CameraRotation physicalRotation, _BufferInfoImpl::Orientation orientation, CameraRotation& displayRotation)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAMERA_AUTO_ROTATION)/sizeof(_CAMERA_AUTO_ROTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAMERA_AUTO_ROTATION[i].physicalDirection == physicalDirection && _CAMERA_AUTO_ROTATION[i].physicalRotation == physicalRotation)
+               {
+                       if (_CAMERA_AUTO_ROTATION[i].orientation == orientation ||
+                               (_CAMERA_AUTO_ROTATION[i].orientation < _BufferInfoImpl::ORIENTATION_PORTRAIT   // Any value is ok.
+                               || _CAMERA_AUTO_ROTATION[i].orientation > _BufferInfoImpl::ORIENTATION_LANDSCAPE_REVERSE))
+                       {
+                               displayRotation = _CAMERA_AUTO_ROTATION[i].displayRotation;
+                               findFlag = true;
+                               break;
+                       }
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+// Convert from YUYV to YUV420P only.
+result
+_CameraUtil::ConvertColorScale(const Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf, const Tizen::Graphics::Dimension& dim)
+{
+       int  r = -1;
+       int width = dim.width;
+       int height = dim.height;
+       uint8_t *pDestBuf = null;
+       AVFrame picture;
+       AVFrame frame;
+       SwsContext *pSws = null;
+
+       frame.data[0] = (uint8_t *)srcBuf.GetPointer();
+       frame.data[1] = frame.data[0] + (width * height);
+       frame.data[2] = frame.data[1] + ((width * height)/2);
+       frame.data[3] = 0;
+       frame.linesize[0] = width;
+       frame.linesize[1] = width / 2;
+       frame.linesize[2] = width / 2;
+       frame.linesize[3] = 0;
+
+       pDestBuf = (uint8_t *)dstBuf.GetPointer();
+
+       picture.data[0] = (uint8_t*)pDestBuf;
+       picture.data[1] = pDestBuf + (width * height);
+       picture.data[2] = pDestBuf + ((width * height * 5)/ 4);
+       picture.data[3] = 0;
+
+       picture.linesize[0] = width;
+       picture.linesize[1] = width / 2;
+       picture.linesize[2] = width / 2;
+       picture.linesize[3] = 0;
+
+       pSws = sws_getCachedContext(pSws, width, height, PIX_FMT_YUYV422,
+                               width, height, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
+       if (pSws == null)
+       {
+               SysLogException(NID_MEDIA, false, "[E_SYSTEM] A system error has been occurred.  Failed to get sws context.");
+               return E_SYSTEM;
+       }
+
+       r = sws_scale(pSws, frame.data, frame.linesize, 0, height, picture.data, picture.linesize);
+
+       SysLog(NID_MEDIA, "[E_SUCCESS] Converted buffer.");
+       return E_SUCCESS;
+
+}
+
+}}// Tizen::Media
diff --git a/src/FMedia_CameraUtil.h b/src/FMedia_CameraUtil.h
new file mode 100755 (executable)
index 0000000..c7b2726
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraUtil.h
+ * @brief                      This header file contains the declarations of the utility fuctions of camera.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_UTIL_H_
+#define _FMEDIA_INTERNAL_CAMERA_UTIL_H_
+
+#include <camera.h>
+#include <FGrpPixelFormat.h>
+#include <FGrpDimension.h>
+#include <FMediaTypes.h>
+#include <FMediaCameraTypes.h>
+#include <FGrp_BufferInfoImpl.h>
+#include "FMedia_CameraTypes.h"
+
+namespace Tizen { namespace Media
+{
+/**
+* @class       _CameraUtil
+* @brief       This class is utility for camera functionality.
+*
+*/
+class _CameraUtil
+       : public Tizen::Base::Object
+{
+public:
+
+       static void GetOspMediaPixelFormat(camera_pixel_format_e mmFormat, MediaPixelFormat& mediaFormat, double& sizeRatio);
+       static void GetOspMediaPixelFormat(Tizen::Graphics::PixelFormat grpFormat, MediaPixelFormat& mediaFormat, double& sizeRatio);
+       static result GetOspGrpPixelFormat(camera_pixel_format_e mmAttr, Tizen::Graphics::PixelFormat& value);
+       static result GetMmPixelFormat(Tizen::Graphics::PixelFormat value, camera_pixel_format_e& mmAttr);
+
+       static result GetOspCodecType(camera_pixel_format_e mmAttr, CodecType value);
+
+       static result GetMmFlip(CameraSelection selection, CameraFlipType value, camera_flip_e& mmAttr);
+       static result GetOspFlip(camera_flip_e mmAttr, CameraFlipType& value);
+
+       static result GetMmRotation(CameraRotation value, camera_rotation_e& mmAttr);
+       static result GetOspRotation(camera_rotation_e mmAttr, CameraRotation& value);
+
+       static result GetMmFps(int value, camera_attr_fps_e& mmAttr);
+       static result GetOspFps(camera_attr_fps_e mmAttr, int& value);
+
+       static result GetMmEffect(CameraEffect value, camera_attr_effect_mode_e& mmAttr);
+       static result GetOspEffect(camera_attr_effect_mode_e mmAttr, CameraEffect& vaue);
+
+       static result GetMmWhiteBalance(CameraWhiteBalance value, camera_attr_whitebalance_e& mmAttr);
+       static result GetOspWhiteBalance(camera_attr_whitebalance_e mmAttr, CameraWhiteBalance& value);
+
+       static result GetMmScene(_CameraSceneMode value, camera_attr_scene_mode_e& mmAttr);
+       static result GetOspScene(camera_attr_scene_mode_e mmAttr, _CameraSceneMode& value);
+
+       static result GetMmFocusMode(CameraFocusMode value, camera_attr_af_mode_e& mmAttr);
+       static result GetOspFocusMode(camera_attr_af_mode_e mmAttr, CameraFocusMode& value);
+       static result GetOspFocusMode(camera_attr_af_mode_e mmAttr, CameraFocusMode& value, bool& additionalMode, CameraFocusMode& additionalValue);
+
+       static result GetMmIso(CameraIsoLevel value, camera_attr_iso_e& mmAttr);
+       static result GetOspIso(camera_attr_iso_e mmAttr, CameraIsoLevel& value);
+
+       static result GetMmMeteringMode(CameraMeteringMode value, camera_attr_exposure_mode_e& mmAttr);
+       static result GetOspMeteringMode(camera_attr_exposure_mode_e mmAttr, CameraMeteringMode& value);
+
+       static result GetMmFlashMode(CameraFlashMode value, camera_attr_flash_mode_e& mmAttr);
+       static result GetOspFlashMode(camera_attr_flash_mode_e mmAttr, CameraFlashMode& value);
+
+       static result GetMmQuality(CameraQuality value, int& mmAttr);
+       static result GetOspQuality(int mmAttr, CameraQuality& value);
+
+       static result GetMmExifOrientation(CameraExifOrientation value, camera_attr_tag_orientation_e& mmAttr);
+       static result GetMmExifOrientation(CameraRotation value, camera_attr_tag_orientation_e& mmAttr);
+       static result GetOspExifOrientation(camera_attr_tag_orientation_e mmAttr, CameraExifOrientation& value);
+
+       static result GetDisplayRotation(CameraDirection physicalDirection, Tizen::Graphics::_BufferInfoImpl::Orientation orientation, CameraRotation& displayRotation);
+       static result GetDisplayRotation(CameraDirection physicalDirection, CameraRotation physicalRotation, Tizen::Graphics::_BufferInfoImpl::Orientation orientation, CameraRotation& displayRotation);
+
+       static _ResolutionType ConvertResolutionType(const Tizen::Graphics::Dimension &resolution);
+
+       static result ConvertColorScale(const Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf, const Tizen::Graphics::Dimension& dim);
+
+private:
+       _CameraUtil(void);
+       ~_CameraUtil(void);
+
+       _CameraUtil(const _CameraUtil& rhs);
+       _CameraUtil& operator =(const _CameraUtil& rhs);
+};
+
+}}
+#endif
diff --git a/src/FMedia_CapabilityCommon.cpp b/src/FMedia_CapabilityCommon.cpp
new file mode 100644 (file)
index 0000000..3ce7505
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        FMedia_CapabilityCommon.cpp
+ * @brief          This file contains the implementation of recorder capability header file FMedia_CapabilityTypes.h
+ */
+
+#include <FBaseSysLog.h>
+#include "FMedia_CapabilityTypes.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_MediaSafeArrayList::_MediaSafeArrayList(void)
+{
+}
+
+_MediaSafeArrayList::~_MediaSafeArrayList(void)
+{
+       RemoveItems();
+}
+
+void
+_MediaSafeArrayList::RemoveItems(void)
+{
+       RemoveAll(true);
+}
+
+result
+_MediaSafeArrayList::AddPtr (std::unique_ptr<Tizen::Base::Object> pPtr)
+{
+       result r = E_SUCCESS;
+       SysTryReturn(NID_MEDIA, pPtr != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+
+       Object* pObj = pPtr.release();
+       SysTryReturn(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The object is not found.");
+
+       r = Add(*pObj);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       if (pObj != null)
+       {
+               delete pObj;
+       }
+       return r;
+}
+
+
+}}
diff --git a/src/FMedia_CapabilityImpl.cpp b/src/FMedia_CapabilityImpl.cpp
new file mode 100755 (executable)
index 0000000..c1b2b44
--- /dev/null
@@ -0,0 +1,1960 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMedia_CapabilityImpl.cpp
+ * @brief              This file contains the implementation for header file FMedia_CapabilityImpl.h
+ *
+ */
+
+#include <unique_ptr.h>
+#include <pthread.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <FBaseInteger.h>
+#include <FBaseSysLog.h>
+#include <FBaseColIList.h>
+#include <FBaseColHashMap.h>
+#include <FIoFile.h>
+#include <FGrpDimension.h>
+#include <FGrpPixelFormat.h>
+#include <FSys_EnvironmentImpl.h>
+#include <FSys_SystemInfoImpl.h>
+#include <FMediaTypes.h>
+#include <FMediaCapabilityTypes.h>
+#include <FMediaCameraTypes.h>
+#include <FMediaAudioTypes.h>
+#include "FMedia_CapabilityImpl.h"
+#include "FMedia_CameraCapability.h"
+#include "FMedia_CameraCapabilitySession.h"
+#include "FMedia_CameraUtil.h"
+#include "FMedia_RecorderCapability.h"
+#include "FMedia_RecorderSession.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::System;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Media
+{
+const wchar_t* const AUDIORECORDER_CODEC_TYPE = L"AudioRecorder.AudioCodecType";
+const wchar_t* const AUDIORECORDER_MEDIA_CONTAINER_TYPE = L"AudioRecorder.MediaContainerType";
+const wchar_t* const VIDEORECORDER_AUDIO_CODEC_TYPE = L"VideoRecorder.AudioCodecType";
+const wchar_t* const VIDEORECORDER_VIDEO_CODEC_TYPE = L"VideoRecorder.VideoCodecType";
+const wchar_t* const VIDEORECORDER_MEDIA_CONTAINER_TYPE = L"VideoRecorder.MediaContainerType";
+const wchar_t* const VIDEORECORDER_CODEC = L"VideoRecorder.Codec";
+
+const wchar_t* const CAMERA_PRIMARY_ZOOM_LEVEL = L"Camera.Primary.ZoomLevel";
+const wchar_t* const CAMERA_SECONDARY_ZOOM_LEVEL = L"Camera.Secondary.ZoomLevel";
+
+_CapabilityImpl* _CapabilityImpl::__pCapabilityImplInst = null;
+
+void
+_CapabilityImpl::InitCapabilityImpl()
+{
+       static _CapabilityImpl capabilityImpl;
+       result r = E_SUCCESS;
+
+       r = capabilityImpl.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating.");
+
+       __pCapabilityImplInst = &capabilityImpl;
+       return;
+CATCH:
+       __pCapabilityImplInst = null;
+}
+
+_CapabilityImpl*
+_CapabilityImpl::GetInstance(void)
+{
+       static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+
+       if (!__pCapabilityImplInst)
+       {
+               pthread_once(&once_block, InitCapabilityImpl);
+       }
+
+       return __pCapabilityImplInst;
+}
+
+_CapabilityImpl::_CapabilityImpl(void)
+       : __pMap(null)
+       , __cameraCount(0)
+       , __primaryCameraDone(false)
+       , __secondaryCameraDone(false)
+       , __videoRecorderDone(false)
+       , __audioRecorderDone(false)
+{
+}
+
+
+_CapabilityImpl::~_CapabilityImpl(void)
+{
+       if (__pMap != null)
+       {
+               __pMap->RemoveAll(true);
+               delete __pMap;
+       }
+}
+
+result
+_CapabilityImpl::Construct(void)
+{
+       result r = E_SUCCESS;
+       long long length = 0;
+       int readLen = 0;
+       std::unique_ptr<char[]> pXmlBuffer;
+       FileAttributes attributes;
+       File fileObj;
+       const String mediaCapabilityFilePath(L"/usr/etc/media-capability.xml");
+       SysLog(NID_MEDIA, "Enter ");
+
+       __pMap = new (std::nothrow) HashMap();
+       SysTryCatch(NID_MEDIA, null != __pMap, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. ");
+
+       r = __pMap->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       SysLog(NID_MEDIA, "Capability XML path:%ls", mediaCapabilityFilePath.GetPointer());
+
+       r = File::GetAttributes( mediaCapabilityFilePath, attributes);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. File path is %ls", GetErrorMessage(r), mediaCapabilityFilePath.GetPointer());
+
+       length = attributes.GetFileSize();
+       SysTryCatch(NID_MEDIA, length > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating.");
+
+       pXmlBuffer.reset(new (std::nothrow) char[length]);
+       SysTryCatch(NID_MEDIA, null != pXmlBuffer.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. ");
+
+       r = fileObj.Construct(mediaCapabilityFilePath, L"r");
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+//     read the capability xml file content as parse the capability
+       readLen = fileObj.Read(pXmlBuffer.get(), length);
+       SysTryCatch(NID_MEDIA, readLen == length, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating. length:%d, readLen:%d", length,
+                          readLen);
+
+//     parse the capability file buffer all the parse key value pair shall be added in __pMap object
+       r = ParseCapability(pXmlBuffer.get(), readLen);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       //      Get the camera count
+       {
+               int cameraCount = 0;
+               bool flag = false;
+
+               r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/camera.back", flag);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               if (flag)
+               {
+                       cameraCount++;
+               }
+
+               r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/camera.front", flag);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               if (flag)
+               {
+                       cameraCount++;
+               }
+               __cameraCount = cameraCount;
+       }
+       return E_SUCCESS;
+
+CATCH:
+       SysLog(NID_MEDIA, "[%s]", GetErrorMessage(r));
+
+       if (__pMap != null)
+       {
+               __pMap->RemoveAll(true);
+               delete __pMap;
+               __pMap = 0;
+       }
+       return r;
+}
+
+typedef void (_CapabilityImpl::* KeyConvertFunc)(const String& key, String& newKey);
+typedef result (*_ValueCopyFunc)(int type, Object* pObj, void* value);
+
+typedef struct
+{
+       const wchar_t* pKey;
+       _ValueCopyFunc copy;
+       _MediaCapCategoryType category;
+} _CapabilityCopyMap;
+
+
+result
+_CapabilityImpl::CopyListInteger(int type, Object* pObj, void* value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_LIST, E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
+                               type);
+
+       IList* pSrc = dynamic_cast <IList*>(pObj);
+       IList* pDst = static_cast <IList*>(value);
+
+       SysTryReturn(NID_MEDIA, pSrc != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc is null.");
+       SysTryReturn(NID_MEDIA, pDst != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pDest is null.");
+       SysTryReturn(NID_MEDIA,
+                               pSrc->GetCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc->GetCount() is %d", pSrc->GetCount());
+
+       for (int i = 0; i < pSrc->GetCount(); i++)
+       {
+               Integer* pInt = (Integer*) pSrc->GetAt(i);
+               if (pInt)
+               {
+                       Integer* pInteger = null;
+
+                       pInteger = new (std::nothrow) Integer(*pInt);
+                       SysTryReturn(NID_MEDIA, pInteger !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                       r = pDst->Add(*pInteger);
+                       SysTryReturn(NID_MEDIA, E_SUCCESS == r, r, r, "[%s] Propagating.");
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_CapabilityImpl::CopyListString(int type, Object* pObj, void* value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_LIST, E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
+                               type);
+
+       IList* pSrc = dynamic_cast <IList*>(pObj);
+       IList* pDst = static_cast <IList*>(value);
+
+       SysTryReturn(NID_MEDIA, pSrc != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc is null.");
+       SysTryReturn(NID_MEDIA, pDst != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pDest is null.");
+       SysTryReturn(NID_MEDIA,
+                               pSrc->GetCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc->GetCount() is %d", pSrc->GetCount());
+
+       for (int i = 0; i < pSrc->GetCount(); i++)
+       {
+               String* pStr = (String*) pSrc->GetAt(i);
+               if (pStr)
+               {
+                       String* pString = null;
+
+                       pString = new (std::nothrow) String(*pStr);
+                       SysTryReturn(NID_MEDIA, pString !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                       r = pDst->Add(*pString);
+                       SysTryReturn(NID_MEDIA, E_SUCCESS == r, r, r, "[%s] Propagating.");
+               }
+       }
+       return E_SUCCESS;
+}
+
+
+result
+_CapabilityImpl::CopyListDimension(int type, Object* pObj, void* value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_LIST, E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
+                               type);
+
+       IList* pSrc = dynamic_cast <IList*>(pObj);
+       IList* pDst = static_cast <IList*>(value);
+
+       SysTryReturn(NID_MEDIA, pSrc != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc is null.");
+       SysTryReturn(NID_MEDIA, pDst != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pDest is null.");
+       SysTryReturn(NID_MEDIA,
+                               pSrc->GetCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] IList instance is not available. pSrc->GetCount() is %d", pSrc->GetCount());
+
+       for (int i = 0; i < pSrc->GetCount(); i++)
+       {
+               Dimension* pDim = (Dimension*) pSrc->GetAt(i);
+               if (pDim)
+               {
+                       Dimension* pDimension = null;
+
+                       pDimension = new (std::nothrow) Dimension(*pDim);
+                       SysTryReturn(NID_MEDIA, pDimension !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                       r = pDst->Add(*pDimension);
+                       SysTryReturn(NID_MEDIA, E_SUCCESS == r, r, r, "[%s] Propagating.");
+               }
+       }
+       return E_SUCCESS;
+}
+
+result
+_CapabilityImpl::CopyInteger(int type, Object* pObj, void* value)
+{
+       SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
+                               type);
+
+       Integer* pSrc = dynamic_cast <Integer*>(pObj);
+       int* pDst = (int*) value;
+
+       SysTryReturn(NID_MEDIA, pSrc != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Integer instance is not available. pSrc is null.");
+
+       *pDst = pSrc->ToInt();
+
+       return E_SUCCESS;
+}
+
+result
+_CapabilityImpl::CopyBool(int type, Object* pObj, void* value)
+{
+       SysTryReturn(NID_MEDIA, type == _MEDIA_CAP_VALUE_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG,
+                               "[E_INVALID_ARG] Invalid argument(Type) is used. type:%d",
+                               type);
+
+       Integer* pSrc = dynamic_cast <Integer*>(pObj);
+       bool* pDst = (bool*) value;
+
+       SysTryReturn(NID_MEDIA, pSrc != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Integer instance is not available. pSrc is null.");
+
+       *pDst = (pSrc->ToInt()) ? true : false;
+
+       return E_SUCCESS;
+}
+
+static _CapabilityCopyMap _COPY_MAP[] =
+{
+       { AUDIOIN_SAMPLE_RATE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO},
+       { AUDIOIN_SAMPLE_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO },
+
+       { AUDIOOUT_COUNT_MAX, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_AUDIO },
+       { AUDIOOUT_SAMPLE_RATE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO },
+       { AUDIOOUT_SAMPLE_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO },
+
+       { AUDIORECORDER_FORMAT, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
+
+       { AUDIORECORDER_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
+       { AUDIORECORDER_MEDIA_CONTAINER_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
+
+       { CAMERA_COUNT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+
+       { CAMERA_PRIMARY_CAPTURE_FORMAT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_CAPTURE_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_DIRECTION, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_EFFECT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_ISO_LEVEL, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_PREVIEW_FORMAT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_PREVIEW_FRAMERATE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_PREVIEW_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_RECORDING_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_ROTATION, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_BRIGHTNESS, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_CAPTURE, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_CONTRAST, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_EXPOSURE, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_FLASH, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_FOCUS, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_PREVIEW, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_RECORDING, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_ZOOM, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_WHITE_BALANCE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_ZOOM_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_FOCUS_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_FLIP, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_PREVIEW_ROTATION, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_FOCUS_POINT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_FLASH_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+       { CAMERA_PRIMARY_METERING_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
+
+       { CAMERA_SECONDARY_CAPTURE_FORMAT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_CAPTURE_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_DIRECTION, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_EFFECT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_ISO_LEVEL, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_PREVIEW_FORMAT, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_PREVIEW_FRAMERATE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_PREVIEW_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_RECORDING_RESOLUTION, _CapabilityImpl::CopyListDimension, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_ROTATION, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_BRIGHTNESS, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_CAPTURE, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_CONTRAST, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_EXPOSURE, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_FLASH, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_FOCUS, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_PREVIEW, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_RECORDING, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_ZOOM, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG, _CapabilityImpl::CopyBool, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_WHITE_BALANCE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_ZOOM_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_FOCUS_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_FLIP, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_PREVIEW_ROTATION, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_FOCUS_POINT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_FLASH_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+       { CAMERA_SECONDARY_METERING_MODE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA },
+
+       { PLAYER_AUDIO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_PLAYER },
+       { PLAYER_COUNT_MAX, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PLAYER },
+       { PLAYER_PROTOCOL, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_PLAYER },
+       { PLAYER_VIDEO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_PLAYER },
+       { PLAYER_VIDEO_HEIGHT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PLAYER },
+       { PLAYER_VIDEO_WIDTH, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PLAYER },
+
+       { VIDEORECORDER_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_CODEC },
+
+       { VIDEORECORDER_AUDIO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
+       { VIDEORECORDER_FORMAT, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
+       { VIDEORECORDER_VIDEO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
+
+       { VIDEORECORDER_AUDIO_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
+       { VIDEORECORDER_VIDEO_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
+       { VIDEORECORDER_MEDIA_CONTAINER_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
+};
+
+result
+_CapabilityImpl::GetValue(const Tizen::Base::String& key, int type, void* value)
+{
+       result r = E_SUCCESS;
+       bool found = false;
+
+       for (int i = 0; i < (int)sizeof(_COPY_MAP) / (int)sizeof(_COPY_MAP[0]); i++)
+       {
+               _CapabilityCopyMap* pInfo = (_CapabilityCopyMap*) &(_COPY_MAP[i]);
+
+               if (pInfo == 0)
+               {
+                       continue;
+               }
+               //check for valid key value and then get the corresponding value from the hash map
+               if (key.Equals(pInfo->pKey, true))
+               {
+                       // Get the value
+                       Object* pObj = __pMap->GetValue(key);
+
+                       // If not yet retrieved
+                       if ( pObj == null )
+                       {
+                               ClearLastResult();
+                               //Set the value
+                               switch (pInfo->category)
+                               {
+                                       case _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA:
+                                               if (!__primaryCameraDone && __cameraCount > 0)
+                                               {
+                                                       r = ParseCapability(_MEDIA_CAP_CATEGORY_PRIMARY_CAMERA);
+                                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                                       __primaryCameraDone = true;
+                                               }
+                                               break;
+
+                                       case _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA:
+                                               if (!__secondaryCameraDone && __cameraCount > 1)
+                                               {
+                                                       r = ParseCapability(_MEDIA_CAP_CATEGORY_SECONDARY_CAMERA);
+                                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                                       __secondaryCameraDone = true;
+                                               }
+                                               break;
+
+                                       case _MEDIA_CAP_CATEGORY_VIDEO_RECORDER:
+                                               if (!__videoRecorderDone)
+                                               {
+                                                       r = ParseCapability(_MEDIA_CAP_CATEGORY_VIDEO_RECORDER);
+                                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                                       __videoRecorderDone = true;
+                                               }
+                                               break;
+
+                                       case _MEDIA_CAP_CATEGORY_AUDIO_RECORDER:
+                                               if (!__audioRecorderDone)
+                                               {
+                                                       r = ParseCapability(_MEDIA_CAP_CATEGORY_AUDIO_RECORDER);
+                                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                                       __audioRecorderDone = true;
+                                               }
+                                               break;
+
+                                       default:
+                                               break;
+                               }
+                               // Retrieve again.
+                               pObj = __pMap->GetValue(key);
+                               SysTryReturn(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. Value is not found. key:%ls", key.GetPointer());
+                       }
+                       SysTryReturn(NID_MEDIA, pInfo->copy != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Copy function is not found.");
+
+                       r = (pInfo->copy)(type, pObj, value);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. key:%ls", GetErrorMessage(r), key.GetPointer());
+
+                       found = true;
+                       break;
+               }
+       }
+       SysTryCatch(NID_MEDIA, found, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] String instance is not available. key is not found. key:%ls", key.GetPointer());
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CapabilityImpl::GetValue(const Tizen::Base::String& key, bool& value)
+{
+       return GetValue(key, _MEDIA_CAP_VALUE_TYPE_BOOL, (void*) &value);
+}
+
+
+result
+_CapabilityImpl::GetValue(const Tizen::Base::String& key, int& value)
+{
+       return GetValue(key, _MEDIA_CAP_VALUE_TYPE_INT, (void*) &value);
+}
+
+
+result
+_CapabilityImpl::GetValue(const Tizen::Base::String& key, long long& value)
+{
+       return GetValue(key, _MEDIA_CAP_VALUE_TYPE_LONG_LONG, (void*) &value);
+}
+
+result
+_CapabilityImpl::GetValue(const Tizen::Base::String& key, double& value)
+{
+       return GetValue(key, _MEDIA_CAP_VALUE_TYPE_DOUBLE, (void*) &value);
+}
+
+result
+_CapabilityImpl::GetValue(const Tizen::Base::String& key, Tizen::Base::String& value)
+{
+       return GetValue(key, _MEDIA_CAP_VALUE_TYPE_STRING, (void*) &value);
+}
+
+result
+_CapabilityImpl::GetValueN(const Tizen::Base::String& key, Tizen::Base::Collection::IList& value)
+{
+       return GetValue(key, _MEDIA_CAP_VALUE_TYPE_LIST, (void*) &value);
+}
+
+typedef Tizen::Base::Object* (*_ValueConvertFunc)(const char* input, Object* pObj, const void* param);
+
+typedef struct
+{
+       const char* pKey;
+       int value;
+} _CharToEnumMap;
+
+static const _CharToEnumMap _AUDIO_SAMPLE_TYPE_MAP[] =
+{
+       { "PCM_U8", AUDIO_TYPE_PCM_U8 },
+       { "PCM_S8", AUDIO_TYPE_PCM_S8 },
+       { "PCM_U16_LE", AUDIO_TYPE_PCM_U16_LE },
+       { "PCM_U16_BE", AUDIO_TYPE_PCM_U16_BE },
+       { "PCM_S16_LE", AUDIO_TYPE_PCM_S16_LE },
+       { "PCM_S16_BE", AUDIO_TYPE_PCM_S16_BE },
+       { 0, 0 }
+};
+/*
+static const _CharToEnumMap _PIXEL_FORMAT_MAP[] =
+{
+       { "RGB565", PIXEL_FORMAT_RGB565 },
+       { "ARGB8888", PIXEL_FORMAT_ARGB8888 },
+       { "R8G8B8A8", PIXEL_FORMAT_R8G8B8A8 },
+       { "YUV420", PIXEL_FORMAT_YCbCr420_PLANAR },
+       { "JPEG", PIXEL_FORMAT_JPEG },
+       { 0, 0 },
+};
+*/
+static const _CharToEnumMap _CAMERA_DIRECTION_MAP[] =
+{
+       { "Front", CAMERA_DIRECTION_FRONT },
+       { "Back", CAMERA_DIRECTION_BACK },
+       { 0, 0 },
+};
+
+static const _CharToEnumMap _CAMERA_ZOOM_TYPE_MAP[] =
+{
+       { "Digital", CAMERA_ZOOM_TYPE_DIGITAL },
+       { "Smart", CAMERA_ZOOM_TYPE_SMART },
+       { 0, 0 },
+};
+/*
+static const _CharToEnumMap _CAMERA_FOCUS_MODE_MAP[] =
+{
+       { "None", CAMERA_FOCUS_MODE_NONE },
+       { "Normal", CAMERA_FOCUS_MODE_NORMAL },
+       { "Macro", CAMERA_FOCUS_MODE_MACRO },
+       { "ContinuousAuto", CAMERA_FOCUS_MODE_CONTINUOUS_AUTO },
+       { "Infinite", CAMERA_FOCUS_MODE_INFINITE },
+       { 0, 0 },
+};
+*/
+static const _CharToEnumMap _CAMERA_FLIP_TYPE_MAP[] =
+{
+       { "None", CAMERA_FLIP_NONE },
+       { "Horizontal", CAMERA_FLIP_HORIZONTAL },
+       { "Vertical", CAMERA_FLIP_VERTICAL },
+       { 0, 0 },
+};
+/*
+static const _CharToEnumMap _CAMERA_EFFECT_MAP[] =
+{
+       { "COLOR", CAMERA_EFFECT_COLOR},
+       { "BW", CAMERA_EFFECT_BW},
+       { "SEPIA", CAMERA_EFFECT_SEPIA},
+       { "SOLARIZE", CAMERA_EFFECT_SOLARIZE},
+       { "NEGATIVE", CAMERA_EFFECT_NEGATIVE},
+       { "NIGHT", CAMERA_EFFECT_NIGHT},
+       { 0, 0 },
+};
+
+static const _CharToEnumMap _CAMERA_ISO_LEVEL_MAP[] =
+{
+       { "AUTO", CAMERA_ISO_AUTO},
+       { "50", CAMERA_ISO_50},
+       { "100", CAMERA_ISO_100},
+       { "200", CAMERA_ISO_200},
+       { "400", CAMERA_ISO_400},
+       { "800", CAMERA_ISO_800},
+       { "1600", CAMERA_ISO_1600},
+       { 0, 0 },
+};
+*/
+static const _CharToEnumMap _CAMERA_ROTATION_MAP[] =
+{
+       { "0", CAMERA_ROTATION_NONE},
+       { "90", CAMERA_ROTATION_90},
+       { "180", CAMERA_ROTATION_180},
+       { "270", CAMERA_ROTATION_270},
+       { 0, 0 },
+};
+/*
+static const _CharToEnumMap _CAMERA_WB_MAP[] =
+{
+       { "AUTO", CAMERA_WHITE_BALANCE_AUTO},
+       { "SUNNY", CAMERA_WHITE_BALANCE_SUNNY},
+       { "CLOUDY", CAMERA_WHITE_BALANCE_CLOUDY},
+       { "FLUORESCENT", CAMERA_WHITE_BALANCE_FLUORESCENT},
+       { "TUNGSTEN", CAMERA_WHITE_BALANCE_TUNGSTEN},
+       { 0, 0 },
+};
+
+static const _CharToEnumMap _BOOL_MAP[] =
+{
+       { "true", true },
+       { "false", false },
+       { 0, 0 },
+};
+
+static const _CharToEnumMap _CODEC_TYPE_MAP[] =
+{
+       { "LPCM", CODEC_LPCM },
+       { "ALAW", CODEC_ALAW },
+       { "uLAW", CODEC_ULAW },
+       { "IMAD", CODEC_IMA_ADPCM },
+       { "MSAD", CODEC_MS_ADPCM },
+       { "AMR", CODEC_AMR_NB },
+       { "FLAC", CODEC_FLAC },
+       { "MP3", CODEC_MP3 },
+       { "AAC", CODEC_AAC },
+       { "AACH", CODEC_HEAAC },
+       { "AACP", CODEC_HEAAC_V2 },
+       { "AC-3", CODEC_AC3 },
+       { "VORB", CODEC_VORBIS },
+       { "WMA", CODEC_WMA },
+       { "MIDI", CODEC_MIDI },
+       { "H263", CODEC_H263 },
+       { "MPG4", CODEC_MPEG4 },
+       { "H264", CODEC_H264 },
+       { "THRA", CODEC_THEORA },
+       { "WMV", CODEC_WMV },
+       { 0, 0 }
+};
+
+static const _CharToEnumMap _MEDIA_CONTAINER_TYPE_MAP[] =
+{
+       { "WAV", MEDIA_CONTAINER_WAV },
+       { "AMR", MEDIA_CONTAINER_AMR },
+       { "AAC", MEDIA_CONTAINER_AAC },
+       { "MP3", MEDIA_CONTAINER_MP3 },
+       { "FLAC", MEDIA_CONTAINER_FLAC },
+       { "3GP", MEDIA_CONTAINER_3GP },
+       { "MP4", MEDIA_CONTAINER_MP4 },
+       { "AVI", MEDIA_CONTAINER_AVI },
+       { "ASF", MEDIA_CONTAINER_ASF },
+       { "MKV", MEDIA_CONTAINER_MKV },
+       { "MOV", MEDIA_CONTAINER_MOV },
+       { "OGG", MEDIA_CONTAINER_OGG },
+       { 0, 0 }
+};
+*/
+
+typedef Tizen::Base::Object* (*_ValueParsingFunc)(xmlNode* pRoot, Tizen::Base::Object* pObj, _ValueConvertFunc func,
+                                                                                          const void* param);
+
+typedef struct
+{
+       const wchar_t* pKey;
+       _ValueParsingFunc parser;
+       _ValueConvertFunc convert;
+       const void* param;
+} _SectionParsingInfo;
+
+Tizen::Base::Object*
+_CapabilityImpl::ConvertCharToInteger(const char* input, Object* pObj, const void* param)
+{
+       Tizen::Base::String str(input);
+       Integer* pInt = 0;
+       int i = 0;
+       result res = E_SUCCESS;
+//     bool integerCreated = false;
+
+       res = Tizen::Base::Integer::Parse(str, i);
+       SysTryReturn(NID_MEDIA, res == E_SUCCESS, pInt, res, "[%s] Propagating.", res);
+
+       if (pObj)
+       {
+               pInt = dynamic_cast <Integer*>(pObj);
+       }
+       else
+       {
+               pInt = new (std::nothrow) Integer();
+//             integerCreated = true;
+       }
+
+       SysTryCatch(NID_MEDIA, null != pInt, res = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Integer is null");
+
+       *pInt = i;
+
+       return pInt;
+
+CATCH:
+       return null;
+}
+
+Tizen::Base::Object*
+_CapabilityImpl::ConvertCharToString(const char* input, Object* pObj, const void* param)
+{
+       String* pStr = pObj ? (String*) pObj : new (std::nothrow) String();
+       SysTryReturn(NID_MEDIA, pStr !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+       *pStr = input;
+
+       return pStr;
+}
+
+
+Tizen::Base::Object*
+_CapabilityImpl::ConvertCharToEnum(const char* input, Object* pObj, const void* param)
+{
+       Tizen::Base::String str(input);
+       Integer* pInt = null;
+       _CharToEnumMap* pMap = (_CharToEnumMap*) param;
+       bool found = false;
+       bool integerCreated = false;
+
+       if (pObj != null)
+       {
+               pInt = (Integer*) pObj;
+       }
+       else
+       {
+               pInt = new (std::nothrow) Integer();
+               integerCreated = true;
+       }
+
+       SysTryCatch(NID_MEDIA, null != pInt, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Integer is null");
+
+       while (pMap != null && pMap->pKey)
+       {
+               if (str.Equals(pMap->pKey, false))
+               {
+                       *pInt = pMap->value;
+                       found = true;
+                       break;
+               }
+               pMap++;
+       }
+
+       if (found)
+       {
+               return pInt;
+       }
+       else
+       {
+               SysLog(NID_MEDIA, "Failed : %s pMap=0x%x", input, param);
+               if (integerCreated)
+               {
+                       delete pInt;
+               }
+
+               return 0;
+       }
+
+CATCH:
+       return null;
+}
+
+Tizen::Base::Object*
+_CapabilityImpl::ConvertCharToDimension(const char* input, Object* pObj, const void* param)
+{
+       Tizen::Base::String str;
+       Dimension* pDim = null;
+       StringTokenizer tok(input, L" x");
+       int w = 0;
+       int h = 0;
+       int count = 0;
+       result res = E_SUCCESS;
+
+       pDim = pObj ? (Dimension*) pObj : new (std::nothrow) Dimension();
+       SysTryReturn(NID_MEDIA, pDim !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+       count = tok.GetTokenCount();
+       SysTryReturn(NID_MEDIA, count == 2, pDim, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Token should be two, token count:%d", count);
+
+       tok.GetNextToken(str);
+       res = Tizen::Base::Integer::Parse(str, w);
+       SysTryReturn(NID_MEDIA, res == E_SUCCESS, pDim, res, "[%s] Propagating.");
+
+       tok.GetNextToken(str);
+       res = Tizen::Base::Integer::Parse(str, h);
+       SysTryReturn(NID_MEDIA, res == E_SUCCESS, pDim, res, "[%s] Propagating.");
+
+       pDim->width = w;
+       pDim->height = h;
+
+       return pDim;
+}
+
+Tizen::Base::Object*
+ParseValueList(xmlNode* pRoot, Tizen::Base::Object* pObj, _ValueConvertFunc func, const void* param)
+{
+       xmlNode* pNode = null;
+       xmlNode* pChild = null;
+       _MediaSafeArrayList* pList = null;
+
+       pList = pObj ? (_MediaSafeArrayList*) pObj : new (std::nothrow) _MediaSafeArrayList();
+       SysTryReturn(NID_MEDIA, pList !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+       for (pNode = pRoot->children; pNode; pNode = pNode->next)
+       {
+               if (pNode->type == XML_ELEMENT_NODE && pNode->children)
+               {
+                       pChild = pNode->children;
+
+                       if (pChild->type == XML_TEXT_NODE && pChild->content)
+                       {
+                               Object* pRet = func((const char*) pChild->content, 0, param);
+                               if (pRet)
+                               {
+                                       pList->Add(*pRet);
+                               }
+                       }
+               }
+       }
+
+       return pList;
+}
+
+Tizen::Base::Object*
+ParseContent(xmlNode* pRoot, Tizen::Base::Object* pObj, _ValueConvertFunc func, const void* param)
+{
+       xmlNode* pNode = null;
+
+       for (pNode = pRoot->children; pNode; pNode = pNode->next)
+       {
+               if (pNode->type == XML_TEXT_NODE && pNode->content)
+               {
+                       pObj = func((const char*) pNode->content, pObj, param);
+               }
+       }
+
+       return pObj;
+}
+
+//key to corresponding value conversion function map
+static _SectionParsingInfo _PARSING_INFO[] =
+{
+       { AUDIOIN_SAMPLE_RATE, ParseValueList, _CapabilityImpl::ConvertCharToInteger, 0 },
+       { AUDIOIN_SAMPLE_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _AUDIO_SAMPLE_TYPE_MAP },
+
+       { AUDIOOUT_COUNT_MAX, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
+       { AUDIOOUT_SAMPLE_RATE, ParseValueList, _CapabilityImpl::ConvertCharToInteger, 0 },
+       { AUDIOOUT_SAMPLE_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _AUDIO_SAMPLE_TYPE_MAP },
+
+       { AUDIORECORDER_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+
+//     { AUDIORECORDER_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
+//     { AUDIORECORDER_MEDIA_CONTAINER_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _MEDIA_CONTAINER_TYPE_MAP},
+
+//     { CAMERA_PRIMARY_CAPTURE_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
+//     { CAMERA_PRIMARY_CAPTURE_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0 },
+       { CAMERA_PRIMARY_DIRECTION, ParseContent, _CapabilityImpl::ConvertCharToEnum, _CAMERA_DIRECTION_MAP },
+//     { CAMERA_PRIMARY_EFFECT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_EFFECT_MAP },
+//     { CAMERA_PRIMARY_ISO_LEVEL, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ISO_LEVEL_MAP },
+//     { CAMERA_PRIMARY_PREVIEW_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
+//     { CAMERA_PRIMARY_PREVIEW_FRAMERATE, ParseValueList, _CapabilityImpl::ConvertCharToInteger, 0 },
+//     { CAMERA_PRIMARY_PREVIEW_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0 },
+       { CAMERA_PRIMARY_ROTATION, ParseContent, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ROTATION_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_BRIGHTNESS, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_CAPTURE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_CONTRAST, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_EXPOSURE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_FLASH, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_FOCUS, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_PREVIEW, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_RECORDING, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_ZOOM, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_PRIMARY_WHITE_BALANCE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+       { CAMERA_PRIMARY_ZOOM_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ZOOM_TYPE_MAP },
+//     { CAMERA_PRIMARY_RECORDING_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0},
+//     { CAMERA_PRIMARY_FOCUS_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FOCUS_MODE_MAP },
+       { CAMERA_PRIMARY_FLIP, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FLIP_TYPE_MAP },
+       { CAMERA_PRIMARY_PREVIEW_ROTATION, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ROTATION_MAP },
+//     { CAMERA_PRIMARY_ZOOM_LEVEL, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0},
+       { CAMERA_PRIMARY_FOCUS_POINT, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
+//     { CAMERA_PRIMARY_FLASH_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FLASH_MODE_MAP },
+//     { CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT, ParseContent, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
+//     { CAMERA_PRIMARY_METERING_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_METERING_MODE_MAP },
+
+//     { CAMERA_SECONDARY_CAPTURE_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
+//     { CAMERA_SECONDARY_CAPTURE_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0 },
+       { CAMERA_SECONDARY_DIRECTION, ParseContent, _CapabilityImpl::ConvertCharToEnum, _CAMERA_DIRECTION_MAP },
+//     { CAMERA_SECONDARY_EFFECT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_EFFECT_MAP },
+//     { CAMERA_SECONDARY_ISO_LEVEL, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ISO_LEVEL_MAP },
+//     { CAMERA_SECONDARY_PREVIEW_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
+//     { CAMERA_SECONDARY_PREVIEW_FRAMERATE, ParseValueList, _CapabilityImpl::ConvertCharToInteger, 0 },
+//     { CAMERA_SECONDARY_PREVIEW_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0 },
+       { CAMERA_SECONDARY_ROTATION, ParseContent, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ROTATION_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_BRIGHTNESS, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_CAPTURE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_CONTRAST, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_EXPOSURE, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_FLASH, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_FOCUS, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_PREVIEW, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_RECORDING, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_ZOOM, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG, ParseContent, _CapabilityImpl::ConvertCharToEnum, _BOOL_MAP },
+//     { CAMERA_SECONDARY_WHITE_BALANCE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_WB_MAP },
+       { CAMERA_SECONDARY_ZOOM_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ZOOM_TYPE_MAP },
+//     { CAMERA_SECONDARY_RECORDING_RESOLUTION, ParseValueList, _CapabilityImpl::ConvertCharToDimension, 0},
+//     { CAMERA_SECONDARY_FOCUS_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FOCUS_MODE_MAP },
+       { CAMERA_SECONDARY_FLIP, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FLIP_TYPE_MAP },
+       { CAMERA_SECONDARY_PREVIEW_ROTATION, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_ROTATION_MAP },
+//     { CAMERA_SECONDARY_ZOOM_LEVEL, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0},
+       { CAMERA_SECONDARY_FOCUS_POINT, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
+//     { CAMERA_SECONDARY_FLASH_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_FLASH_MODE_MAP },
+//     { CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT, ParseContent, _CapabilityImpl::ConvertCharToEnum, _PIXEL_FORMAT_MAP },
+//     { CAMERA_SECONDARY_METERING_MODE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CAMERA_METERING_MODE_MAP },
+
+       { PLAYER_AUDIO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+       { PLAYER_COUNT_MAX, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
+       { PLAYER_PROTOCOL, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+       { PLAYER_VIDEO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+       { PLAYER_VIDEO_HEIGHT, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
+       { PLAYER_VIDEO_WIDTH, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
+
+       { VIDEORECORDER_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+
+       { VIDEORECORDER_AUDIO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+       { VIDEORECORDER_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+       { VIDEORECORDER_VIDEO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+
+//     { VIDEORECORDER_AUDIO_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
+//     { VIDEORECORDER_VIDEO_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
+//     { VIDEORECORDER_MEDIA_CONTAINER_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _MEDIA_CONTAINER_TYPE_MAP},
+};
+
+
+void
+_CapabilityImpl::ParseSection(xmlNode* pRoot, const String& section)
+{
+       xmlNode* pNode = null;
+       result r = E_SUCCESS;
+
+       //capability xml buffer parsing loop
+       for (pNode = pRoot->children; pNode; pNode = pNode->next)
+       {
+               if (pNode->type == XML_ELEMENT_NODE)
+               {
+                       String name((char*) pNode->name);
+                       String key(section);
+                       Object* pValue = 0;
+                       key += "." + name;
+
+                       if (key.Equals(L"Camera.Primary", true) || key.Equals(L"Camera.Secondary", true))
+                       {
+                               ParseSection(pNode, key);
+                       }
+                       else
+                       {
+                               pValue = __pMap->GetValue(key);
+
+                               for (int i = 0; i < (int)sizeof(_PARSING_INFO) / (int)sizeof(_PARSING_INFO[0]); i++)
+                               {
+                                       if (key.Equals(_PARSING_INFO[i].pKey, true))
+                                       {
+                                               Object* pRet = (_PARSING_INFO[i].parser)(pNode, pValue, _PARSING_INFO[i].convert, _PARSING_INFO[i].param);
+                                               if (pValue == null)
+                                               {
+                                                       String* pKey = null;
+                                                       pKey = new (std::nothrow) Tizen::Base::String(key);
+                                                       SysTryReturn(NID_MEDIA, pKey !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                                       r = __pMap->Add(*pKey, *pRet);
+                                                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                               }
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+result
+_CapabilityImpl::ParseCapability(const char* pXmlBuffer, int length)
+{
+       xmlDoc* pDoc = null;
+       xmlNode* pRoot = null;
+       xmlNode* pNode = null;
+       result r = E_SUCCESS;
+       String name;
+
+       pDoc = xmlParseMemory(pXmlBuffer, length);
+       SysTryCatch(NID_MEDIA, pDoc != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. xmlParseMemory failed %s %d", pXmlBuffer, length);
+
+       pRoot = xmlDocGetRootElement(pDoc);
+       SysTryCatch(NID_MEDIA, pRoot != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. xmlDocGetRootElement failed : %d %d", pDoc, pRoot);
+
+       name = (const char*) (pRoot->name);
+       SysTryCatch(NID_MEDIA, name.Equals("MediaCapability", true), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid Root Name %ls", name.GetPointer());
+
+       for (pNode = pRoot->children; pNode; pNode = pNode->next)
+       {
+               String countryName;
+
+               if (pNode->type == XML_ELEMENT_NODE)
+               {
+                       String name((char*) pNode->name);
+                       ParseSection(pNode, name);
+               }
+       }
+
+       xmlFreeDoc(pDoc);
+       return E_SUCCESS;
+
+CATCH:
+       if (pDoc != null)
+       {
+               xmlFreeDoc(pDoc);
+       }
+
+       return r;
+}
+
+result _CapabilityImpl::ParseCapability(_MediaCapCategoryType category)
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, category > _MEDIA_CAP_CATEGORY_NONE && category <= _MEDIA_CAP_CATEGORY_CODEC
+               , r = E_INVALID_ARG, r, "[E_INVALID_ARG] Invalid argument(category) is used. category:%d", category);
+       SysLog(NID_MEDIA, "Enter. category : %d", category);
+
+       switch(category)
+       {
+               case _MEDIA_CAP_CATEGORY_AUDIO:
+                       break;
+
+               case _MEDIA_CAP_CATEGORY_IMAGE:
+                       break;
+
+               case _MEDIA_CAP_CATEGORY_PLAYER:
+                       break;
+
+               case _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA:
+               {
+                       // For the performance, prevent the repeat camera object creation and deletion.
+                       // This session will hold the ref count +1.
+                       _ResultType itemType = _RESULT_NONE;
+                       _CameraCapabilitySession cameraSession;
+                       r = cameraSession.Construct(_CAMERA_DEVICE_PRIMARY);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_COUNT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(__cameraCount);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_CAPTURE_FORMAT, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_CAPTURE_FORMAT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               if (pList == null || pList->GetCount() == 0)
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_CAPTURE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(false);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               else
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_CAPTURE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(true);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_CAPTURE_RESOLUTION, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_CAPTURE_RESOLUTION);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_EFFECT, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_EFFECT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_ISO_LEVEL, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_ISO_LEVEL);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_PREVIEW_FORMAT, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_PREVIEW_FORMAT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               if (pList == null || pList->GetCount() == 0)
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_PREVIEW);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(false);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               else
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_PREVIEW);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(true);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_PREVIEW_FRAMERATE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_PREVIEW_FRAMERATE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_PREVIEW_RESOLUTION, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_PREVIEW_RESOLUTION);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer *pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_FLASH);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_FLASH_MODE));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer *pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_FOCUS);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_FOCUS_MODE));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer* pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_BRIGHTNESS);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_BRIGHTNESS));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer* pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_CONTRAST);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_CONTRAST));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer* pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_EXPOSURE);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_EXPOSURE));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+#if 0
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_ZOOM_TYPE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_ZOOM_TYPE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+#endif
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_FOCUS_MODE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_FOCUS_MODE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_FLASH_MODE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_FLASH_MODE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_METERING_MODE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_METERING_MODE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               Object* pObj = _CameraCapability::GetValueN(_COP_PRIMARY_PREVIEW_FORMAT, _QUERY_DEFAULT_VALUE, itemType);
+                               if (pObj != null)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_DEFAULT_PREVIEW_FORMAT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pObj);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer* pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_ZOOM);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_PRIMARY_ZOOM_LEVEL));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               Object* pObj = _CameraCapability::GetValueN(_COP_PRIMARY_ZERO_SHUTTER_LAG, _QUERY_DEFAULT_VALUE, itemType);
+                               if (pObj != null)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_ZERO_SHUTTER_LAG);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pObj);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_WHITE_BALANCE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_WHITE_BALANCE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               bool exist = false;
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_PRIMARY_RECORDING_RESOLUTION, itemType);
+
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_RECORDING_RESOLUTION);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                       exist = true;
+                               }
+
+                               if (exist)
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_RECORDING);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(true);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               else
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_PRIMARY_SUPPORT_RECORDING);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(false);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+               }
+                       break;
+
+               case _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA:
+               {
+                       // For the performance, prevent the repeat camera object creation and deletion.
+                       // This session will hold the ref count +1.
+                       _ResultType itemType = _RESULT_NONE;
+                       _CameraCapabilitySession cameraSession;
+                       r = cameraSession.Construct(_CAMERA_DEVICE_SECONDARY);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_CAPTURE_FORMAT, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_CAPTURE_FORMAT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               if (pList == null || pList->GetCount() == 0)
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_CAPTURE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(false);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               else
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_CAPTURE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(true);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_CAPTURE_RESOLUTION, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_CAPTURE_RESOLUTION);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_EFFECT, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_EFFECT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_ISO_LEVEL, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_ISO_LEVEL);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_PREVIEW_FORMAT, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_PREVIEW_FORMAT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               if (pList == null || pList->GetCount() == 0)
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_PREVIEW);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(false);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               else
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_PREVIEW);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(true);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_PREVIEW_FRAMERATE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_PREVIEW_FRAMERATE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_PREVIEW_RESOLUTION, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_PREVIEW_RESOLUTION);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer *pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_FLASH);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_FLASH_MODE));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer *pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_FOCUS);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_FOCUS_MODE));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer* pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_BRIGHTNESS);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_BRIGHTNESS));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer* pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_CONTRAST);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_CONTRAST));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer* pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_EXPOSURE);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_EXPOSURE));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_FOCUS_MODE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_FOCUS_MODE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_FLASH_MODE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_FLASH_MODE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_METERING_MODE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_METERING_MODE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               Object* pObj = _CameraCapability::GetValueN(_COP_SECONDARY_PREVIEW_FORMAT, _QUERY_DEFAULT_VALUE, itemType);
+                               if (pObj != null)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_DEFAULT_PREVIEW_FORMAT);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pObj);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               String* pKey = null;
+                               Integer* pInteger = null;
+
+                               pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_ZOOM);
+                               SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                               pInteger = new (std::nothrow) Integer(_CameraCapability::IsSupported(_COP_SECONDARY_ZOOM_LEVEL));
+                               SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                               r = __pMap->Add(*pKey, *pInteger);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+
+                       {
+                               Object* pObj = _CameraCapability::GetValueN(_COP_SECONDARY_ZERO_SHUTTER_LAG, _QUERY_DEFAULT_VALUE, itemType);
+                               if (pObj != null)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_ZERO_SHUTTER_LAG);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pObj);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_WHITE_BALANCE, itemType);
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_WHITE_BALANCE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               bool exist = false;
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _CameraCapability::GetListN(_COP_SECONDARY_RECORDING_RESOLUTION, itemType);
+
+                               if (pList)
+                               {
+                                       String* pKey = null;
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_RECORDING_RESOLUTION);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                       exist = true;
+                               }
+
+                               if (exist)
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_RECORDING);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(true);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                               else
+                               {
+                                       String* pKey = null;
+                                       Integer* pInteger = null;
+
+                                       pKey = new (std::nothrow) String(CAMERA_SECONDARY_SUPPORT_RECORDING);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       pInteger = new (std::nothrow) Integer(false);
+                                       SysTryCatch(NID_MEDIA, pInteger !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The value is not created.");
+
+                                       r = __pMap->Add(*pKey, *pInteger);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+               }
+                       break;
+
+               case _MEDIA_CAP_CATEGORY_VIDEO_RECORDER:
+               {
+                       _ResultType itemType = _RESULT_NONE;
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_VROP_FILE_FORMAT, itemType);
+
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(VIDEORECORDER_MEDIA_CONTAINER_TYPE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_VROP_VIDEO_ENCODER, itemType);
+
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(VIDEORECORDER_VIDEO_CODEC_TYPE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_VROP_AUDIO_ENCODER, itemType);
+
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(VIDEORECORDER_AUDIO_CODEC_TYPE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+               }
+                       break;
+
+               case _MEDIA_CAP_CATEGORY_AUDIO_RECORDER:
+               {
+                       _ResultType itemType = _RESULT_NONE;
+                       _RecorderSession recorderSession;
+                       r = recorderSession.Construct(_RECORDER_SOURCE_AUDIO);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_AROP_FILE_FORMAT, itemType);
+
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(AUDIORECORDER_MEDIA_CONTAINER_TYPE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+
+                       {
+                               _MediaSafeArrayList* pList = (_MediaSafeArrayList*) _RecorderCapability::GetListN(_AROP_AUDIO_ENCODER, itemType);
+
+                               if (pList)
+                               {
+                                       String* pKey = null;
+
+                                       pKey = new (std::nothrow) String(AUDIORECORDER_CODEC_TYPE);
+                                       SysTryCatch(NID_MEDIA, pKey !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+
+                                       r = __pMap->Add(*pKey, *pList);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               }
+                       }
+               }
+                       break;
+
+               case _MEDIA_CAP_CATEGORY_CODEC:
+                       break;
+
+               default:
+                       break;
+       }
+
+       return r;
+CATCH:
+       return r;
+}
+
+}}// Tizen::Media
+
diff --git a/src/FMedia_CapabilityTypes.h b/src/FMedia_CapabilityTypes.h
new file mode 100755 (executable)
index 0000000..6dc0c38
--- /dev/null
@@ -0,0 +1,160 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CapabilityTypes.h
+ * @brief                      This header file contains the types of the capability.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAPABILITY_TYPES_H_
+#define _FMEDIA_INTERNAL_CAPABILITY_TYPES_H_
+
+#include <unique_ptr.h>
+#include <FBaseColArrayList.h>
+
+namespace Tizen { namespace Media
+{
+#define MM_INVALID_HANDLE 0
+#define MEDIA_INVALID_VALUE -1
+#define MM_SUCCESS 0
+
+//
+// @enum _CameraOperationType
+// This represents the camera operation type.
+//
+enum _CameraOperationType
+{
+       _COP_NONE = 0,
+       _COP_PRIMARY_CAPTURE_FORMAT, // 1
+       _COP_PRIMARY_CAPTURE_RESOLUTION,
+       _COP_PRIMARY_DIRECTION,
+       _COP_PRIMARY_EFFECT,
+       _COP_PRIMARY_ISO_LEVEL,
+       _COP_PRIMARY_PREVIEW_FORMAT,
+       _COP_PRIMARY_PREVIEW_FRAMERATE,
+       _COP_PRIMARY_PREVIEW_RESOLUTION,
+       _COP_PRIMARY_RECORDING_RESOLUTION,
+       _COP_PRIMARY_ROTATION,
+       _COP_PRIMARY_BRIGHTNESS, //11
+       _COP_PRIMARY_CONTRAST,
+       _COP_PRIMARY_EXPOSURE,
+       _COP_PRIMARY_FLASH_MODE,
+       _COP_PRIMARY_FOCUS_MODE,
+       _COP_PRIMARY_METERING_MODE,
+       _COP_PRIMARY_WHITE_BALANCE,
+       _COP_PRIMARY_ZOOM_TYPE,
+       _COP_PRIMARY_FLIP,
+       _COP_PRIMARY_PREVIEW_ROTATION,
+       _COP_PRIMARY_ZERO_SHUTTER_LAG, //21
+       _COP_PRIMARY_ZOOM_LEVEL,
+       _COP_PRIMARY_MAX_FRAMERATE,
+
+
+       _COP_SECONDARY_CAPTURE_FORMAT, //24
+       _COP_SECONDARY_CAPTURE_RESOLUTION,
+       _COP_SECONDARY_DIRECTION,
+       _COP_SECONDARY_EFFECT,
+       _COP_SECONDARY_ISO_LEVEL,
+       _COP_SECONDARY_PREVIEW_FORMAT,
+       _COP_SECONDARY_PREVIEW_FRAMERATE,
+       _COP_SECONDARY_PREVIEW_RESOLUTION, //31
+       _COP_SECONDARY_RECORDING_RESOLUTION,
+       _COP_SECONDARY_ROTATION,
+       _COP_SECONDARY_BRIGHTNESS,
+       _COP_SECONDARY_CONTRAST,
+       _COP_SECONDARY_EXPOSURE,
+       _COP_SECONDARY_FLASH_MODE,
+       _COP_SECONDARY_FOCUS_MODE,
+       _COP_SECONDARY_METERING_MODE,
+       _COP_SECONDARY_WHITE_BALANCE,
+       _COP_SECONDARY_ZOOM_TYPE, //41
+       _COP_SECONDARY_FLIP,
+       _COP_SECONDARY_PREVIEW_ROTATION,
+       _COP_SECONDARY_ZERO_SHUTTER_LAG,
+       _COP_SECONDARY_ZOOM_LEVEL,
+       _COP_SECONDARY_MAX_FRAMERATE,
+
+       _COP_MAX
+};
+
+//
+// @enum _RecorderOperationType
+// This represents the recorder operation type.
+//
+enum _RecorderOperationType
+{
+       _ROP_NONE = 0,
+       _VROP_FILE_FORMAT,
+       _VROP_AUDIO_ENCODER,
+       _VROP_VIDEO_ENCODER,
+       _AROP_FILE_FORMAT,
+       _AROP_AUDIO_ENCODER,
+       _ROP_MAX
+};
+
+//
+// @enum _ResultType
+// This represents the retrieved item type for the capability.
+//
+enum _ResultType
+{
+       _RESULT_NONE = 0,
+       _RESULT_INTEGER,
+       _RESULT_DIMENSION,
+       _RESULT_INTEGER_LIST,
+       _RESULT_PAIR_INTEGER_LIST,
+       _RESULT_DIMENSION_LIST,
+       _RESULT_DOUBLE_LIST,
+       _RESULT_STRING_LIST,
+};
+
+//
+// @enum _QueryType
+// This represents the query type for the capability.
+//
+enum _QueryType
+{
+       _QUERY_NONE = 0,
+       _QUERY_LIST,
+       _QUERY_DEFAULT_VALUE = 0x20,
+       _QUERY_MAX,
+};
+
+/**
+* @class       _MediaSafeArrayList
+* @brief       This class is for handling safe list.
+*
+*/
+class _MediaSafeArrayList
+       : public Tizen::Base::Collection::ArrayList
+       , public virtual Tizen::Base::Collection::ICollection
+{
+public:
+       _MediaSafeArrayList(void);
+       virtual ~_MediaSafeArrayList(void);
+       void RemoveItems(void);
+       result AddPtr (std::unique_ptr<Tizen::Base::Object> pPtr);
+
+private:
+       _MediaSafeArrayList(const _MediaSafeArrayList& rhs);
+       _MediaSafeArrayList& operator =(const _MediaSafeArrayList& rhs);
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_CodecFactory.cpp b/src/FMedia_CodecFactory.cpp
new file mode 100644 (file)
index 0000000..81b6782
--- /dev/null
@@ -0,0 +1,337 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <cstdlib>
+#include <new>
+#include <pthread.h>
+#include <stdio.h>
+#include <unique_ptr.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMapT.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include <FMedia_CodecFactory.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_CodecFactory* _CodecFactory::__pTheInstance = null;
+
+void
+_CodecFactory::InitSingleton(void)
+{
+       std::unique_ptr<_CodecFactory> pInst(new (std::nothrow) _CodecFactory());
+
+       SysTryReturnVoidResult(NID_MEDIA, pInst, E_OUT_OF_MEMORY,
+                                                  "[%s] Memory allocation failed.",
+                                                  GetErrorMessage(E_OUT_OF_MEMORY));
+
+       result r = pInst->Construct();
+       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r,
+                                                  "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pInst->RegisterAllCodec();
+       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r,
+                                                  "[%s] _CodecFactory:RegisterAllCodec", GetErrorMessage(r));
+
+       __pTheInstance  = pInst.release();
+       std::atexit(DestroySingleton);
+}
+
+void
+_CodecFactory::DestroySingleton(void)
+{
+       delete __pTheInstance;
+}
+
+_CodecFactory*
+_CodecFactory::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pTheInstance == null)
+       {
+               ClearLastResult();
+               pthread_once(&onceBlock, InitSingleton);
+               result r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+       return __pTheInstance;
+}
+
+_CodecFactory::_CodecFactory(void)
+{
+}
+
+
+_CodecFactory::~_CodecFactory(void)
+{
+}
+
+result
+_CodecFactory::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       r = __videoDecoderRegister.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Factory Hash Map Failed");
+       r = __videoEncoderRegister.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Factory Hash Map Failed");
+       r = __audioDecoderRegister.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Factory Hash Map Failed");
+       r = __audioEncoderRegister.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Factory Hash Map Failed");
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CodecFactory::CreateCodecInstance(CodecType codecType, _IVideoDecoder*& pVideoDecoder)
+{
+       result r = E_SUCCESS;
+       _VideoDecoderCreateFunc createFunc = null;
+
+       r = __videoDecoderRegister.GetValue(codecType, createFunc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS && createFunc != null,
+                          r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC,
+                          "[E_UNSUPPORTED_CODEC] CreateCodecInstance Failed ");
+
+       pVideoDecoder = createFunc();
+       SysTryCatch(NID_MEDIA, pVideoDecoder != null, r = GetLastResult(), GetLastResult(),
+                          "[%s] CreateCodecInstance Failed", GetErrorMessage(GetLastResult()));
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CodecFactory::CreateCodecInstance(CodecType codecType, _IVideoEncoder*& pVideoEncoder)
+{
+       result r = E_SUCCESS;
+       _VideoEncoderCreateFunc createFunc = null;
+
+       r = __videoEncoderRegister.GetValue(codecType, createFunc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS && createFunc != null,
+                          r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC,
+                          "[E_UNSUPPORTED_CODEC] CreateCodecInstance Failed ");
+
+       pVideoEncoder = createFunc();
+       SysTryCatch(NID_MEDIA, pVideoEncoder != null, r = GetLastResult(), GetLastResult(),
+                          "[%s] CreateCodecInstance Failed", GetErrorMessage(GetLastResult()));
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CodecFactory::CreateCodecInstance(CodecType codecType, _IAudioDecoder*& pAudioDecoder)
+{
+       result r = E_SUCCESS;
+       _AudioDecoderCreateFunc createFunc = null;
+
+       r = __audioDecoderRegister.GetValue(codecType, createFunc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS && createFunc != null,
+                          r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC,
+                          "[E_UNSUPPORTED_CODEC] CreateCodecInstance Failed ");
+
+       pAudioDecoder = createFunc();
+       SysTryCatch(NID_MEDIA, pAudioDecoder != null, r = GetLastResult(), GetLastResult(),
+                          "[%s] CreateCodecInstance", GetErrorMessage(GetLastResult()));
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CodecFactory::CreateCodecInstance(CodecType codecType, _IAudioEncoder*& pAudioEncoder)
+{
+       result r = E_SUCCESS;
+       _AudioEncoderCreateFunc createFunc = null;
+
+       r = __audioEncoderRegister.GetValue(codecType, createFunc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS && createFunc != null,
+                          r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC,
+                          "[E_UNSUPPORTED_CODEC] CreateCodecInstance Failed ");
+
+       pAudioEncoder = createFunc();
+       SysTryCatch(NID_MEDIA, pAudioEncoder != null, r = GetLastResult(), GetLastResult(),
+                          "[%s] CreateCodecInstance", GetErrorMessage(GetLastResult()));
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CodecFactory::RegisterCodecCreateFunc(CodecType codecType, _VideoDecoderCreateFunc createFunc)
+{
+       result r = E_SUCCESS;
+
+       r = __videoDecoderRegister.Add(codecType, createFunc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                          "Codec Registration Failed ");
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CodecFactory::RegisterCodecCreateFunc(CodecType codecType, _VideoEncoderCreateFunc createFunc)
+{
+       result r = E_SUCCESS;
+
+       r = __videoEncoderRegister.Add(codecType, createFunc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                          "Codec Registration Failed ");
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CodecFactory::RegisterCodecCreateFunc(CodecType codecType, _AudioDecoderCreateFunc createFunc)
+{
+       result r = E_SUCCESS;
+
+       r = __audioDecoderRegister.Add(codecType, createFunc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                          "Codec Registration Failed ");
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_CodecFactory::RegisterCodecCreateFunc(CodecType codecType, _AudioEncoderCreateFunc createFunc)
+{
+       result r = E_SUCCESS;
+
+       r = __audioEncoderRegister.Add(codecType, createFunc);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                          "Codec Registration Failed ");
+       return r;
+
+CATCH:
+       return r;
+}
+
+
+extern _IAudioDecoder* _AacDecoder_CreateInstance();
+extern _IAudioDecoder* _Mp3Decoder_CreateInstance();
+extern _IAudioDecoder* _AmrDecoder_CreateInstance();
+extern _IAudioDecoder* _VorbisDecoder_CreateInstance();
+extern _IAudioDecoder* _AlawDecoder_CreateInstance();
+extern _IAudioDecoder* _UlawDecoder_CreateInstance();
+
+extern _IAudioEncoder* _AmrEncoder_CreateInstance();
+extern _IAudioEncoder* _AacEncoder_CreateInstance();
+
+extern _IVideoDecoder* _H263Decoder_CreateInstance();
+extern _IVideoDecoder* _H264Decoder_CreateInstance();
+extern _IVideoDecoder* _Mpeg4Decoder_CreateInstance();
+
+extern _IVideoEncoder* _H263Encoder_CreateInstance();
+extern _IVideoEncoder* _Mpeg4Encoder_CreateInstance();
+
+result
+_CodecFactory::RegisterAllCodec(void)
+{
+       result r = E_SUCCESS;
+
+       __videoDecoderRegister.Add(CODEC_H264, _H264Decoder_CreateInstance);
+       __videoDecoderRegister.Add(CODEC_H263, _H263Decoder_CreateInstance);
+       __videoDecoderRegister.Add(CODEC_MPEG4, _Mpeg4Decoder_CreateInstance);
+
+       __videoEncoderRegister.Add(CODEC_H263, _H263Encoder_CreateInstance);
+       __videoEncoderRegister.Add(CODEC_MPEG4, _Mpeg4Encoder_CreateInstance);
+
+       __audioDecoderRegister.Add(CODEC_AAC, _AacDecoder_CreateInstance);
+       __audioDecoderRegister.Add(CODEC_MP3, _Mp3Decoder_CreateInstance);
+       __audioDecoderRegister.Add(CODEC_AMR_NB, _AmrDecoder_CreateInstance);
+       __audioDecoderRegister.Add(CODEC_VORBIS, _VorbisDecoder_CreateInstance);
+       __audioDecoderRegister.Add(CODEC_ALAW, _AlawDecoder_CreateInstance);
+       __audioDecoderRegister.Add(CODEC_ULAW, _UlawDecoder_CreateInstance);
+
+       __audioEncoderRegister.Add(CODEC_AAC, _AacEncoder_CreateInstance);
+       __audioEncoderRegister.Add(CODEC_AMR_NB, _AmrEncoder_CreateInstance);
+
+       return r;
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+_CodecFactory::GetSupportedAudioDecoderListN(void)
+{
+       IListT<CodecType> *pList = null;
+
+       pList = __audioDecoderRegister.GetKeysN();
+       SysTryReturn(NID_MEDIA, pList != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Propagated.", GetErrorMessage(GetLastResult()));
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+_CodecFactory::GetSupportedAudioEncoderListN(void)
+{
+       IListT<CodecType> *pList = null;
+
+       pList = __audioEncoderRegister.GetKeysN();
+       SysTryReturn(NID_MEDIA, pList != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Propagated.", GetErrorMessage(GetLastResult()));
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+_CodecFactory::GetSupportedVideoDecoderListN(void)
+{
+       IListT<CodecType> *pList = null;
+
+       pList = __videoDecoderRegister.GetKeysN();
+       SysTryReturn(NID_MEDIA, pList != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Propagated.", GetErrorMessage(GetLastResult()));
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+_CodecFactory::GetSupportedVideoEncoderListN(void)
+{
+       IListT<CodecType> *pList = __videoEncoderRegister.GetKeysN();
+
+       SysTryReturn(NID_MEDIA, pList != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Propagated.", GetErrorMessage(GetLastResult()));
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_CodecFactory.h b/src/FMedia_CodecFactory.h
new file mode 100644 (file)
index 0000000..68251a1
--- /dev/null
@@ -0,0 +1,221 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_CodecFactory.h
+ *  @brief  This is the header file for the _CodecFactory.
+ *
+ *  This header file contains the declarations of the _CodecFactory.
+ */
+
+#ifndef _FMEDIA_INTERNAL_CODECFACTORY_H_
+#define _FMEDIA_INTERNAL_CODECFACTORY_H_
+
+#include <unique_ptr.h>
+
+namespace Tizen { namespace Media
+{
+
+class _IVideoDecoder;
+class _IVideoEncoder;
+class _IAudioDecoder;
+class _IAudioEncoder;
+
+typedef _IVideoDecoder* (*_VideoDecoderCreateFunc)(void);
+typedef _IVideoEncoder* (*_VideoEncoderCreateFunc)(void);
+typedef _IAudioDecoder* (*_AudioDecoderCreateFunc)(void);
+typedef _IAudioEncoder* (*_AudioEncoderCreateFunc)(void);
+
+/**
+ * @class  __CodecFactory
+ * @brief  This class is used to create audio or video codec instance.
+ *
+ * This class contains list of __CodecCreator and create codec instance with Codec's request.
+ *
+ */
+class _CodecFactory
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * Get the global instance of this class.
+        *
+        * @return Global instance of this class.
+        */
+       static _CodecFactory* GetInstance(void);
+
+       /**
+        * Create an instance of Codec with given type.
+        *
+        * @return E_SUCCESS on success, an error code on failure
+        *
+        * @param[in]   codecType               The codec type that want to create
+        * @param[Out]  pVideoDecoder   Reference to the _IVideoDecoder instance
+        *
+        * @exception   E_SUCCESS               This method was successful.
+        * @exception   E_INVALID_ARG   One of input parameter is invalid
+        * @exception   E_SYSTEM                A system error occurred.
+        */
+       result CreateCodecInstance(CodecType codecType, _IVideoDecoder*& pVideoDecoder);
+
+       /**
+        * Create an instance of Codec with given type.
+        *
+        * @return E_SUCCESS on success, an error code on failure
+        *
+        * @param[in]   codecType               The codec type that want to create
+        * @param[Out]  pVideoEncoder   Reference to the _IVideoEncoder instance
+        *
+        * @exception   E_SUCCESS               This method was successful.
+        * @exception   E_INVALID_ARG   One of input parameter is invalid
+        * @exception   E_SYSTEM                A system error occurred.
+        */
+       result CreateCodecInstance(CodecType codecType, _IVideoEncoder*& pVideoEncoder);
+
+       /**
+        * Create an instance of Codec with given type.
+        *
+        * @return E_SUCCESS on success, an error code on failure
+        *
+        * @param[in]   codecType               The codec type that want to create
+        * @param[Out]  pAudioDecoder   Reference to the _IAudioDecoder instance
+        *
+        * @exception   E_SUCCESS               This method was successful.
+        * @exception   E_INVALID_ARG   One of input parameter is invalid
+        * @exception   E_SYSTEM                A system error occurred.
+        */
+       result CreateCodecInstance(CodecType codecType, _IAudioDecoder*& pAudioDecoder);
+
+       /**
+        * Create an instance of Codec with given type.
+        *
+        * @return E_SUCCESS on success, an error code on failure
+        *
+        * @param[in]   codecType               The codec type that want to create
+        * @param[Out]  pAudioEncoder   Reference to the _IAudioEncoder instance
+        *
+        * @exception   E_SUCCESS               This method was successful.
+        * @exception   E_INVALID_ARG   One of input parameter is invalid
+        * @exception   E_SYSTEM                A system error occurred.
+        */
+       result CreateCodecInstance(CodecType codecType, _IAudioEncoder*& pAudioEncoder);
+
+
+       /**
+        * Registers the _IVideoDecoder CreateInstance function.
+        *
+        * @return E_SUCCESS on success, an error code on failure
+        *
+        * @param[in]   codecType               The codec type that want to create
+        * @param[in]   createFunc              The reference to the video encoder  create instance is returned
+        *
+        * @exception   E_SUCCESS               This method was successful.
+        * @exception   E_INVALID_ARG   One of input parameter is invalid
+        * @exception   E_SYSTEM                A system error occurred.
+        */
+       result RegisterCodecCreateFunc(CodecType codecType, _VideoDecoderCreateFunc createFunc);
+
+
+       /**
+        * Retrieves the _IVideoEncoder CreateInstance function.
+        *
+        * @return E_SUCCESS on success, an error code on failure
+        *
+        * @param[in]  codecType                The codec type that want to create
+        * @param[in]  createFunc               The reference to the video encoder  create instance is returned
+        *
+        * @exception  E_SUCCESS                This method was successful.
+        * @exception  E_INVALID_ARG    One of input parameter is invalid
+        * @exception  E_SYSTEM         A system error occurred.
+        */
+       result RegisterCodecCreateFunc(CodecType codecType, _VideoEncoderCreateFunc createFunc);
+
+       /**
+        * Retrieves the _IAudioDecoder CreateInstance function.
+        *
+        * @return E_SUCCESS on success, an error code on failure
+        *
+        * @param[in]   codecType               The codec type that want to create
+        * @param[in]   createFunc              The reference to the audio decoder create instance is returned
+        *
+        * @exception   E_SUCCESS               This method was successful.
+        * @exception   E_INVALID_ARG   One of input parameter is invalid
+        * @exception   E_SYSTEM                A system error occurred.
+        */
+       result RegisterCodecCreateFunc(CodecType codecType, _AudioDecoderCreateFunc createFunc);
+
+       /**
+        * Retrieves the _IAudioEncoder CreateInstance function.
+        *
+        * @return E_SUCCESS on success, an error code on failure
+        *
+        * @param[in]   codecType               The codec type that want to create
+        * @param[in]   createFunc              The reference to the audio encoder create instance is returned
+        *
+        * @exception   E_SUCCESS               This method was successful.
+        * @exception   E_INVALID_ARG   One of input parameter is invalid
+        * @exception   E_SYSTEM                A system error occurred.
+        */
+       result RegisterCodecCreateFunc(CodecType codecType, _AudioEncoderCreateFunc createFunc);
+
+       /**
+        * Registers all availiable codec
+        */
+       result RegisterAllCodec(void);
+
+       /**
+        * Gets supported audio decoder list
+        */
+       Tizen::Base::Collection::IListT<CodecType>* GetSupportedAudioDecoderListN(void);
+
+       /**
+        * Gets supported audio encoder list
+        */
+       Tizen::Base::Collection::IListT<CodecType>* GetSupportedAudioEncoderListN(void);
+
+       /**
+        * Gets supported video decoder list
+        */
+       Tizen::Base::Collection::IListT<CodecType>* GetSupportedVideoDecoderListN(void);
+
+       /**
+        * Gets supported video encoder list
+        */
+       Tizen::Base::Collection::IListT<CodecType>* GetSupportedVideoEncoderListN(void);
+
+protected:
+       // This constructs the hash maps.
+       result Construct(void);
+
+private:
+       _CodecFactory(void);
+       virtual ~_CodecFactory(void);
+
+       static void InitSingleton(void);
+       static void DestroySingleton(void);
+
+       static _CodecFactory* __pTheInstance;
+       friend struct std::default_delete<_CodecFactory>;
+       Tizen::Base::Collection::HashMapT<CodecType, _VideoDecoderCreateFunc> __videoDecoderRegister;
+       Tizen::Base::Collection::HashMapT<CodecType, _VideoEncoderCreateFunc> __videoEncoderRegister;
+       Tizen::Base::Collection::HashMapT<CodecType, _AudioDecoderCreateFunc> __audioDecoderRegister;
+       Tizen::Base::Collection::HashMapT<CodecType, _AudioEncoderCreateFunc> __audioEncoderRegister;
+};
+
+}} // Tizen::Media
+
+#endif // _FMEDIA_INTERNAL_CODECFACTORY_H_
diff --git a/src/FMedia_FfmpegUtil.cpp b/src/FMedia_FfmpegUtil.cpp
new file mode 100644 (file)
index 0000000..ec27c0e
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMedia_FfmpegUtil.cpp
+ * @brief  This is the implementation file for the FMedia::_FfmpegUtil.
+ *
+ * This file contains the implementations of the FMedia::_FfmpegUtil.
+ *
+ */
+#include <FBaseObject.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_FfmpegUtil.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+typedef struct
+{
+       CodecID codecId;
+       Tizen::Media::CodecType codecType;
+} _CodecTypeIdMap;
+
+static const _CodecTypeIdMap _CODEC_ID_MAP[] = {
+       { CODEC_ID_AAC, CODEC_AAC},
+       { CODEC_ID_MP3, CODEC_MP3},
+       { CODEC_ID_AMR_NB, CODEC_AMR_NB},
+       { CODEC_ID_H264, CODEC_H264},
+       { CODEC_ID_H263, CODEC_H263},
+       { CODEC_ID_MPEG4, CODEC_MPEG4}
+};
+
+typedef struct
+{
+       AVSampleFormat avSampleFormat;
+       Tizen::Media::AudioSampleType audioSampleType;
+} _SampleFormatMap;
+
+static const _SampleFormatMap _SAMPLE_FORMAT_MAP[] = {
+       { AV_SAMPLE_FMT_U8, AUDIO_TYPE_PCM_U8},
+       { AV_SAMPLE_FMT_S16, AUDIO_TYPE_PCM_S16_LE}
+};
+
+Tizen::Media::CodecType
+_FfmpegUtil::ToCodecType(CodecID codecId)
+{
+       for (unsigned int i = 0; i < sizeof(_CODEC_ID_MAP)/sizeof(_CODEC_ID_MAP[0]); i++)
+       {
+               if (codecId == _CODEC_ID_MAP[i].codecId)
+               {
+                       return _CODEC_ID_MAP[i].codecType;
+               }
+       }
+       return CODEC_UNKNOWN;
+}
+
+CodecID
+_FfmpegUtil::ToCodecID(Tizen::Media::CodecType codecType)
+{
+       for (unsigned int i = 0; i < sizeof(_CODEC_ID_MAP)/sizeof(_CODEC_ID_MAP[0]); i++)
+       {
+               if (codecType == _CODEC_ID_MAP[i].codecType)
+               {
+                       return _CODEC_ID_MAP[i].codecId;
+               }
+       }
+       return CODEC_ID_NONE;
+}
+
+AudioChannelType
+_FfmpegUtil::ToAudioChannelType(int channels)
+{
+       AudioChannelType channelType = AUDIO_CHANNEL_TYPE_NONE;
+
+       switch (channels)
+       {
+       case 1:
+               channelType = AUDIO_CHANNEL_TYPE_MONO;
+       break;
+
+       case 2:
+               channelType = AUDIO_CHANNEL_TYPE_STEREO;
+       break;
+
+       default:
+               break;
+       }
+
+       return channelType;
+}
+
+AudioSampleType
+_FfmpegUtil::ToAudioSampleType(AVSampleFormat sampleFormat)
+{
+       for (unsigned int i = 0; i < sizeof(_SAMPLE_FORMAT_MAP)/sizeof(_SAMPLE_FORMAT_MAP[0]); i++)
+       {
+               if (sampleFormat == _SAMPLE_FORMAT_MAP[i].avSampleFormat)
+               {
+                       return _SAMPLE_FORMAT_MAP[i].audioSampleType;
+               }
+       }
+       return AUDIO_TYPE_NONE;
+}
+
+AVSampleFormat
+_FfmpegUtil::ToAvSampleFormat(AudioSampleType sampleType)
+{
+       for (unsigned int i = 0; i < sizeof(_SAMPLE_FORMAT_MAP)/sizeof(_SAMPLE_FORMAT_MAP[0]); i++)
+       {
+               if (sampleType == _SAMPLE_FORMAT_MAP[i].audioSampleType)
+               {
+                       return _SAMPLE_FORMAT_MAP[i].avSampleFormat;
+               }
+       }
+       return AV_SAMPLE_FMT_NONE;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_H263Decoder.cpp b/src/FMedia_H263Decoder.cpp
new file mode 100644 (file)
index 0000000..9c03b5c
--- /dev/null
@@ -0,0 +1,430 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <stdio.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FMediaTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_IVideoDecoder.h"
+#include "FMedia_H263Decoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_IVideoDecoder*
+_H263Decoder_CreateInstance(void)
+{
+       return new (std::nothrow) _H263Decoder();
+}
+
+_H263Decoder::_H263Decoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __isDecodeCalled = false;
+}
+
+_H263Decoder::~_H263Decoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_flush_buffers(__pCodecCtx);
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+}
+
+result
+_H263Decoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+
+       SysAssertf((__pCodecCtx == null && __pCodec == null), " Already Constructed .");\r
+
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                           "[%s] AVCODEC Context Allcoation Failed",GetErrorMessage(E_SYSTEM));\r
+       __pCodec = avcodec_find_decoder(CODEC_ID_H263);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Find Decoder Failed for CODEC_ID_H263",GetErrorMessage(E_SYSTEM));\r
+\r
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                           "[%s] AVCODEC Codec Open Failed for CODEC_ID_H263",GetErrorMessage(E_SYSTEM));\r
+
+       // AVCodecContext parameters
+       if (__pCodec->capabilities & CODEC_CAP_TRUNCATED)
+       {
+               __pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+       }
+
+       __pCodecCtx->debug_mv = 0; //set by user
+       __pCodecCtx->debug = 0; //set by user
+       __pCodecCtx->workaround_bugs = 1; //set by user
+       __pCodecCtx->lowres = 0; //set by user
+       __pCodecCtx->skip_frame = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_idct = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_loop_filter = AVDISCARD_DEFAULT; //set by user
+
+       return r;
+
+CATCH:
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       return r;
+}
+
+result
+_H263Decoder::Decode(const byte* pSrcBuf, int& srcBufLength,
+                                        byte*& pDstBuf, int& dstBufLength, bool& gotFrame)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVFrame* pVideoFrame = null;
+       AVPacket inputPacket;
+       int gotPicture = 0;
+       int remainingBytes = 0;
+       int srcOffset = 0;
+       int i = 0;
+       int offset = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "The instance is in invalid state");\r
+       SysTryReturnResult(NID_MEDIA, (pSrcBuf != null && pDstBuf != null && srcBufLength > 0 && dstBufLength > 0),
+                                          E_INVALID_ARG, "Invalid argument is used. The argument is not valid");\r
+
+       av_init_packet(&inputPacket);
+       inputPacket.size = srcBufLength;
+       pVideoFrame = avcodec_alloc_frame();
+       SysTryCatch(NID_MEDIA, pVideoFrame != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+
+       inputPacket.data = (uint8_t*) pSrcBuf;
+       // Decoding the video packet
+       remainingBytes = srcBufLength;
+
+       do
+       {
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                                  "[%s] The input data format is not supported ", GetErrorMessage(E_UNSUPPORTED_FORMAT));\r
+
+               remainingBytes -= res;
+               inputPacket.data += res;
+               inputPacket.size -= res;
+
+               if (gotPicture)
+               {
+                       __isDecodeCalled = true;
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P) // handling only  yuv 420 case
+                       {
+                               SysTryCatch(NID_MEDIA, dstBufLength >= (__pCodecCtx->height*__pCodecCtx->width*3)/2,
+                                                  r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                                  "[%s] pDstBuf:%d %d %d",GetErrorMessage(E_OUT_OF_MEMORY),\r
+                                                  dstBufLength, __pCodecCtx->height, __pCodecCtx->width);
+                               for (i = 0; i < __pCodecCtx->height; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[0];
+                                       offset = i * __pCodecCtx->width;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[0] + srcOffset, __pCodecCtx->width);
+                               }
+                               for (i = 0; i < __pCodecCtx->height / 2; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[1];
+                                       offset = (__pCodecCtx->height * __pCodecCtx->width) + (i * __pCodecCtx->width) / 2;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[1] + srcOffset, __pCodecCtx->width / 2);
+                               }
+                               for (i = 0; i < __pCodecCtx->height / 2; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[2];
+                                       offset = ((__pCodecCtx->height * __pCodecCtx->width * 5) / 4) + (i * __pCodecCtx->width) / 2;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[2] + srcOffset, __pCodecCtx->width / 2);
+                               }
+                               gotFrame = true;
+                               srcBufLength = srcBufLength - remainingBytes;  //Input bytes used
+                               dstBufLength = (__pCodecCtx->height * __pCodecCtx->width * 3) / 2;
+                       }
+                       break;
+               }
+       }
+       while (remainingBytes);
+
+       if (!gotPicture)
+       {
+               // "Trying for another decode"
+               inputPacket.data = null;
+               inputPacket.size = 0;
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               if (gotPicture)
+               {
+                       // "Got Frame."
+                       __isDecodeCalled = true;
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P ) // handling only  yuv 420 case
+                       {
+                               SysTryCatch(NID_MEDIA, dstBufLength >= (__pCodecCtx->height*__pCodecCtx->width*3)/2,
+                                                  r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                                   "[%s] Decode Failed Insufficient destination buffer",GetErrorMessage(E_OUT_OF_MEMORY));                             \r
+                               for (i = 0; i < __pCodecCtx->height; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[0];
+                                       offset = i * __pCodecCtx->width;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[0] + srcOffset, __pCodecCtx->width);
+                               }
+                               for (i = 0; i < __pCodecCtx->height / 2; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[1];
+                                       offset = (__pCodecCtx->height * __pCodecCtx->width) + (i * __pCodecCtx->width) / 2;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[1] + srcOffset, __pCodecCtx->width / 2);
+                               }
+                               for (i = 0; i < __pCodecCtx->height / 2; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[2];
+                                       offset = ((__pCodecCtx->height * __pCodecCtx->width * 5) / 4) + (i * __pCodecCtx->width) / 2;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[2] + srcOffset, __pCodecCtx->width / 2);
+                               }
+                               gotFrame = true;
+                               srcBufLength = srcBufLength - remainingBytes;  //Input bytes used
+                               dstBufLength = (__pCodecCtx->height * __pCodecCtx->width * 3) / 2;
+                       }
+               }
+               else
+               {
+                       // "No Frame."
+                       srcBufLength = srcBufLength - remainingBytes;  //Input bytes used
+                       gotFrame = false;
+               }
+       }
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+
+CATCH:
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+
+       SysLog(NID_MEDIA, "Error is %d.", res);
+       return r;
+}
+
+result
+_H263Decoder::Probe(const byte* pSrcBuf, const int srcBufLength, int& width, int& height,
+                                       MediaPixelFormat& pixelFormat)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVFrame* pVideoFrame = null;
+       AVPacket inputPacket;
+       int gotPicture = 0;
+       int remainingBytes = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "The instance is in invalid state");\r
+       SysTryReturnResult(NID_MEDIA, (pSrcBuf != null && srcBufLength > 0), E_INVALID_ARG,
+                                          "Invalid argument is used. The argument is not valid");\r
+
+       av_init_packet(&inputPacket);
+       inputPacket.size = srcBufLength + FF_INPUT_BUFFER_PADDING_SIZE;
+       pVideoFrame = avcodec_alloc_frame();
+
+       SysTryCatch(NID_MEDIA, (pVideoFrame != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+       inputPacket.data = (uint8_t*) pSrcBuf;
+
+       // Decoding the video packet
+       remainingBytes = inputPacket.size;
+
+       do
+       {
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                                  "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+
+               if (gotPicture)
+               {
+                       // "Got Frame."
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P) // handling only  yuv 420 case
+                       {
+                               width = __pCodecCtx->width;
+                               height = __pCodecCtx->height;
+                               pixelFormat = MEDIA_PIXEL_FORMAT_YUV420P;
+                       }
+                       break;
+               }
+
+               remainingBytes -= res;
+               inputPacket.data += res;
+               inputPacket.size -= res;
+       }
+       while (remainingBytes);
+
+       if (!gotPicture)
+       {
+               inputPacket.data = null;
+               inputPacket.size = 0;
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               if (gotPicture && res >= 0)
+               {
+                       //  "Got Frame."
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P) // handling only  yuv 420 case
+                       {
+                               width = __pCodecCtx->width;
+                               height = __pCodecCtx->height;
+                               pixelFormat = MEDIA_PIXEL_FORMAT_YUV420P;
+                       }
+               }
+               else
+               {
+                       r = E_UNSUPPORTED_FORMAT;
+               }
+       }
+
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+
+CATCH:
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+}
+
+result
+_H263Decoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "The instance is in invalid state");\r
+       avcodec_flush_buffers(__pCodecCtx);
+       __isDecodeCalled = false;
+
+       return r;
+}
+
+result
+_H263Decoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "The instance is in invalid state");\r
+       SysTryCatch(NID_MEDIA, __isDecodeCalled == true, r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH && type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));\r
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_VIDEO_WIDTH:
+               value = __pCodecCtx->width;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_HEIGHT:
+               value = __pCodecCtx->height;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT:
+               value = MEDIA_PIXEL_FORMAT_YUV420P;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+               break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_H263Decoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "Not constructed");
+       SysTryCatch(NID_MEDIA, __isDecodeCalled == true, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH || type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,  "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));\r
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_H263Decoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+
+       ArrayListT<MediaPropertyType>* pPropList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+       SysTryCatch(NID_MEDIA, pPropList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_WIDTH);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_HEIGHT);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT);
+       SetLastResult(r);
+       return pPropList;
+
+CATCH:
+       return null;
+}
+
+bool
+_H263Decoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+       ClearLastResult();
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "Not constructed");
+       SysTryCatch(NID_MEDIA, (type == MEDIA_PROPERTY_VIDEO_WIDTH || type == MEDIA_PROPERTY_VIDEO_HEIGHT
+                                                  || type == MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT),
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                         "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));\r
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_H263Decoder.h b/src/FMedia_H263Decoder.h
new file mode 100644 (file)
index 0000000..18a1afe
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_H263Decoder.h
+ *  @brief  This is the header file for the _H263Decoder.
+ *
+ *  This header file contains the declarations of the _H263Decoder.
+ */
+#ifndef FMEDIA_INTERNAL_H263DECODER_H_
+#define FMEDIA_INTERNAL_H263DECODER_H_
+
+namespace Tizen { namespace Media
+{
+
+class _H263Decoder
+       : public _IVideoDecoder
+{
+public:
+       _H263Decoder(void);
+
+       virtual ~_H263Decoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* pSrcBuf, const int srcBufLength, int& width, int& height, MediaPixelFormat& pixelFormat);
+
+       virtual result Decode(const byte* pSrcBuf, int& srcBufLength, byte*& pDstBuf, int& dstBufLength, bool& gotFrame);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+private:
+       _H263Decoder(const _H263Decoder&);
+
+       _H263Decoder& operator =(const _H263Decoder&);
+
+private:
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       bool __isDecodeCalled;
+};
+
+};
+};
+
+
+#endif // FMEDIA_INTERNAL_H263DECODER_H_
diff --git a/src/FMedia_H263Encoder.cpp b/src/FMedia_H263Encoder.cpp
new file mode 100644 (file)
index 0000000..e3789f3
--- /dev/null
@@ -0,0 +1,443 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <unique_ptr.h>
+#include <stdio.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FBaseInteger.h>
+#include <FMediaTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_IVideoEncoder.h"
+#include "FMedia_H263Encoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_IVideoEncoder*
+_H263Encoder_CreateInstance(void)
+{
+       return new (std::nothrow) _H263Encoder();
+}
+
+_H263Encoder::_H263Encoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __pFrame = null;
+       __firstFrame = true;
+}
+
+_H263Encoder::~_H263Encoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+
+       if (__pFrame != null)
+       {
+               av_free(__pFrame);
+       }
+}
+
+result
+_H263Encoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       Integer* pKey = null;
+       Integer* pValue = null;
+       int key = -1;
+       int value = -1;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx == null, E_INVALID_STATE, "already constructed");
+
+       //avcodec_init();
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] Failed to allocate avcodec context", GetErrorMessage(E_SYSTEM));
+       __pCodec = avcodec_find_encoder(CODEC_ID_H263P);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to get avcodec encoder",GetErrorMessage(E_SYSTEM));
+
+       __pCodecCtx->bit_rate = BITRATE_IN_BITS;
+       __pCodecCtx->width = WIDTH;
+       __pCodecCtx->height = HEIGHT;
+       __pCodecCtx->time_base.den = 15;
+       __pCodecCtx->time_base.num = 1;
+       __pCodecCtx->gop_size = GOP ;
+       __pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
+       __pCodecCtx->thread_count = 1;
+       __pCodecCtx->max_b_frames = 0;
+
+       __pCodecCtx->qmin = MIN_QP;
+       __pCodecCtx->qmax = MAX_QP;
+       __pCodecCtx->mpeg_quant = 0;
+       __pCodecCtx->profile = 0;
+       //__pCodecCtx->rtp_payload_size = 1024;
+       __pCodecCtx->mb_decision = FF_MB_DECISION_BITS;
+       if (pOption != null)
+       {
+       // The initialization values are given in the Hashmap
+       std::unique_ptr<IMapEnumerator> pMapEnum(pOption->GetMapEnumeratorN());
+       SysTryCatch(NID_MEDIA, pMapEnum.get() != null, r = E_SYSTEM, E_SYSTEM, "Propagating");
+
+       while (pMapEnum.get()->MoveNext() == E_SUCCESS)
+       {
+               pKey = dynamic_cast<Integer*> (pMapEnum.get()->GetKey());
+               pValue = dynamic_cast<Integer*> (pMapEnum.get()->GetValue());
+
+               if (pKey == null || pValue == null)
+               {
+                       continue;
+               }
+
+               key = pKey->ToInt();
+               value = pValue->ToInt();
+
+
+               switch (key)
+               {
+               case MEDIA_PROPERTY_VIDEO_WIDTH:
+                       SysTryCatch(NID_MEDIA, value > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: width %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->width = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_HEIGHT:
+                       SysTryCatch(NID_MEDIA, value > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: height %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->height = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_FRAME_RATE:
+                       SysTryCatch(NID_MEDIA, value > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: frameRate %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->time_base.den = value;
+                       __pCodecCtx->time_base.num = 1;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT:
+                       SysTryCatch(NID_MEDIA, value == MEDIA_PIXEL_FORMAT_YUV420P,
+                                          r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: pixelFormat %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_BIT_RATE:
+                       SysTryCatch(NID_MEDIA, value >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: bitRate %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->bit_rate = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_QUANTIZATION_MIN :
+                       SysTryCatch(NID_MEDIA, value >= MIN_QP && value <= MAX_QP,
+                                          r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used: quantization min %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->qmin = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_QUANTIZATION_MAX :
+                       SysTryCatch(NID_MEDIA, value >= MIN_QP && value <= MAX_QP,
+                                          r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used: quantization max %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->qmax = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_GOP_SIZE :
+                       SysTryCatch(NID_MEDIA, value  >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: gop size %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->gop_size = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_PROFILE:
+                       SysTryCatch(NID_MEDIA, value  == 0 || value == 3, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: video profile %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->profile = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_SLICE_SIZE_IN_BYTE:
+                       SysTryCatch(NID_MEDIA, value >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: slice size %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->rtp_payload_size = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_QUANTIZATION_PARAMETER :
+                       SysTryCatch(NID_MEDIA, value >= MIN_QP && value <= MAX_QP,
+                                          r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used: quantization max %d", GetErrorMessage(E_INVALID_ARG), value);
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_GOB_SIZE :
+               SysTryCatch(NID_MEDIA, value > 0 && value <= __pCodecCtx->height/16, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: gob size %d", GetErrorMessage(E_INVALID_ARG), value);
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_USE_AC_PREDICTION :
+               SysTryCatch(NID_MEDIA, value == 0 || value == 1, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: ac prediction setting  %d", GetErrorMessage(E_INVALID_ARG), value);
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_USE_HEADER_EXTENSION_CODE :
+               SysTryCatch(NID_MEDIA, value == 0 || value == 1, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: header extension code %d", GetErrorMessage(E_INVALID_ARG), value);
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_USE_FRAME_SKIP:
+               SysTryCatch(NID_MEDIA, value == 0 || value == 1, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: frame skip setting %d", GetErrorMessage(E_INVALID_ARG), value);
+                       break;
+
+               default:
+                       break;
+               }
+       }
+       }
+
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] avcodec open failed %d ", GetErrorMessage(E_SYSTEM), res);
+
+       __pFrame = avcodec_alloc_frame();
+       SysTryCatch(NID_MEDIA, __pFrame != null, r = E_SYSTEM, E_SYSTEM, "[%s] avcodec alloc frame failed", GetErrorMessage(E_SYSTEM));
+
+       for (int i = 0; i < 4; i++)
+       {
+               __pFrame->data[i] = null;
+               __pFrame->linesize[i] = 0;
+       }
+       __firstFrame = true;
+
+       return r;
+
+CATCH:
+
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       return r;
+}
+
+
+result
+_H263Encoder::Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       int outIndex = 0;
+       int minSrcBufLength = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       minSrcBufLength = __pCodecCtx->width * __pCodecCtx->height * 3 / 2;
+       SysTryCatch(NID_MEDIA, (srcBuf != null && dstBuf != null && srcBufLength >= minSrcBufLength
+                                                  && dstBufLength >= FF_MIN_BUFFER_SIZE),
+                          r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Invalid argument is used. 0x%x %d %d 0x%x %d %d",
+                          GetErrorMessage(E_INVALID_ARG), srcBuf, srcBufLength, minSrcBufLength, dstBuf, dstBufLength, FF_MIN_BUFFER_SIZE);
+
+       __pFrame->data[0] = (uint8_t*)srcBuf;
+       __pFrame->data[1] = (uint8_t*)srcBuf + __pCodecCtx->width * __pCodecCtx->height;
+       __pFrame->data[2] = (uint8_t*)srcBuf + __pCodecCtx->width * __pCodecCtx->height * 5 / 4;
+       __pFrame->linesize[0] = __pCodecCtx->width;
+       __pFrame->linesize[1] = __pCodecCtx->width / 2;
+       __pFrame->linesize[2] = __pCodecCtx->width / 2;
+
+       res = avcodec_encode_video(__pCodecCtx, (uint8_t*) dstBuf+outIndex, dstBufLength, __pFrame);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM, "[%s] H263 Video Encode Failed %d", GetErrorMessage(E_SYSTEM), res);
+       srcBufLength = minSrcBufLength;
+       dstBufLength = res + outIndex;
+
+CATCH:
+       return r;
+}
+
+
+result
+_H263Encoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       avcodec_flush_buffers(__pCodecCtx);
+       return r;
+}
+
+result
+_H263Encoder::SetValue(MediaPropertyType type, int value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, value >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Invalid argument is used. type:%d", GetErrorMessage(E_INVALID_ARG), type);
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Invalid argument is used. type:%d", GetErrorMessage(E_INVALID_ARG), type);
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH && type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object not found. type:%d", GetErrorMessage(E_OBJ_NOT_FOUND), type);
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_VIDEO_WIDTH:
+       SysTryCatch(NID_MEDIA, value <= MAX_WIDTH, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. type:%d", GetErrorMessage(E_INVALID_ARG), type);
+               __pCodecCtx->width = value;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_HEIGHT:
+       SysTryCatch(NID_MEDIA, value <= MAX_HEIGHT, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. type:%d", GetErrorMessage(E_INVALID_ARG), type);
+               __pCodecCtx->height = value;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT:
+               __pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_FRAME_RATE:
+               __pCodecCtx->time_base.den = 15;
+               __pCodecCtx->time_base.num = 1;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_BIT_RATE:
+               __pCodecCtx->bit_rate = value;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_QUANTIZATION_PARAMETER :
+               __pCodecCtx->mpeg_quant = value;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_QUANTIZATION_MIN :
+               __pCodecCtx->qmin = value;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_QUANTIZATION_MAX :
+               __pCodecCtx->qmax = value;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_GOP_SIZE :
+               __pCodecCtx->gop_size = value;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_SLICE_SIZE_IN_BYTE  :
+               __pCodecCtx->rtp_payload_size = value;
+               break ;
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_H263Encoder::SetValue(MediaPropertyType type, bool value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, type>0, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, value == 0 || value == 1, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH || type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] Object not found", GetErrorMessage(E_OBJ_NOT_FOUND));
+       switch (type)
+       {
+       case MEDIA_PROPERTY_VIDEO_FORCE_SKIP_FRAME:
+               __pCodecCtx->skip_frame = AVDISCARD_DEFAULT;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_FORCE_INTRA_CODING:
+               __pCodecCtx->skip_idct = AVDISCARD_DEFAULT;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_H263Encoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pPropList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pPropList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory allocation failed",GetErrorMessage(E_OUT_OF_MEMORY));
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_WIDTH);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_HEIGHT);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_FRAME_RATE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_BIT_RATE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_QUANTIZATION_PARAMETER);
+       pPropList->Add( MEDIA_PROPERTY_VIDEO_QUANTIZATION_MAX);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_QUANTIZATION_MIN);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_GOP_SIZE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_PROFILE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_USE_FRAME_SKIP);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_GOB_SIZE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_SLICE_SIZE_IN_BYTE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_FORCE_SKIP_FRAME);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_FORCE_INTRA_CODING);
+
+       SetLastResult(r);
+       return pPropList;
+
+CATCH:
+       return null;
+}
+
+bool
+_H263Encoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturn(NID_MEDIA, __pCodecCtx, false, E_INVALID_STATE, "[E_INVALID_STATE] not constructed");
+       SysTryCatch(NID_MEDIA, ( type == MEDIA_PROPERTY_VIDEO_WIDTH || type == MEDIA_PROPERTY_VIDEO_HEIGHT
+                                                       || type == MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT || type == MEDIA_PROPERTY_VIDEO_FRAME_RATE
+                       || type == MEDIA_PROPERTY_VIDEO_BIT_RATE || type == MEDIA_PROPERTY_VIDEO_QUANTIZATION_PARAMETER || type ==
+                       MEDIA_PROPERTY_VIDEO_QUANTIZATION_MIN || type == MEDIA_PROPERTY_VIDEO_QUANTIZATION_MAX || type == MEDIA_PROPERTY_VIDEO_GOP_SIZE || type ==
+                       MEDIA_PROPERTY_VIDEO_PROFILE || type ==  MEDIA_PROPERTY_VIDEO_USE_FRAME_SKIP || type ==  MEDIA_PROPERTY_VIDEO_GOB_SIZE || type ==
+                       MEDIA_PROPERTY_VIDEO_SLICE_SIZE_IN_BYTE || type ==  MEDIA_PROPERTY_VIDEO_FORCE_SKIP_FRAME || type ==  MEDIA_PROPERTY_VIDEO_FORCE_INTRA_CODING),
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] Object not found %d", GetErrorMessage(E_OBJ_NOT_FOUND), type);
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_H263Encoder.h b/src/FMedia_H263Encoder.h
new file mode 100644 (file)
index 0000000..bb534e9
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_H263EncoderFfmpeg.h
+ *  @brief  This is the header file for the Tizen::Media::FMediaIVideoEncoder.
+ *
+ *  This header file contains the declarations of the Tizen::Media::_H263EncoderFfmpeg.
+ */
+#ifndef FMEDIA_INTERNAL_H263ENCODER_H_
+#define FMEDIA_INTERNAL_H263ENCODER_H_
+
+namespace Tizen { namespace Media
+{
+
+class _H263Encoder
+       : public _IVideoEncoder
+{
+public:
+       _H263Encoder(void);
+
+       virtual ~_H263Encoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength);
+
+       virtual result Reset(void);
+
+       virtual result SetValue(MediaPropertyType key, int value);
+
+       virtual result SetValue(MediaPropertyType key, bool value);
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+private:
+       _H263Encoder(const _H263Encoder&);
+
+       _H263Encoder& operator =(const _H263Encoder&);
+
+private:
+       static const int INPUT_BUFFER_PADDING_SIZE = 8;
+       static const int HEIGHT = 288;
+       static const int WIDTH = 352;
+       static const int MAX_HEIGHT = 640;
+       static const int MAX_WIDTH = 480;
+       static const int MAX_FRAME_RATE = 30;
+       static const int Y_STRIDE = 640;
+       static const int UV_STRIDE = 320;
+       static const int QUANTISATION_PARAMETER = 30;
+       static const int GOP = 15;
+       static const int BITRATE_IN_BITS = 0;
+       static const int FRAME_RATE = 25;
+       static const int MIN_QP = 1;
+       static const int MAX_QP = 31;
+       static const int SET_PROPERTY_COUNT = 6;
+       static const int GET_PROPERTY_COUNT = 10;
+       static const int INTERNAL_BUFFER_COUNT = 0;
+
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       AVFrame* __pFrame;
+       bool __firstFrame;
+};
+
+};
+};
+#endif // FMEDIA_INTERNAL_H263ENCODER_H_
+
diff --git a/src/FMedia_H264Decoder.cpp b/src/FMedia_H264Decoder.cpp
new file mode 100644 (file)
index 0000000..fe74ab7
--- /dev/null
@@ -0,0 +1,557 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FBaseInteger.h>
+#include <FMediaTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_IVideoDecoder.h"
+#include "FMedia_H264Decoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+static const int _INPUT_BUFFER_PADDING_SIZE = 8;
+static const int _ERROR_STRING_LENGTH = 256;
+
+_IVideoDecoder*
+_H264Decoder_CreateInstance(void)
+{
+       return new (std::nothrow) _H264Decoder();
+}
+
+_H264Decoder::_H264Decoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __decodeCalled = false;
+       __pParser = null;
+       __inPacketMode = false;
+}
+
+_H264Decoder::~_H264Decoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_flush_buffers(__pCodecCtx);
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               av_parser_close(__pParser);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+}
+
+result
+_H264Decoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       IMapEnumerator* pMapEnum = null;
+       Integer* pKey = null;
+       Integer* pValue = null;
+       int key = -1;
+       int value = -1;
+
+       SysAssertf((__pCodecCtx == null && __pCodec == null), " Already Constructed .");\r
+
+       if (pOption)
+       {
+               // The initialization values are given in the Hashmap
+               pMapEnum = pOption->GetMapEnumeratorN();
+               if (pMapEnum != null)
+               {
+                       while (pMapEnum->MoveNext() == E_SUCCESS)
+                       {
+                               pKey = dynamic_cast<Integer*>(pMapEnum->GetKey());
+                               pValue = dynamic_cast<Integer*>(pMapEnum->GetValue());
+
+                               if (pKey && pValue)
+                               {
+                                       key = pKey->ToInt();
+                                       value = pValue->ToInt();
+                                       switch (key)
+                                       {
+                                       case MEDIA_PROPERTY_VIDEO_H264_USE_ANNEX_B:
+                                               SysTryCatch(NID_MEDIA, value == 0 || value == 1,
+                                                                  r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Invalid argument is used. The value is out of range", GetErrorMessage(E_OUT_OF_RANGE));\r
+                                               break;
+
+                                       default:
+                                               break;
+                                       }
+                               }
+
+                       }
+                       delete pMapEnum;
+                       pMapEnum = null;
+               }
+       }
+
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,  "[%s] AVCODEC Context Allcoation Failed", GetErrorMessage(E_SYSTEM));\r
+       __pCodec = avcodec_find_decoder(CODEC_ID_H264);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM, "[%s]  AVCODEC Find Decoder Failed for CODEC_ID_H264", GetErrorMessage(E_SYSTEM));\r
+
+       // AVCodecContext parameters
+       __pCodecCtx->debug_mv = 0; //set by user
+       __pCodecCtx->debug = 0; //set by user
+       __pCodecCtx->workaround_bugs = 1; //set by user
+       __pCodecCtx->lowres = 0; //set by user
+       __pCodecCtx->skip_frame = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_idct = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_loop_filter = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK ;
+       __pCodecCtx->idct_algo = FF_IDCT_H264;
+       __pCodecCtx->strict_std_compliance = FF_COMPLIANCE_NORMAL;
+
+       if (__pCodec->capabilities & CODEC_CAP_TRUNCATED)
+       {
+               __pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+       }
+
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Codec Open Failed for CODEC_ID_H264, \
+                          result of avcodec_open() = %d ",
+                          GetErrorMessage(E_SYSTEM), res);\r
+
+       __pParser = av_parser_init(CODEC_ID_H264);
+       SysTryCatch(NID_MEDIA, __pParser != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Construct Failed");
+
+       return r;
+
+CATCH:
+       if (pMapEnum != null)
+       {
+               delete pMapEnum;
+       }
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       return r;
+}
+
+result
+_H264Decoder::Decode(const byte* pSrcBuf, int& srcBufLength,
+                                        byte*& dstBuf, int& dstBufLength, bool& gotFrame)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVFrame* pVideoFrame = null;
+       AVPacket inputPacket;
+       int gotPicture = 0;
+       int remainingBytes = 0;
+       int srcOffset = 0;
+       int i = 0;
+       int offset = 0;
+       int dataRead = 0;
+       uint8_t* pOutPtr = null;
+       int outDataSize = 0;
+       int64_t pts = 0;
+       int64_t dts = 0;
+       int64_t pos = 0;
+       int parsingOffSet = 0;
+
+       // TODO: add srcBufUsed, dstBufUsed param
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "The instance is in invalid state");\r
+       SysTryReturnResult(NID_MEDIA, (pSrcBuf != null && dstBuf != null && srcBufLength > 0 && dstBufLength > 0),
+                                          E_INVALID_ARG, "Invalid argument is used. The argument is not valid");
+       av_init_packet(&inputPacket);
+
+       pVideoFrame = avcodec_alloc_frame();
+       SysTryCatch(NID_MEDIA, (pVideoFrame != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[E_SYSTEM] alloc frame failed");
+
+       remainingBytes = srcBufLength;
+
+       while (remainingBytes && __inPacketMode == false)
+       {
+               // Parsing the stream to extract the packets
+               dataRead = av_parser_parse2(__pParser, __pCodecCtx, &pOutPtr,
+                                                                       &outDataSize, (uint8_t*) (pSrcBuf + parsingOffSet),
+                                                                       remainingBytes, pts, dts, pos);
+
+               // Parsing offset needs to be updated to avoid infinite loop
+               remainingBytes -= dataRead;
+               parsingOffSet += dataRead;
+
+               if ( outDataSize == 0 || pOutPtr == null)
+               {
+                       continue; // it should not be in a block .
+               }
+
+               inputPacket.size = outDataSize;
+               inputPacket.data = (uint8_t*) pOutPtr;
+
+               // Decoding the video packet
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                  "[%s] The input data format is not supported \
+                                  result of avcodec_decode_video2 = %d",
+                                  GetErrorMessage(E_UNSUPPORTED_FORMAT), res);\r
+
+               if (gotPicture) // Parsing of H264 packets done and got picture
+               {
+                       // "Got Picture."
+                       if (res < srcBufLength)
+                       {
+                               srcBufLength = srcBufLength - remainingBytes ;  //Input bytes used
+                       }
+                       goto GOTDECODEDFRAME;
+               }
+
+       }
+
+       // The parser failed to read a frame from bit stream so changing decode mode to packet mode avoiding parsing
+       if ( __inPacketMode == false && (outDataSize == 0 || pOutPtr == null) && remainingBytes == 0)
+       {
+                       __inPacketMode = true;
+       }
+
+       if (__inPacketMode)
+       {
+               inputPacket.size = srcBufLength;
+               inputPacket.data = (uint8_t*) pSrcBuf;
+
+               SysLog(NID_MEDIA, "Before Decode. inputPacket.size :: %d  ", srcBufLength);
+               // Decoding the video packet
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                  "[%s] The input data format is not supported, \
+                                  result of avcodec_decode_video2() = %d", 
+                                  GetErrorMessage(E_UNSUPPORTED_FORMAT), res);\r
+               if (gotPicture)
+               {
+                       //  "Got Picture. "
+                       if (res <= srcBufLength)
+                       {
+                               srcBufLength = res;  //Input bytes used
+                       }
+                       goto GOTDECODEDFRAME;
+               }
+       }
+
+       if (!gotPicture)
+       {
+               SysLog(NID_MEDIA, "Trying Again. Giving Empty Buffer");
+               inputPacket.data = null;
+               inputPacket.size = 0;
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                  "[%s] The input data format is not supported \
+                                  result of avcodec_decode_video2() = %d",
+                                  GetErrorMessage(E_UNSUPPORTED_FORMAT), res);\r
+       }
+
+GOTDECODEDFRAME:
+
+       if (gotPicture)
+       {
+               __decodeCalled = true;
+               // "Got Picture. "
+               if ( __pCodecCtx->pix_fmt == PIX_FMT_YUV420P ) // handling only  yuv 420 case
+               {
+                       SysTryCatch(NID_MEDIA, dstBufLength >= (__pCodecCtx->height*__pCodecCtx->width*3)/2,
+                                          r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                          "[%s] Decode Failed Insufficient destination buffer", GetErrorMessage(E_OUT_OF_MEMORY));\r
+                       for (i = 0; i < __pCodecCtx->height; i++)
+                       {
+                               srcOffset = i * pVideoFrame->linesize[0];
+                               offset = i * __pCodecCtx->width;
+                               memcpy(dstBuf + offset, pVideoFrame->data[0] + srcOffset, __pCodecCtx->width);
+                       }
+                       for (i = 0; i < __pCodecCtx->height / 2; i++)
+                       {
+                               srcOffset = i * pVideoFrame->linesize[1];
+                               offset = (__pCodecCtx->height * __pCodecCtx->width) + (i * __pCodecCtx->width) / 2;
+                               memcpy(dstBuf + offset, pVideoFrame->data[1] + srcOffset, __pCodecCtx->width / 2);
+                       }
+                       for (i = 0; i < __pCodecCtx->height / 2; i++)
+                       {
+                               srcOffset = i * pVideoFrame->linesize[2];
+                               offset = ((__pCodecCtx->height*__pCodecCtx->width*5)/4)+(i*__pCodecCtx->width)/ 2;
+                               memcpy(dstBuf + offset, pVideoFrame->data[2] + srcOffset, __pCodecCtx->width / 2);
+                       }
+                       gotFrame = true;
+                       dstBufLength = (__pCodecCtx->height * __pCodecCtx->width * 3) / 2;
+               }
+       }
+       else
+       {
+               // "No Frame."
+               gotFrame = false;
+       }
+
+
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+
+CATCH:
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+}
+
+result
+_H264Decoder::Probe(const byte* pSrcBuf, const int srcBufLength,
+                                       int& width, int& height, MediaPixelFormat& pixelFormat)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVFrame* pVideoFrame = null;
+       AVPacket inputPacket;
+       uint8_t* pInputData = null;
+       int gotPicture = 0;
+       int remainingBytes = 0;
+       int dataRead = 0;
+       uint8_t *pOutPtr = null;
+       int outDataSize = 0;
+       int64_t pts = 0;
+       int64_t dts = 0;
+       int64_t pos = 0;
+       int parsingOffSet = 0;
+
+       // TODO: merge with Decode ?
+
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "The instance is in invalid state");\r
+       SysTryReturnResult(NID_MEDIA, (pSrcBuf != null && srcBufLength > 0), E_INVALID_ARG,
+                                         "pSrcBuf:0x%x %d", pSrcBuf, srcBufLength);
+
+       av_init_packet(&inputPacket);
+       inputPacket.size = srcBufLength + FF_INPUT_BUFFER_PADDING_SIZE;
+       pInputData = new (std::nothrow) byte[inputPacket.size + FF_INPUT_BUFFER_PADDING_SIZE];
+       pVideoFrame = avcodec_alloc_frame();
+       SysTryCatch(NID_MEDIA, (pInputData != null && pVideoFrame != null),
+                          r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[E_SYSTEM] Input buffer allocation  Failed");
+       memcpy(pInputData, pSrcBuf, srcBufLength);
+       memset(pInputData + srcBufLength, 0, _INPUT_BUFFER_PADDING_SIZE);
+       inputPacket.data = (uint8_t*) pInputData;
+
+       // Decoding the video packet
+       remainingBytes = inputPacket.size;
+
+       do
+       {
+               // Parsing the stream to extract the packets
+               dataRead = av_parser_parse2(__pParser, __pCodecCtx, &pOutPtr, &outDataSize, (uint8_t*) (pSrcBuf + parsingOffSet),
+                                                                       remainingBytes, pts, dts, pos);
+
+               // Parsing offset needs to be updated to avoid infinite loop
+               remainingBytes -= dataRead;
+               parsingOffSet += dataRead;
+
+               if ( outDataSize == 0 || pOutPtr == null)
+               {
+                       continue; // no block is required for this if statement.
+               }
+
+               inputPacket.size = outDataSize;
+               inputPacket.data = (uint8_t*) pOutPtr;
+
+               // Decoding the video packet
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                                  "[%s] Invalid argument is used. The argument is not valid, \
+                                  result of avcodec_decode_video2 = %d",
+                                  GetErrorMessage(E_INVALID_ARG), res);\r
+
+               if (gotPicture)
+               {
+                       // "Got Picture. "
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P) // handling only  yuv 420 case
+                       {
+                               width = __pCodecCtx->width;
+                               height = __pCodecCtx->height;
+                               pixelFormat = MEDIA_PIXEL_FORMAT_YUV420P;
+                       }
+                       break;
+               }
+
+               // All bytes of the frame are not consumed
+               if (dataRead > res)
+               {
+                       remainingBytes += dataRead - res;
+                       parsingOffSet -= dataRead - res;
+               }
+       }
+       while (remainingBytes);
+
+       if (!gotPicture)
+       {
+               inputPacket.data = null;
+               inputPacket.size = 0;
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+
+               if (gotPicture && res>= 0)
+               {
+                       // "Got Picture. "
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P) // handling only  yuv 420 case
+                       {
+                               width = __pCodecCtx->width;
+                               height = __pCodecCtx->height;
+                               pixelFormat = MEDIA_PIXEL_FORMAT_YUV420P;
+                       }
+               }
+               else
+               {
+                       r = E_UNSUPPORTED_FORMAT;
+                       // "No Frame. "
+               }
+       }
+
+       delete[] pInputData;
+       av_free(pVideoFrame);
+
+       return r;
+
+CATCH:
+       if (pInputData != null)
+       {
+               delete[] pInputData;
+       }
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+}
+
+result
+_H264Decoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "Not constructed");
+       avcodec_flush_buffers(__pCodecCtx);
+       __decodeCalled = false;
+       __inPacketMode = false;
+       return r;
+}
+
+result
+_H264Decoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "Not constructed");
+       SysTryCatch(NID_MEDIA, __decodeCalled == true, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state", GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, type>0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid", GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH && type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,  "[%s] The instance is not available ", GetErrorMessage(E_OBJ_NOT_FOUND));\r
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_VIDEO_WIDTH:
+               value = __pCodecCtx->width;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_HEIGHT:
+               value = __pCodecCtx->height;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT:
+               value = MEDIA_PIXEL_FORMAT_YUV420P;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_H264Decoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "Not constructed");
+       SysTryCatch(NID_MEDIA, __decodeCalled == true, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state", GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, type>0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] GetValue Failed");
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH && type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ", GetErrorMessage(E_OBJ_NOT_FOUND));\r
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_H264Decoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pPropList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pPropList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ", GetErrorMessage(E_OUT_OF_MEMORY));\r
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_WIDTH);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_HEIGHT);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT);
+       SetLastResult(r);
+       return pPropList;
+
+CATCH:
+       return null;
+}
+
+bool
+_H264Decoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "Not constructed");
+       SysTryCatch(NID_MEDIA, (type == MEDIA_PROPERTY_VIDEO_WIDTH || type == MEDIA_PROPERTY_VIDEO_HEIGHT
+                                                  || type == MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT ),
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                           "[%s] The instance is not available ", GetErrorMessage(E_OBJ_NOT_FOUND));\r
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_H264Decoder.h b/src/FMedia_H264Decoder.h
new file mode 100644 (file)
index 0000000..5bf2fd5
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_H264Decoder.h
+ *  @brief  This is the header file for the _H264Decoder.
+ *
+ *  This header file contains the declarations of the _H264Decoder.
+ */
+#ifndef FMEDIA_INTERNAL_H264DECODER_H_
+#define FMEDIA_INTERNAL_H264DECODER_H_
+
+
+namespace Tizen { namespace Media
+{
+
+class _H264Decoder
+       : public _IVideoDecoder
+{
+public:
+       _H264Decoder(void);
+
+       virtual ~_H264Decoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* pSrcBuf, const int srcBufLength, int& width, int& height, MediaPixelFormat& pixelFormat);
+
+       virtual result Decode(const byte* pSrcBuf, int& srcBufLength, byte*& pDstBuf, int& dstBufLength, bool& gotFrame);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+
+private:
+       _H264Decoder(const _H264Decoder&);
+
+       _H264Decoder& operator =(const _H264Decoder&);
+
+private:
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       bool __decodeCalled;
+       bool __inPacketMode;
+       AVCodecParserContext *__pParser;
+};
+
+};
+};
+
+
+#endif // FMEDIA_H264DECODERFFMPEG_H_
diff --git a/src/FMedia_IAudioDecoder.h b/src/FMedia_IAudioDecoder.h
new file mode 100644 (file)
index 0000000..19c6d63
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_IAudioDecoder.h
+ *  @brief  This is the header file for the _IAudioDecoder.h.
+ *
+ *  This header file contains the declarations of the Tizen::Media::_FMediaCodecFactory.
+ */
+#ifndef _FMEDIA_INTERNAL_IAUDIODECODER_H_
+#define _FMEDIA_INTERNAL_IAUDIODECODER_H_
+
+namespace Tizen { namespace Media
+{
+
+class _IAudioDecoder
+       : public Tizen::Base::Object
+{
+public:
+       virtual ~_IAudioDecoder(void) {};
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null) = 0;
+
+       virtual result Probe(const byte* srcBuf, const int length, AudioSampleType& sampleType,
+                                                AudioChannelType& channelType, int& sampleRate) = 0;
+
+       virtual result Decode(const byte* srcBuf, int srcBufSize, int &srcBufUsed,
+                                                 byte* dstBuf, int dstBufSize, int &dstBufUsed) = 0;
+
+       virtual result Reset(void) = 0;
+
+       virtual result GetValue(MediaPropertyType type, int& value) const = 0;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const = 0;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const = 0;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const = 0;
+
+};
+
+} }
+
+#endif //  _FMEDIA_INTERNAL_IAUDIODECODER_H_
diff --git a/src/FMedia_IAudioEncoder.h b/src/FMedia_IAudioEncoder.h
new file mode 100644 (file)
index 0000000..d81e24c
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_IAudioEncoder.h
+ *  @brief  This is the header file for the _IAudioEncoder.
+ *
+ *  This header file contains the declarations of the _IAudioEncoder.
+ */
+#ifndef FMEDIA_INTERNAL_IAUDIOENCODER_H_
+#define FMEDIA_INTERNAL_IAUDIOENCODER_H_
+
+namespace Tizen { namespace Media
+{
+
+class _IAudioEncoder
+       : public Tizen::Base::Object
+{
+public:
+       virtual ~_IAudioEncoder(void) {};
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null) = 0;
+
+       virtual result Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength) = 0;
+
+       virtual result Reset(void) = 0;
+};
+
+};
+};
+
+#endif // FMEDIA_INTERNAL_IAUDIOENCODER_H_
diff --git a/src/FMedia_ICameraCoordinatorListener.h b/src/FMedia_ICameraCoordinatorListener.h
new file mode 100755 (executable)
index 0000000..543ff67
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_ICameraCoordinatorListener.h
+ * @brief                      This is the header file for the %_ICameraCoordinatorListener interface.
+ *
+ * This header file contains the declarations of the %_ICameraCoordinatorListener interface.
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_COORDINATOR_LISTENER_H
+#define _FMEDIA_INTERNAL_CAMERA_COORDINATOR_LISTENER_H
+
+#include "FMedia_CameraTypes.h"
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @interface  _ICameraCoordinatorListener
+ * @brief              This interface provides a listener that receives callbacks associated with the %_CameraCoordinator class.
+ */
+class _ICameraCoordinatorListener
+{
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor@n
+       * of this interface is called.
+       *
+       */
+       virtual ~_ICameraCoordinatorListener(void) {}
+
+       /**
+       * Called when the mode is prepared to change.
+       *
+       * @return               An error code
+       * @param[in]     mode           camera mode
+       */
+       virtual result OnCameraCoordinatorModeChangePrepared(_CameraMode mode) = 0;
+
+       /**
+       * Called when the mode is changed.
+       *
+       * @return               An error code
+       * @param[in]     mode           camera mode
+       */
+       virtual result OnCameraCoordinatorModeChanged(_CameraMode mode) = 0;
+
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_ISessionManagerListener.h b/src/FMedia_ISessionManagerListener.h
new file mode 100644 (file)
index 0000000..7c2ac29
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef FMEDIA_INTERNAL_ISESSION_MANAGER_EVENT_H_
+#define FMEDIA_INTERNAL_ISESSION_MANAGER_EVENT_H_
+
+namespace Tizen { namespace Media
+{
+class _ISessionManagerListener
+{
+public:
+       virtual void OnSoundSessionInturrupted(void) = 0;
+       virtual void OnSoundSessionReleased(void) = 0;
+
+protected:
+       virtual ~_ISessionManagerListener(void) {}
+};
+
+}}
+
+#endif
diff --git a/src/FMedia_IVideoDecoder.h b/src/FMedia_IVideoDecoder.h
new file mode 100644 (file)
index 0000000..659456f
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_IVideoDecoder.h
+ *  @brief  This is the header file for the _IVideoDecoder.
+ *
+ *  This header file contains the declarations of the _IVideoDecoder.
+ */
+
+#ifndef FMEDIA_INTERNAL_IVIDEODECODER_H_
+#define FMEDIA_INTERNAL_IVIDEODECODER_H_
+
+
+namespace Tizen { namespace Media
+{
+
+class _IVideoDecoder
+       : public Tizen::Base::Object
+{
+public:
+       virtual ~_IVideoDecoder(void) {};
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null) = 0;
+
+       virtual result Probe(const byte* srcBuf, const int length, int& width, int& height, MediaPixelFormat& pixelFormat) = 0;
+
+       virtual result Decode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength, bool& gotFrame) = 0;
+
+       virtual result Reset(void) = 0;
+
+       virtual result GetValue(MediaPropertyType type, int& value) const = 0;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const = 0;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const = 0;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const = 0;
+};
+
+};
+};
+
+#endif // FMEDIA_INTERNAL_IVIDEODECODER_H_
diff --git a/src/FMedia_IVideoEncoder.h b/src/FMedia_IVideoEncoder.h
new file mode 100644 (file)
index 0000000..dffb678
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_IVideoEncoder.h
+ *  @brief  This is the header file for the _IVideoEncoder.
+ *
+ *  This header file contains the declarations of the Tizen::Media::_IVideoEncoder.
+ */
+
+#ifndef FMEDIA_INTERNAL_IVIDEOENCODER_H_
+#define FMEDIA_INTERNAL_IVIDEOENCODER_H_
+
+namespace Tizen { namespace Media
+{
+
+class _IVideoEncoder
+       : public Tizen::Base::Object
+{
+public:
+       virtual ~_IVideoEncoder(void) {};
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null) = 0;
+
+       virtual result Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength) = 0;
+
+       virtual result Reset(void) = 0;
+
+       virtual result SetValue(MediaPropertyType type, int value) = 0;
+
+       virtual result SetValue(MediaPropertyType type, bool value) = 0;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const = 0;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const = 0;
+};
+
+};
+};
+
+#endif // FMEDIA_IVIDEOENCODER_H_
diff --git a/src/FMedia_MediaStreamInfoImpl.cpp b/src/FMedia_MediaStreamInfoImpl.cpp
new file mode 100644 (file)
index 0000000..82a77c3
--- /dev/null
@@ -0,0 +1,347 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+#include "FMediaMediaStreamInfo.h"
+#include "FMedia_MediaStreamInfoImpl.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_MediaStreamInfoImpl::_MediaStreamInfoImpl(const Tizen::Base::String& title, const Tizen::Base::String& artist, const Tizen::Base::String& albumTitle, const Tizen::Base::String& genre, int year, Tizen::Base::ByteBuffer* pAlbumArt, Tizen::Base::Collection::IList* pAudioStream, Tizen::Base::Collection::IList* pVideoStream, result audioStreamException, result videoStreamException)
+{
+       __year = year;
+       __title = title;
+       __artist = artist;
+       __albumTitle = albumTitle;
+       __genre = genre;
+       __pAlbumArt = pAlbumArt;
+
+       __pAudioStreamList = pAudioStream;
+       __pVideoStreamList = pVideoStream;
+       __audioStreamListException = audioStreamException;
+       __videoStreamListException = videoStreamException;
+
+}
+
+_MediaStreamInfoImpl::~_MediaStreamInfoImpl()
+{
+       if (__pAudioStreamList != null)
+       {
+               __pAudioStreamList->RemoveAll(true);
+       }
+
+       if (__pVideoStreamList != null)
+       {
+               __pVideoStreamList->RemoveAll(true);
+       }
+       if (__pAlbumArt)
+       {
+               delete __pAlbumArt;
+               __pAlbumArt = null;
+       }
+
+}
+
+_MediaStreamInfoImpl::_MediaStreamInfoImpl(const _MediaStreamInfoImpl& rhs)
+{
+       __year = rhs.__year;
+       __title = rhs.__title;
+       __artist = rhs.__artist;
+       __albumTitle = rhs.__albumTitle;
+       __genre = rhs.__genre;
+
+       __audioStreamListException = rhs.__audioStreamListException;
+       __videoStreamListException = rhs.__videoStreamListException;
+       if (rhs.__pAlbumArt)
+       {
+               __pAlbumArt = new (std::nothrow) ByteBuffer;
+               __pAlbumArt->Construct(*rhs.__pAlbumArt);
+       }
+       else
+       {
+               __pAlbumArt = null;
+       }
+
+       if (rhs.__pAudioStreamList)
+       {
+               __pAudioStreamList = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+               if (__pAudioStreamList)
+               {
+                       for (int i = 0; i < rhs.__pAudioStreamList->GetCount() ; i++)
+                       {
+                               AudioStreamInfo *pAudioSteamInfo = null;
+                               AudioStreamInfo *pSrcInfo = dynamic_cast<AudioStreamInfo*>(rhs.__pAudioStreamList->GetAt(i));
+                                       if (pSrcInfo != null)
+                                       {
+                                               pAudioSteamInfo = new (std::nothrow) AudioStreamInfo(*pSrcInfo);
+                                                       if (pAudioSteamInfo != null)
+                                                       {
+                                                               __pAudioStreamList->Add(*pAudioSteamInfo);
+                                                       }
+                                       }
+                       }
+               }
+       }
+       else
+       {
+               __pAudioStreamList = null;
+       }
+
+       if (rhs.__pVideoStreamList )
+       {
+               __pVideoStreamList = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+               if (__pVideoStreamList)
+               {
+                       for (int i = 0; i < rhs.__pVideoStreamList->GetCount() ; i++)
+                       {
+                               VideoStreamInfo *pVideoSteamInfo = null;
+                               VideoStreamInfo *pSrcInfo = dynamic_cast<VideoStreamInfo*>(rhs.__pVideoStreamList->GetAt(i));
+                               if (pSrcInfo != null)
+                               {
+                                       pVideoSteamInfo = new (std::nothrow) VideoStreamInfo(*pSrcInfo);
+                                       if (pVideoSteamInfo != null)
+                                       {
+                                               __pVideoStreamList->Add(*pVideoSteamInfo);
+                                       }
+                               }
+                       }
+               }
+       }
+       else
+       {
+               __pVideoStreamList = null;
+       }
+}
+
+bool
+_MediaStreamInfoImpl::Equals(const Object& obj) const
+{
+       const _MediaStreamInfoImpl* pMediaStreaInfoImpl = dynamic_cast <const _MediaStreamInfoImpl *> (&obj);
+       if (this == pMediaStreaInfoImpl)
+       {
+               return true;
+       }
+       if (!pMediaStreaInfoImpl)
+       {
+               return false;
+       }
+       if (__year != pMediaStreaInfoImpl->__year)
+       {
+               return false;
+       }
+       if (!__title.Equals(pMediaStreaInfoImpl->__title))
+       {
+               return false;
+       }
+       if (!__artist.Equals( pMediaStreaInfoImpl->__artist))
+       {
+               return false;
+       }
+       if (!__albumTitle.Equals(pMediaStreaInfoImpl->__albumTitle))
+       {
+               return false;
+       }
+       if (!__genre.Equals(pMediaStreaInfoImpl->__genre))
+       {
+               return false;
+       }
+       if (__pAlbumArt)
+       {
+               if (pMediaStreaInfoImpl->__pAlbumArt)
+               {
+                       if (!__pAlbumArt->Equals( *pMediaStreaInfoImpl->__pAlbumArt))
+                       {
+                               return false;
+                       }
+               }
+               else
+               {
+                       return false;
+               }
+       }
+       else if (pMediaStreaInfoImpl->__pAlbumArt)
+       {
+               return false;
+       }
+       if (__pAudioStreamList)
+       {
+               if (pMediaStreaInfoImpl->__pAudioStreamList)
+               {
+                       if (__pAudioStreamList->GetCount() == pMediaStreaInfoImpl->__pAudioStreamList->GetCount())
+                       {
+                               for (int i = 0; i < __pAudioStreamList->GetCount() ; i++)
+                               {
+                                       if (!__pAudioStreamList->GetAt(i)->Equals(*pMediaStreaInfoImpl->__pAudioStreamList->GetAt(i)))
+                                       {
+                                               return false;
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+               else
+               {
+                       return false;
+               }
+       }
+       else if (pMediaStreaInfoImpl->__pAudioStreamList)
+       {
+               return false;
+       }
+       if (__pVideoStreamList)
+       {
+               if (pMediaStreaInfoImpl->__pVideoStreamList)
+               {
+                       if (__pVideoStreamList->GetCount() == pMediaStreaInfoImpl->__pVideoStreamList->GetCount())
+                       {
+                               for (int i = 0; i < __pVideoStreamList->GetCount() ; i++)
+                               {
+                                       if (!__pVideoStreamList->GetAt(i)->Equals(*pMediaStreaInfoImpl->__pVideoStreamList->GetAt(i)))
+                                       {
+                                               return false;
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+               else
+               {
+                       return false;
+               }
+       }
+       else if (pMediaStreaInfoImpl->__pVideoStreamList)
+       {
+               return false;
+       }
+       return true;
+
+}
+
+int
+_MediaStreamInfoImpl::GetHashCode(void) const
+{
+       int hashAlbumArt = 0;
+       int hashAudioStream = 0;
+       int hashVideoStream = 0;
+       int hashMediaItems = 0;
+
+       if (__pAlbumArt)
+       {
+               hashAlbumArt = __pAlbumArt->GetHashCode();
+       }
+
+       hashMediaItems = __year + __title.GetHashCode() + __albumTitle.GetHashCode() + __artist.GetHashCode() + __genre.GetHashCode();
+
+       if (__pAudioStreamList)
+       {
+               for (int i = 0; i < __pAudioStreamList->GetCount(); i++ )
+               {
+                       hashAudioStream = ((hashAudioStream) + (__pAudioStreamList->GetAt(i)->GetHashCode()));
+               }
+       }
+
+       if (__pVideoStreamList)
+       {
+               for (int i = 0; i < __pVideoStreamList->GetCount(); i++ )
+               {
+                       hashVideoStream = ((hashVideoStream) + (__pVideoStreamList->GetAt(i)->GetHashCode()));
+               }
+       }
+
+       return (hashAlbumArt + hashAudioStream + hashVideoStream + hashMediaItems);
+}
+
+String
+_MediaStreamInfoImpl::GetTitle() const
+{
+       return __title;
+}
+
+String
+_MediaStreamInfoImpl::GetArtist(void) const
+{
+       return __artist;
+}
+
+String
+_MediaStreamInfoImpl::GetAlbumTitle(void) const
+{
+       return __albumTitle;
+}
+
+int
+_MediaStreamInfoImpl::GetYear(void) const
+{
+       return __year;
+}
+
+String
+_MediaStreamInfoImpl::GetGenre(void) const
+{
+       return __genre;
+}
+
+ByteBuffer*
+_MediaStreamInfoImpl::GetAlbumArtN(void) const
+{
+       ByteBuffer *pByteBuffer = null;
+       result r = E_SUCCESS;
+       if (__pAlbumArt)
+       {
+
+               pByteBuffer = new (std::nothrow) ByteBuffer;
+               SysTryReturn(NID_MEDIA, pByteBuffer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               r = pByteBuffer->Construct(*__pAlbumArt);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] propagating", GetErrorMessage(r));
+               return pByteBuffer;
+       }
+       return null;
+CATCH:
+
+       delete pByteBuffer;
+       pByteBuffer = null;
+
+       return null;
+}
+
+const IList*
+_MediaStreamInfoImpl::GetAudioStreamInfoList() const
+{
+       SetLastResult(__audioStreamListException);
+       return __pAudioStreamList;
+}
+
+const IList*
+_MediaStreamInfoImpl::GetVideoStreamInfoList() const
+{
+       SetLastResult(__videoStreamListException);
+       return __pVideoStreamList;
+}
+
+};
+};
diff --git a/src/FMedia_MediaStreamInfoImpl.h b/src/FMedia_MediaStreamInfoImpl.h
new file mode 100644 (file)
index 0000000..5deafb7
--- /dev/null
@@ -0,0 +1,167 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_MediaStreamInfoImpl.h
+ * @brief                      This is the header file for the %_MediaStreamInfoImpl class.
+ *
+ * This header file contains the declarations of the %_MediaStreamInfoImpl class.
+ */
+
+#ifndef _FMEDIA_INTERNAL_MEDIASTREAMINFO_IMPL_H_
+#define _FMEDIA_INTERNAL_MEDIASTREAMINFO_IMPL_H_
+
+#include <FMediaAudioStreamInfo.h>
+#include <FMediaVideoStreamInfo.h>
+
+namespace Tizen { namespace Media
+{
+class _MediaStreamInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       //
+       //      This is the destructor for this class.
+       //
+       //
+       virtual ~_MediaStreamInfoImpl(void);
+
+public:
+       //
+       //      Gets the title.
+       //
+       //      @return           The value of the title, @n
+       //                    else an empty string if the content has no title
+       //
+       Tizen::Base::String GetTitle(void) const;
+
+       //
+       //      Gets the name of the artist from the content.
+       //
+       //      @return                     The artist, @n
+       //                               else an empty string if the content has no artist name
+       //
+       Tizen::Base::String GetArtist(void) const;
+
+       //
+       //      Gets the album title.
+       //
+       //      @return           The title of the album, @n
+       //                    else an empty string if the content has no album
+       //
+       Tizen::Base::String GetAlbumTitle(void) const;
+
+       //
+       //      Gets the genre.
+       //
+       //      @return           The genre, @n
+       //                    else an empty string if the content has no genre
+       //
+       Tizen::Base::String GetGenre(void) const;
+
+       //
+       //      Gets the year.
+       //
+       //      @return         The year, @n
+       //                  else @c 0 if the content has no year
+       //
+       int GetYear(void) const;
+
+       //
+       //      Gets the album art.
+       //
+       //      @return         The album art in the content, @n
+       //                  else @c null if the content has no album art
+       //
+       Tizen::Base::ByteBuffer* GetAlbumArtN(void) const;
+
+       //
+       //      Gets a list of the audio stream information.
+       //
+       //      @return                                             A pointer to the list containing the audio stream information @n
+       //                                                                  The value belongs to the %AudioStreamInfo class.
+       //      @exception      E_SUCCESS                               The method is successful.
+       //      @exception      E_INVALID_DATA                  The stream cannot be parsed successfully.
+       //      @exception      E_SYSTEM                                 A system error has occurred.
+       //      @remarks                                The specific error code can be accessed using the GetLastResult() method.
+       //
+       const Tizen::Base::Collection::IList* GetAudioStreamInfoList(void) const;
+
+       //
+       //      Gets a list of the video stream information.
+       //
+       //      @return         A pointer to a list containing the video stream information @n
+       //                                                              The value belongs to the %VideoStreamInfo class.
+       //      @exception      E_SUCCESS                               The method is successful.
+       //      @exception      E_INVALID_DATA                  The stream cannot be parsed successfully.
+       //      @exception      E_SYSTEM                                 A system error has occurred.
+       //      @remarks                                The specific error code can be accessed using the GetLastResult() method.
+       //
+       const Tizen::Base::Collection::IList* GetVideoStreamInfoList(void) const;
+
+       //
+       // @see @ref Tizen::Media::MediaStreamInfo::Equals()
+       //
+       virtual bool Equals(const Object& obj) const;
+
+       //
+       // @see @ref Tizen::Media::MediaStreamInfo::GetHashCode()
+       //
+       virtual int GetHashCode(void) const;
+
+private:
+       //
+       //      Initializes this instance of _MediaStreamInfoImpl with the specified parameters. @n
+       //
+       //      @param[in]              title                                   The value of the title @n
+       //      @param[in]              artist                                  The value of the artist @n
+       //      @param[in]              albumTitle                              The value of the title of the album @n
+       //      @param[in]              genre                                   The value of the genre @n
+       //      @param[in]              year                                    The value of the year @n
+       //      @param[in]              albumArt                                The value of the album art @n
+       //      @param[in]              pAudioStream                    A pointer to an audio stream list @n
+       //      @param[in]              pVideoStream                    A pointer to a video stream list @n
+       //      @param[in]              titleException                  An exception generated due to the title of audio or video @n
+       //      @param[in]              audioStreamException    The exception generated during audio streaming @n
+       //      @param[in]              videoStreamException    The exception generated during video streaming @n
+       //
+       _MediaStreamInfoImpl(const Tizen::Base::String& title, const Tizen::Base::String& artist, const Tizen::Base::String& albumTitle, const Tizen::Base::String& genre, int year, Tizen::Base::ByteBuffer* pAlbumArt, Tizen::Base::Collection::IList* pAudioStream, Tizen::Base::Collection::IList* pVideoStream, result audioStreamException, result videoStreamException);
+
+       _MediaStreamInfoImpl(const _MediaStreamInfoImpl& rhs);
+
+       _MediaStreamInfoImpl& operator = (const _MediaStreamInfoImpl& rhs);
+
+       int __year;
+       Tizen::Base::String __title;
+       Tizen::Base::String __artist;
+       Tizen::Base::String __albumTitle;
+       Tizen::Base::String __genre;
+       Tizen::Base::ByteBuffer* __pAlbumArt;
+
+       Tizen::Base::Collection::IList* __pAudioStreamList;
+       Tizen::Base::Collection::IList* __pVideoStreamList;
+
+       result __audioStreamListException;
+       result __videoStreamListException;
+
+       friend class MediaStreamInfo;
+};
+
+}}//Tizen::Media
+
+#endif
+
diff --git a/src/FMedia_Mp3Decoder.cpp b/src/FMedia_Mp3Decoder.cpp
new file mode 100644 (file)
index 0000000..4dce194
--- /dev/null
@@ -0,0 +1,331 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <stdio.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_FfmpegUtil.h"
+#include "FMedia_IAudioDecoder.h"
+#include "FMedia_Mp3Decoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_IAudioDecoder*
+_Mp3Decoder_CreateInstance(void)
+{
+       return new (std::nothrow) _Mp3Decoder();
+}
+
+_Mp3Decoder::_Mp3Decoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __decodeCalled = false;
+       __pOutBuf = null;
+}
+
+_Mp3Decoder::~_Mp3Decoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+       }
+}
+
+result
+_Mp3Decoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+
+       SysAssertf((__pCodecCtx == null && __pCodec == null), " Already Constructed .");\r
+
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                           "[%s] AVCODEC Context Allcoation Failed",GetErrorMessage(E_SYSTEM));\r
+       __pCodec = avcodec_find_decoder(CODEC_ID_MP3);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Find Decoder Failed for CODEC_ID_MP3",GetErrorMessage(E_SYSTEM));\r
+\r
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                           "[%s] AVCODEC Codec Open Failed for CODEC_ID_MP3",GetErrorMessage(E_SYSTEM));\r
+
+       // AVCodecContext parameters
+       if (__pCodec->capabilities & CODEC_CAP_TRUNCATED)
+       {
+               __pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+       }
+
+       __pCodecCtx->debug_mv = 0; //set by user
+       __pCodecCtx->debug = 0; //set by user
+       __pCodecCtx->workaround_bugs = 1; //set by user
+       __pCodecCtx->lowres = 0; //set by user
+       __pCodecCtx->skip_frame = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_idct = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_loop_filter = AVDISCARD_DEFAULT; //set by user
+
+       __pOutBuf = new (std::nothrow) byte[_MIN_OUT_BUFFER_SIZE];
+       SysTryCatch(NID_MEDIA, __pOutBuf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+
+       return r;
+
+CATCH:
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+               __pOutBuf = null;
+       }
+       return r;
+}
+
+result
+_Mp3Decoder::Decode(const byte* pSrcBuf, int srcBufSize, int& srcBufUsed,
+                                       byte* pDstBuf, int dstBufSize, int& dstBufUsed)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVPacket inputPacket;
+       int outBufSize = 0;
+       bool hasSyncBits = false;
+       byte* pOutBuf = null;
+       int srcBytesSkipped = 0;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, pSrcBuf != null && pDstBuf != null && srcBufSize > 0 && dstBufSize > 0,
+                          r = E_INVALID_ARG, E_INVALID_ARG,
+                         "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+
+       av_init_packet(&inputPacket);
+
+       // check this routines is required
+       for (int i = 0; i < srcBufSize - 1; i++)
+       {
+               if ((pSrcBuf[i] == 0xff) && ((pSrcBuf[i + 1] == 0xfb) || (pSrcBuf[i + 1] == 0xf3)))
+               {
+                       hasSyncBits = true;
+                       inputPacket.size = srcBufSize - i;
+                       inputPacket.data = (uint8_t*)pSrcBuf + i;
+                       srcBytesSkipped = i;
+                       break;
+               }
+       }
+
+       SysTryCatch(NID_MEDIA, hasSyncBits, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));\r
+
+       if (dstBufSize >= _MIN_OUT_BUFFER_SIZE)
+       {
+               pOutBuf = pDstBuf;
+               outBufSize = dstBufSize;
+       }
+       else
+       {
+               pOutBuf = __pOutBuf;
+               outBufSize = _MIN_OUT_BUFFER_SIZE;
+       }
+
+       res = avcodec_decode_audio3(__pCodecCtx, (int16_t*)pOutBuf, &outBufSize, &inputPacket);
+       SysTryCatch(NID_MEDIA, (res > 0 && outBufSize > 0), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));\r
+
+       SysTryCatch(NID_MEDIA, dstBufSize >= outBufSize, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                         "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+
+       dstBufUsed = outBufSize; // the decoded audio data size
+       srcBufUsed = res + srcBytesSkipped; // input bytes used
+       if (pOutBuf != pDstBuf)
+       {
+               memcpy(pDstBuf, pOutBuf, outBufSize);
+               __decodeCalled = true;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_Mp3Decoder::Probe(const byte* pSrcBuf, const int srcBufSize,
+                                  AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate)
+{
+       result r = E_SUCCESS;
+       int dstBufUsed = 0;
+       int srcBufUsed = 0;
+
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, pSrcBuf != null && srcBufSize > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+
+       r = Decode(pSrcBuf, srcBufSize, srcBufUsed, __pOutBuf, _MIN_OUT_BUFFER_SIZE, dstBufUsed);
+
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Decode failed", GetErrorMessage(r));
+
+       channelType = _FfmpegUtil::ToAudioChannelType(__pCodecCtx->channels);
+       sampleType = _FfmpegUtil::ToAudioSampleType(__pCodecCtx->sample_fmt);
+       sampleRate = __pCodecCtx->sample_rate;
+
+       SetLastResult(E_SUCCESS);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_Mp3Decoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+
+       avcodec_flush_buffers(__pCodecCtx);
+
+       __decodeCalled = false;
+       SetLastResult(E_SUCCESS);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_Mp3Decoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, __decodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+               value = _FfmpegUtil::ToAudioChannelType(__pCodecCtx->channels);
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE:
+               value = _FfmpegUtil::ToAudioSampleType(__pCodecCtx->sample_fmt);
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+               value = __pCodecCtx->sample_rate;
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_BIT_RATE:
+               value = __pCodecCtx->bit_rate;
+       break;
+
+       default:
+               r = E_OBJ_NOT_FOUND;
+       break;
+       }
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_Mp3Decoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                         "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, __decodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_Mp3Decoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+       pList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE);
+       pList->Add(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE);
+       pList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE);
+       pList->Add(MEDIA_PROPERTY_AUDIO_BIT_RATE);
+       SetLastResult(r);
+       return pList;
+
+CATCH:
+       return null;
+}
+
+bool
+_Mp3Decoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, type == MEDIA_PROPERTY_AUDIO_SAMPLE_RATE ||
+                          type == MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE ||
+                          type == MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE ||
+                          type == MEDIA_PROPERTY_AUDIO_BIT_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                         "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));\r
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+} } // Tizen::Media
diff --git a/src/FMedia_Mp3Decoder.h b/src/FMedia_Mp3Decoder.h
new file mode 100644 (file)
index 0000000..90fba87
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_Mp3Decoder.h
+ *  @brief  This is the header file for the _Mp3Decoder.
+ *
+ *  This header file contains the declarations of the _Mp3Decoder
+ */
+#ifndef _FMEDIA_INTERNAL_MP3DECODER_H_
+#define _FMEDIA_INTERNAL_MP3DECODER_H_
+
+
+namespace Tizen { namespace Media
+{
+
+class _Mp3Decoder
+       : public _IAudioDecoder
+{
+public:
+       _Mp3Decoder(void);
+
+       virtual ~_Mp3Decoder(void);
+
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* srcBuf, const int length,
+                                                AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate);
+
+       virtual result Decode(const byte* srcBuf, int srcBufSize, int &srcBufUsed,
+                                                 byte* dstBuf, int dstBufSize, int &dstBufUsed);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+private:
+       _Mp3Decoder(const _Mp3Decoder&);
+       _Mp3Decoder& operator =(const _Mp3Decoder&);
+
+private:
+       static const int _MIN_OUT_BUFFER_SIZE = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       bool __decodeCalled;
+       byte* __pOutBuf;
+};
+
+} }
+
+#endif // _FMEDIA_INTERNAL_MP3DECODER_H_
diff --git a/src/FMedia_Mpeg4Decoder.cpp b/src/FMedia_Mpeg4Decoder.cpp
new file mode 100644 (file)
index 0000000..e39d799
--- /dev/null
@@ -0,0 +1,437 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FMediaTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_IVideoDecoder.h"
+#include "FMedia_Mpeg4Decoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_IVideoDecoder*
+_Mpeg4Decoder_CreateInstance(void)
+{
+       return new (std::nothrow) _Mpeg4Decoder();
+}
+
+_Mpeg4Decoder::_Mpeg4Decoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __isDecodeCalled = false;
+}
+
+_Mpeg4Decoder::~_Mpeg4Decoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_flush_buffers(__pCodecCtx);
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+}
+
+result
+_Mpeg4Decoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+
+       SysAssertf((__pCodecCtx == null && __pCodec == null), " Already Constructed .");\r
+
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Context Allcoation Failed", GetErrorMessage(E_SYSTEM));\r
+
+       __pCodec = avcodec_find_decoder(CODEC_ID_MPEG4);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Find Decoder Failed for CODEC_ID_MPEG4", GetErrorMessage(E_SYSTEM));\r
+\r
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Codec Open Failed for CODEC_ID_MPEG4, \
+                          result of avcodec_open() = %d",
+                          GetErrorMessage(E_SYSTEM), res);\r
+
+       // AVCodecContext parameters
+       if (__pCodec->capabilities & CODEC_CAP_TRUNCATED)
+       {
+               __pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+       }
+
+       __pCodecCtx->debug_mv = 0; //set by user
+       __pCodecCtx->debug = 0; //set by user
+       __pCodecCtx->workaround_bugs = 1; //set by user
+       __pCodecCtx->lowres = 0; //set by user
+       __pCodecCtx->skip_frame = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_idct = AVDISCARD_DEFAULT; //set by user
+       __pCodecCtx->skip_loop_filter = AVDISCARD_DEFAULT; //set by user
+
+       return r;
+
+CATCH:
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       return r;
+}
+
+result
+_Mpeg4Decoder::Decode(const byte* pSrcBuf, int& srcBufLength,
+                                         byte*& pDstBuf, int& dstBufLength, bool& gotFrame)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVFrame* pVideoFrame = null;
+       AVPacket inputPacket;
+       int gotPicture = 0;
+       int remainingBytes = 0;
+       int srcOffset = 0;
+       int i = 0;
+       int offset = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE,  "[%s] The instance is in invalid state", GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, (pSrcBuf != null && pDstBuf != null && srcBufLength > 0 && dstBufLength > 0),
+                          r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid", GetErrorMessage(E_INVALID_ARG));\r
+
+       av_init_packet(&inputPacket);
+       inputPacket.size = srcBufLength;
+       pVideoFrame = avcodec_alloc_frame();
+       SysTryCatch(NID_MEDIA, pVideoFrame != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ", GetErrorMessage(E_OUT_OF_MEMORY));\r
+
+       inputPacket.data = (uint8_t*) pSrcBuf;
+
+       // Decoding the video packet
+       remainingBytes = srcBufLength;
+
+       do
+       {
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                                  "[%s] The input data format is not supported, \
+                                  result of avcodec_decode_video2() = %d ",
+                                  GetErrorMessage(E_UNSUPPORTED_FORMAT), res);\r
+
+               remainingBytes -= res;
+               inputPacket.data += res;
+               inputPacket.size -= res;
+
+               if (gotPicture)
+               {
+                       __isDecodeCalled = true;
+                       // "Got Frame."
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P ) // handling only  yuv 420 case
+                       {
+                               SysTryCatch(NID_MEDIA, dstBufLength >= (__pCodecCtx->height * __pCodecCtx->width * 3) / 2,
+                                                  r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                                  "[%s] pDstBuf:%d %d %d", GetErrorMessage(E_OUT_OF_MEMORY),\r
+                                                  dstBufLength, __pCodecCtx->height, __pCodecCtx->width);
+
+                               for (i = 0; i < __pCodecCtx->height; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[0];
+                                       offset = i * __pCodecCtx->width;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[0] + srcOffset, __pCodecCtx->width);
+                               }
+                               for (i = 0; i < __pCodecCtx->height / 2; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[1];
+                                       offset = (__pCodecCtx->height * __pCodecCtx->width) + (i * __pCodecCtx->width) / 2;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[1] + srcOffset, __pCodecCtx->width / 2);
+                               }
+                               for (i = 0; i < __pCodecCtx->height / 2; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[2];
+                                       offset = ((__pCodecCtx->height * __pCodecCtx->width * 5) / 4) + (i * __pCodecCtx->width) / 2;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[2] + srcOffset, __pCodecCtx->width / 2);
+                               }
+
+                               gotFrame = true;
+                               srcBufLength = srcBufLength - remainingBytes; //Input bytes used
+                               dstBufLength = (__pCodecCtx->height * __pCodecCtx->width * 3) / 2;
+                       }
+                       break;
+               }
+       }
+       while (remainingBytes);
+
+       if (!gotPicture)
+       {
+               // "Trying Again."
+               inputPacket.data = null;
+               inputPacket.size = 0;
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               if (gotPicture)
+               {
+                       __isDecodeCalled = true;
+                       // "Got Frame."
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P) // handling only  yuv 420 case
+                       {
+                               SysTryCatch(NID_MEDIA, dstBufLength >= (__pCodecCtx->height * __pCodecCtx->width * 3) / 2,
+                                                  r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                                  "[%s] Decode Failed Insufficient destination buffer", GetErrorMessage(E_OUT_OF_MEMORY));\r
+
+                               for (i = 0; i < __pCodecCtx->height; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[0];
+                                       offset = i * __pCodecCtx->width;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[0] + srcOffset, __pCodecCtx->width);
+                               }
+                               for (i = 0; i < __pCodecCtx->height / 2; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[1];
+                                       offset = (__pCodecCtx->height * __pCodecCtx->width) + (i * __pCodecCtx->width) / 2;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[1] + srcOffset, __pCodecCtx->width / 2);
+                               }
+                               for (i = 0; i < __pCodecCtx->height / 2; i++)
+                               {
+                                       srcOffset = i * pVideoFrame->linesize[2];
+                                       offset = ((__pCodecCtx->height * __pCodecCtx->width * 5) / 4) + (i * __pCodecCtx->width) / 2;
+                                       memcpy(pDstBuf + offset, pVideoFrame->data[2] + srcOffset, __pCodecCtx->width / 2);
+                               }
+                               gotFrame = true;
+                               srcBufLength = srcBufLength - remainingBytes;  //Input bytes used
+                               dstBufLength = (__pCodecCtx->height * __pCodecCtx->width * 3) / 2;
+                       }
+               }
+               else
+               {
+                       // "No Frame."
+                       srcBufLength = srcBufLength - remainingBytes;  //Input bytes used
+                       gotFrame = false;
+               }
+       }
+
+       if (pVideoFrame)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+
+CATCH:
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+}
+
+result
+_Mpeg4Decoder::Probe(const byte* pSrcBuf, const int srcBufLength,
+                                        int& width, int& height, MediaPixelFormat& pixelFormat)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVFrame* pVideoFrame = null;
+       AVPacket inputPacket;
+       int gotPicture = 0;
+       int remainingBytes = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, (pSrcBuf != null && srcBufLength > 0), r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid", GetErrorMessage(E_INVALID_ARG));\r
+
+       av_init_packet(&inputPacket);
+       inputPacket.size = srcBufLength;
+       pVideoFrame = avcodec_alloc_frame();
+       SysTryCatch(NID_MEDIA, (pVideoFrame != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ", GetErrorMessage(E_OUT_OF_MEMORY));\r
+       inputPacket.data = (uint8_t*) pSrcBuf;
+       remainingBytes = inputPacket.size;
+
+       do
+       {
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                                  "[%s] The input data format is not supported, \
+                                  result of avcodec_decode_video2 = %d",
+                                  GetErrorMessage(E_UNSUPPORTED_FORMAT), res);\r
+
+               if (gotPicture)
+               {
+                       // "Got Frame."
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P ) // handling only  yuv 420 case
+                       {
+                               width = __pCodecCtx->width;
+                               height = __pCodecCtx->height;
+                               pixelFormat = MEDIA_PIXEL_FORMAT_YUV420P;
+                       }
+                       break;
+               }
+
+               remainingBytes -= res;
+               inputPacket.data += res;
+               inputPacket.size -= res;
+       }
+       while (remainingBytes);
+
+       if (!gotPicture)
+       {
+               inputPacket.data = null;
+               inputPacket.size = 0;
+               res = avcodec_decode_video2(__pCodecCtx, pVideoFrame, &gotPicture, &inputPacket);
+               if (gotPicture && res >= 0)
+               {
+                       // "Got Frame."
+                       if (__pCodecCtx->pix_fmt == PIX_FMT_YUV420P) // handling only  yuv 420 case
+                       {
+                               width = __pCodecCtx->width;
+                               height = __pCodecCtx->height;
+                               pixelFormat = MEDIA_PIXEL_FORMAT_YUV420P;
+                       }
+               }
+               else
+               {
+                       r = E_UNSUPPORTED_FORMAT;
+               }
+       }
+
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+
+CATCH:
+       if (pVideoFrame != null)
+       {
+               av_free(pVideoFrame);
+       }
+       return r;
+}
+
+result
+_Mpeg4Decoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE,  "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       avcodec_flush_buffers(__pCodecCtx);
+       __isDecodeCalled = false;
+       return r;
+}
+
+result
+_Mpeg4Decoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, __isDecodeCalled == true, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                         "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH && type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));\r
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_VIDEO_WIDTH:
+               value = __pCodecCtx->width;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_HEIGHT:
+               value = __pCodecCtx->height;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT:
+               value = MEDIA_PIXEL_FORMAT_YUV420P;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_Mpeg4Decoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, __isDecodeCalled == true, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));\r
+       SysTryCatch(NID_MEDIA, 0 < type, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));\r
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH && type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));\r
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_Mpeg4Decoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pPropList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pPropList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));\r
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_WIDTH);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_HEIGHT);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT);
+       SetLastResult(r);
+       return pPropList;
+
+CATCH:
+       return null;
+}
+
+bool
+_Mpeg4Decoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, (type == MEDIA_PROPERTY_VIDEO_WIDTH || type == MEDIA_PROPERTY_VIDEO_HEIGHT
+                                                  || type == MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT),
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ", GetErrorMessage(E_OBJ_NOT_FOUND));\r
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_Mpeg4Decoder.h b/src/FMedia_Mpeg4Decoder.h
new file mode 100644 (file)
index 0000000..4f47595
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_Mpeg4Decoder.h
+ *  @brief  This is the header file for the _Mpeg4Decoder.
+ *
+ *  This header file contains the declarations of the _Mpeg4Decoder.
+ */
+#ifndef FMEDIA_INTERNAL_MPEG4DECODER_H_
+#define FMEDIA_INTERNAL_MPEG4DECODER_H_
+
+namespace Tizen { namespace Media
+{
+
+class _Mpeg4Decoder
+       : public _IVideoDecoder
+{
+public:
+       _Mpeg4Decoder(void);
+
+       virtual ~_Mpeg4Decoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* pSrcBuf, const int srcBufLength, int& width, int& height, MediaPixelFormat& pixelFormat);
+
+       virtual result Decode(const byte* pSrcBuf, int& srcBufLength, byte*& pDstBuf, int& dstBufLength, bool& gotFrame);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+private:
+       _Mpeg4Decoder(const _Mpeg4Decoder&);
+
+       _Mpeg4Decoder& operator =(const _Mpeg4Decoder&);
+
+private:
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       bool __isDecodeCalled;
+};
+
+};
+};
+
+
+#endif // FMEDIA_INTERNAL_MPEG4DECODER_H_
diff --git a/src/FMedia_Mpeg4Encoder.cpp b/src/FMedia_Mpeg4Encoder.cpp
new file mode 100644 (file)
index 0000000..5b68117
--- /dev/null
@@ -0,0 +1,478 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <unique_ptr.h>
+#include <stdio.h>
+#include <FBaseInteger.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FMediaTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_IVideoEncoder.h"
+#include "FMedia_Mpeg4Encoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+static const int _DEFAULT_QSCALE = 3;
+
+_IVideoEncoder*
+_Mpeg4Encoder_CreateInstance(void)
+{
+       return new (std::nothrow) _Mpeg4Encoder();
+}
+
+_Mpeg4Encoder::_Mpeg4Encoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __pFrame = null;
+       __firstFrame = true;
+}
+
+_Mpeg4Encoder::~_Mpeg4Encoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       if (__pFrame != null)
+       {
+               av_free(__pFrame);
+       }
+}
+
+result
+_Mpeg4Encoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       Integer* pKey = null;
+       Integer* pValue = null;
+       int key = -1;
+       int value = -1;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx == null, E_INVALID_STATE, "already constructed");
+
+       //avcodec_init();
+       avcodec_register_all();
+
+       __pCodec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to get avcodec encoder",GetErrorMessage(E_SYSTEM));
+
+       __pCodecCtx = avcodec_alloc_context3(__pCodec);
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] Failed to allocate avcodec context", GetErrorMessage(E_SYSTEM));
+
+       __pCodecCtx->bit_rate = BITRATE_IN_BITS;
+       __pCodecCtx->width = WIDTH;
+       __pCodecCtx->height = HEIGHT;
+       __pCodecCtx->time_base.den = 15;
+       __pCodecCtx->time_base.num = 1;
+       __pCodecCtx->gop_size = GOP;
+       __pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
+       __pCodecCtx->max_b_frames = 0;
+       __pCodecCtx->qmin = MIN_QP;
+       __pCodecCtx->qmax = MAX_QP;
+       __pCodecCtx->mpeg_quant = 1;
+
+       // The initialization values are given in the Hashmap
+       if (pOption != null)
+       {
+       std::unique_ptr<IMapEnumerator> pMapEnum(pOption->GetMapEnumeratorN());
+       SysTryCatch(NID_MEDIA, pMapEnum.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating");
+
+       while (pMapEnum.get()->MoveNext() == E_SUCCESS)
+       {
+               pKey = dynamic_cast<Integer*> (pMapEnum.get()->GetKey());
+               pValue = dynamic_cast<Integer*> (pMapEnum.get()->GetValue());
+
+               if (pKey == null || pValue == null)
+               {
+                       continue;
+               }
+
+               key = pKey->ToInt();
+               value = pValue->ToInt();
+
+               switch (key)
+               {
+               case MEDIA_PROPERTY_VIDEO_WIDTH:
+                       SysTryCatch(NID_MEDIA, value > 0 && value < MAX_WIDTH,
+                                          r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used: width %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->width = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_HEIGHT:
+                       SysTryCatch(NID_MEDIA, value > 0 && value < MAX_HEIGHT,
+                                          r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used: height %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->height = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_FRAME_RATE:
+                       SysTryCatch(NID_MEDIA, value > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: framerate %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->time_base.den = value;
+                       __pCodecCtx->time_base.num = 1;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT:
+                       SysTryCatch(NID_MEDIA, value == MEDIA_PIXEL_FORMAT_YUV420P, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: pixelFormat %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_BIT_RATE:
+                       SysTryCatch(NID_MEDIA, value >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: bitRate %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->bit_rate = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_QUANTIZATION_PARAMETER :
+                       SysTryCatch(NID_MEDIA, value >= MIN_QP && value <= MAX_QP,
+                                          r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: quantization parameter %d", GetErrorMessage(E_INVALID_ARG), value);
+                       //__pCodecCtx->mpeg_quant = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_QUANTIZATION_MIN :
+                       SysTryCatch(NID_MEDIA, value >= MIN_QP && value <= MAX_QP,
+                                          r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: quantization min %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->qmin = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_QUANTIZATION_MAX :
+                       SysTryCatch(NID_MEDIA, value >= MIN_QP && value <= MAX_QP,
+                                          r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: quantization max %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->qmax = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_GOP_SIZE :
+                       SysTryCatch(NID_MEDIA, value  >= 0,
+                                          r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used: gop size %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->gop_size = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_PACKET_SIZE  :
+                       SysTryCatch(NID_MEDIA, value >= 0,
+                                          r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used: slice size %d", GetErrorMessage(E_INVALID_ARG), value);
+                       __pCodecCtx->rtp_payload_size = value;
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_USE_AC_PREDICTION :
+                       SysTryCatch(NID_MEDIA, value == 0 || value == 1, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: slice size %d", GetErrorMessage(E_INVALID_ARG), value);
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_USE_HEADER_EXTENSION_CODE :
+                       SysTryCatch(NID_MEDIA, value == 0 || value == 1, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: slice size %d", GetErrorMessage(E_INVALID_ARG), value);
+                       break;
+
+               case MEDIA_PROPERTY_VIDEO_USE_FRAME_SKIP:
+                       SysTryCatch(NID_MEDIA, value == 0 || value == 1, r = E_INVALID_ARG, E_INVALID_ARG,
+                                          "[%s] Invalid argument is used: slice size %d", GetErrorMessage(E_INVALID_ARG), value);
+                       break;
+
+               default:
+
+                       break;
+               }
+       }
+       }
+
+       res = avcodec_open2(__pCodecCtx, __pCodec, NULL);
+
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] avcodec open failed %d ", GetErrorMessage(E_SYSTEM), res);
+
+       __pFrame = avcodec_alloc_frame();
+       SysTryCatch(NID_MEDIA, __pFrame != null, r = E_SYSTEM, E_SYSTEM, "[%s] avcodec alloc frame failed", GetErrorMessage(E_SYSTEM));
+
+       __pFrame->format = __pCodecCtx->pix_fmt;
+       __pFrame->pts  = 0;
+       for (int i = 0; i < 4; i++)
+       {
+               __pFrame->data[i] = null;
+               __pFrame->linesize[i] = 0;
+       }
+       __firstFrame = true;
+
+       return r;
+
+CATCH:
+
+       if (__pCodecCtx)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       return r;
+}
+
+result
+_Mpeg4Encoder::Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       int outIndex = 0;
+       int minSrcBufLength = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       minSrcBufLength = __pCodecCtx->width * __pCodecCtx->height * 3 / 2;
+       SysTryCatch(NID_MEDIA, (srcBuf != null && dstBuf != null && srcBufLength >= minSrcBufLength && dstBufLength >= FF_MIN_BUFFER_SIZE),
+                          r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[E_INVALID_ARG] Encode Failed : 0x%x %d %d 0x%x %d %d",
+                          srcBuf, srcBufLength, minSrcBufLength, dstBuf, dstBufLength, FF_MIN_BUFFER_SIZE);
+
+       __pFrame->data[0] = (uint8_t*)srcBuf;
+       __pFrame->data[1] = (uint8_t*)srcBuf + __pCodecCtx->width * __pCodecCtx->height;
+       __pFrame->data[2] = (uint8_t*)srcBuf + __pCodecCtx->width * __pCodecCtx->height * 5 / 4;
+       __pFrame->linesize[0] = __pCodecCtx->width;
+       __pFrame->linesize[1] = __pCodecCtx->width / 2;
+       __pFrame->linesize[2] = __pCodecCtx->width / 2;
+
+       if (__firstFrame && __pCodecCtx->extradata)
+       {
+               SysLog(NID_MEDIA, "extradata:%x %d", __pCodecCtx->extradata, __pCodecCtx->extradata_size);
+               memcpy(dstBuf, __pCodecCtx->extradata, __pCodecCtx->extradata_size);
+               __firstFrame = false;
+               dstBufLength -= __pCodecCtx->extradata_size;
+               outIndex += __pCodecCtx->extradata_size;
+       }
+
+#ifdef OLD_API
+       res = avcodec_encode_video(__pCodecCtx, (uint8_t*)dstBuf+outIndex, dstBufLength, __pFrame);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM, "[%s] Video Encode Failed %d", GetErrorMessage(E_SYSTEM), res);
+
+       srcBufLength = minSrcBufLength;
+       dstBufLength = res + outIndex;
+#else
+       {
+               AVPacket pkt;
+               int gotOutput;
+
+               av_init_packet(&pkt);
+               pkt.data = NULL;    // packet data will be allocated by the encoder
+               pkt.size = 0;
+
+               __pFrame->pts++;
+
+               /* encode the image */
+               res = avcodec_encode_video2(__pCodecCtx, &pkt, __pFrame, &gotOutput);
+               SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM, "[%s] Video Encode Failed %d", GetErrorMessage(E_SYSTEM), res);
+
+               if (gotOutput)
+               {
+                       SysTryCatch(NID_MEDIA, pkt.size <= dstBufLength, r = E_INVALID_ARG, E_INVALID_ARG,
+                                               "[%s] dst buffer is insufficient:%d %d", GetErrorMessage(E_INVALID_ARG), dstBufLength, pkt.size);
+                       memcpy(dstBuf+outIndex, pkt.data, pkt.size);
+                       srcBufLength = minSrcBufLength;
+                       dstBufLength = pkt.size + outIndex;
+                       av_free_packet(&pkt);
+               }
+               else
+               {
+                       srcBufLength = minSrcBufLength;
+                       dstBufLength = outIndex;
+               }
+       }
+#endif
+
+CATCH:
+       return r;
+}
+
+
+result
+_Mpeg4Encoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       avcodec_flush_buffers(__pCodecCtx);
+       return r;
+}
+
+result
+_Mpeg4Encoder::SetValue(MediaPropertyType type, int value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, value >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. type:%d", GetErrorMessage(E_SYSTEM), type);
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. type:%d", GetErrorMessage(E_SYSTEM), type);
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH && type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] object not found: type:%d", GetErrorMessage(E_OBJ_NOT_FOUND),type);
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_VIDEO_WIDTH:
+       SysTryCatch(NID_MEDIA, value < MAX_WIDTH, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. type:%d", GetErrorMessage(E_INVALID_ARG), type);
+               __pCodecCtx->width = value;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_HEIGHT:
+       SysTryCatch(NID_MEDIA, value < MAX_HEIGHT, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. type:%d", GetErrorMessage(E_INVALID_ARG), type);
+               __pCodecCtx->height = value;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT:
+               __pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_FRAME_RATE:
+               __pCodecCtx->time_base.den = 15;
+               __pCodecCtx->time_base.num = 1;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_BIT_RATE:
+               __pCodecCtx->bit_rate = value;
+               break;
+
+
+       case MEDIA_PROPERTY_VIDEO_QUANTIZATION_PARAMETER :
+               __pCodecCtx->mpeg_quant = value;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_QUANTIZATION_MIN :
+               __pCodecCtx->qmin = value;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_QUANTIZATION_MAX :
+               __pCodecCtx->qmax = value;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_GOP_SIZE :
+               __pCodecCtx->gop_size = value;
+               break;
+
+       case MEDIA_PROPERTY_VIDEO_PACKET_SIZE  :
+               __pCodecCtx->rtp_payload_size = value;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_Mpeg4Encoder::SetValue(MediaPropertyType type, bool value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used", GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA,(value ==0 || value == 1), r = E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used", GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, type >= MEDIA_PROPERTY_VIDEO_WIDTH || type <= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object Not Found",GetErrorMessage(E_OBJ_NOT_FOUND));
+       switch (type)
+       {
+       case MEDIA_PROPERTY_VIDEO_FORCE_SKIP_FRAME:
+               __pCodecCtx->skip_frame = AVDISCARD_DEFAULT;
+       break;
+
+       case MEDIA_PROPERTY_VIDEO_FORCE_INTRA_CODING:
+               __pCodecCtx->skip_idct = AVDISCARD_DEFAULT;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_Mpeg4Encoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pPropList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pPropList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory allocation Failed",GetErrorMessage(E_OUT_OF_MEMORY));
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_WIDTH);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_HEIGHT);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_FRAME_RATE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_BIT_RATE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_QUANTIZATION_PARAMETER);
+       pPropList->Add( MEDIA_PROPERTY_VIDEO_QUANTIZATION_MAX);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_QUANTIZATION_MIN);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_GOP_SIZE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_PACKET_SIZE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_USE_FRAME_SKIP);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_USE_AC_PREDICTION);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_USE_HEADER_EXTENSION_CODE);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_FORCE_SKIP_FRAME);
+       pPropList->Add(MEDIA_PROPERTY_VIDEO_FORCE_INTRA_CODING);
+
+       SetLastResult(r);
+       return pPropList;
+
+CATCH:
+       return null;
+}
+
+bool
+_Mpeg4Encoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx, E_INVALID_STATE, "not constructed");
+       SysTryCatch(NID_MEDIA, ( type == MEDIA_PROPERTY_VIDEO_WIDTH || type == MEDIA_PROPERTY_VIDEO_HEIGHT
+                                                       || type == MEDIA_PROPERTY_VIDEO_PIXEL_FORMAT || type == MEDIA_PROPERTY_VIDEO_FRAME_RATE
+                       || type == MEDIA_PROPERTY_VIDEO_BIT_RATE || type == MEDIA_PROPERTY_VIDEO_QUANTIZATION_PARAMETER || type ==
+                       MEDIA_PROPERTY_VIDEO_QUANTIZATION_MIN || type == MEDIA_PROPERTY_VIDEO_QUANTIZATION_MAX || type == MEDIA_PROPERTY_VIDEO_GOP_SIZE || type ==
+                       MEDIA_PROPERTY_VIDEO_PACKET_SIZE || type ==  MEDIA_PROPERTY_VIDEO_USE_FRAME_SKIP || type ==  MEDIA_PROPERTY_VIDEO_USE_AC_PREDICTION || type ==
+                       MEDIA_PROPERTY_VIDEO_USE_HEADER_EXTENSION_CODE || type ==  MEDIA_PROPERTY_VIDEO_FORCE_SKIP_FRAME || type ==  MEDIA_PROPERTY_VIDEO_FORCE_INTRA_CODING),
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[E_OBJ_NOT_FOUND] Object not found. type:%d", type);
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_Mpeg4Encoder.h b/src/FMedia_Mpeg4Encoder.h
new file mode 100644 (file)
index 0000000..5f0a730
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_Mpeg4Encoder.h
+ *  @brief  This is the header file for the _Mpeg4Encoder.
+ *
+ *  This header file contains the declarations of the Tizen::Media::_Mpeg4Encoder.
+ */
+#ifndef FMEDIA_INTERNAL_MPEG4ENCODER_H_
+#define FMEDIA_INTERNAL_MPEG4ENCODER_H_
+
+
+namespace Tizen { namespace Media
+{
+
+class _Mpeg4Encoder
+       : public _IVideoEncoder
+{
+public:
+       _Mpeg4Encoder(void);
+
+       virtual ~_Mpeg4Encoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Encode(const byte* srcBuf, int& srcBufLength, byte*& dstBuf, int& dstBufLength);
+
+       virtual result Reset(void);
+
+       virtual result SetValue(MediaPropertyType key, int value);
+
+       virtual result SetValue(MediaPropertyType key, bool value);
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+private:
+       _Mpeg4Encoder(const _Mpeg4Encoder&);
+
+       _Mpeg4Encoder& operator =(const _Mpeg4Encoder&);
+
+private:
+       static const int HEIGHT = 144;
+       static const int WIDTH = 176;
+       static const int MAX_WIDTH = 800;
+       static const int MAX_HEIGHT = 600;
+       static const int MAX_FRAME_RATE = 30;
+       static const int QUANTISATION_PARAMETER = 30;
+       static const int GOP = 10;
+       // (bytes per second = bitrate * 1000 / 8) intermediate bit rate around 320 kbps
+       static const int BITRATE_IN_BITS = 64 * 1000;
+       static const int FRAME_RATE = 20;
+       static const int MIN_QP = 1;
+       static const int MAX_QP = 31;
+       static const int INTERNAL_BUFFER_COUNT = 0;
+
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       AVFrame* __pFrame;
+       bool __firstFrame;
+};
+
+};
+};
+
+
+#endif // FMEDIA_INTERNAL_MPEG4ENCODER_H_
diff --git a/src/FMedia_PlayerEvent.cpp b/src/FMedia_PlayerEvent.cpp
new file mode 100644 (file)
index 0000000..28be1f4
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+#include "FMedia_PlayerEvent.h"
+#include "FMedia_PlayerEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_PlayerEvent::_PlayerEvent()
+       : __cntListener(0)
+{
+
+}
+
+_PlayerEvent::~_PlayerEvent(void)
+{
+
+}
+
+result
+_PlayerEvent::Construct(void)
+{
+       result r = E_SUCCESS;
+       r = _Event::Initialize();
+       return r;
+}
+
+void
+_PlayerEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       IPlayerEventListener* pPlayerEventListener = dynamic_cast<IPlayerEventListener*> (&listener);
+       SysTryReturn(NID_MEDIA, pPlayerEventListener, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. IPlayerEventListener must not be null.");
+
+       const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
+       SysTryReturn(NID_MEDIA, pTempArg, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. IEventArg must not be null.");
+       _PlayerEventTypeArg* pArg = (_PlayerEventTypeArg*) pTempArg;
+
+       switch (pArg->GetEventType())
+       {
+       case _PLAYER_EVENT_ERROR:
+               pPlayerEventListener->OnPlayerErrorOccurred(((_PlayerErrorArg*) pArg)->GetError());
+               break;
+
+       case _PLAYER_EVENT_OPENED:
+               pPlayerEventListener->OnPlayerOpened(((_PlayerEventArg*) pArg)->GetResult());
+               break;
+
+       case _PLAYER_EVENT_ENDOFCLIP:
+               pPlayerEventListener->OnPlayerEndOfClip();
+               break;
+
+       case _PLAYER_EVENT_BUFFERING:
+               pPlayerEventListener->OnPlayerBuffering(((_PlayerStreamingEventArg*) pArg)->GetPercent());
+               break;
+
+       case _PLAYER_EVENT_SEEKTO:
+               pPlayerEventListener->OnPlayerSeekCompleted(((_PlayerEventArg*) pArg)->GetResult());
+               break;
+
+       case _PLAYER_EVENT_INTERRUPTED:
+               pPlayerEventListener->OnPlayerInterrupted();
+               break;
+
+       case _PLAYER_EVENT_RELEASED:
+               pPlayerEventListener->OnPlayerReleased();
+               break;
+
+       case _PLAYER_EVENT_AUDIO_FOCUS_CHANGED:
+               pPlayerEventListener->OnPlayerAudioFocusChanged();
+               break;
+
+       default:
+               break;
+
+       }
+}
+
+};
+};
diff --git a/src/FMedia_PlayerEventArg.cpp b/src/FMedia_PlayerEventArg.cpp
new file mode 100644 (file)
index 0000000..0c0fd28
--- /dev/null
@@ -0,0 +1,135 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMedia_PlayerEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_PlayerEventTypeArg::_PlayerEventTypeArg(void)
+       : __playerEventType(_PLAYER_EVENT_NONE)
+{
+
+}
+
+_PlayerEventTypeArg::~_PlayerEventTypeArg(void)
+{
+
+
+}
+void
+_PlayerEventTypeArg::SetEventType(_PlayerEventType eType)
+{
+       __playerEventType = eType;
+}
+
+_PlayerEventType
+_PlayerEventTypeArg::GetEventType(void) const
+{
+       return __playerEventType;
+}
+
+_PlayerEventArg::_PlayerEventArg(void)
+       : __playerData(null)
+       , __result(E_SUCCESS)
+{
+
+}
+
+_PlayerEventArg::~_PlayerEventArg(void)
+{
+       if (__playerData)
+       {
+               delete (Tizen::Base::ByteBuffer*) __playerData;
+               __playerData = null;
+       }
+}
+
+void
+_PlayerEventArg::SetData(Tizen::Base::ByteBuffer* data)
+{
+       __playerData = data;
+}
+
+Tizen::Base::ByteBuffer*
+_PlayerEventArg::GetData(void) const
+{
+       return __playerData;
+}
+
+result
+_PlayerEventArg::GetResult(void) const
+{
+       return __result;
+}
+
+void
+_PlayerEventArg::SetResult(result r)
+{
+       __result = r;
+}
+
+
+_PlayerErrorArg::_PlayerErrorArg(void)
+       : __error(PLAYER_ERROR_NONE)
+{
+
+}
+
+_PlayerErrorArg::~_PlayerErrorArg(void)
+{
+
+}
+
+PlayerErrorReason
+_PlayerErrorArg::GetError(void) const
+{
+       return __error;
+}
+
+void
+_PlayerErrorArg::SetError(PlayerErrorReason r)
+{
+       __error = r;
+}
+
+_PlayerStreamingEventArg::_PlayerStreamingEventArg(void)
+       : __percent(0)
+{
+
+}
+
+_PlayerStreamingEventArg::~_PlayerStreamingEventArg(void)
+{
+
+}
+
+int
+_PlayerStreamingEventArg::GetPercent(void) const
+{
+       return __percent;
+}
+
+void
+_PlayerStreamingEventArg::SetPercent(int value)
+{
+       __percent = value;
+}
+
+
+};
+};   // Tizen::Media
diff --git a/src/FMedia_PlayerEventArg.h b/src/FMedia_PlayerEventArg.h
new file mode 100644 (file)
index 0000000..ae37842
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_PlayerEventArg.h
+ * @brief                      This header file contains the declaration of Tizen::Media namespace.
+ */
+
+#ifndef _FMEDIA_INTERNAL_PLAYER_EVENTARG_H_
+#define _FMEDIA_INTERNAL_PLAYER_EVENTARG_H_
+
+#include <FOspConfig.h>
+#include <FMediaPlayerTypes.h>
+#include <FBaseObject.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseRtIEventArg.h>
+#include "FMedia_PlayerEventTypes.h"
+
+namespace Tizen {namespace Media
+{
+
+class  _PlayerEventTypeArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+
+       _PlayerEventTypeArg(void);
+       virtual ~_PlayerEventTypeArg(void);
+       _PlayerEventType GetEventType(void) const;
+       void SetEventType(_PlayerEventType eType);
+
+private:
+       _PlayerEventTypeArg(const _PlayerEventTypeArg& rhs);
+       _PlayerEventTypeArg& operator =(const _PlayerEventTypeArg& rhs);
+
+       _PlayerEventType __playerEventType;
+
+};
+
+
+class  _PlayerEventArg
+       : public _PlayerEventTypeArg
+{
+public:
+
+       _PlayerEventArg(void);
+       virtual ~_PlayerEventArg(void);
+       Tizen::Base::ByteBuffer* GetData(void) const;
+       void SetData(Tizen::Base::ByteBuffer* data);
+       result GetResult(void) const;
+       void SetResult(result r);
+
+
+private:
+       Tizen::Base::ByteBuffer* __playerData;
+       result __result;
+
+};
+
+class  _PlayerErrorArg
+       : public _PlayerEventTypeArg
+{
+public:
+
+       _PlayerErrorArg(void);
+       virtual ~_PlayerErrorArg(void);
+       PlayerErrorReason GetError(void) const;
+       void SetError(PlayerErrorReason r);
+
+private:
+       PlayerErrorReason __error;
+
+};
+
+
+class  _PlayerStreamingEventArg
+       : public _PlayerEventArg
+{
+public:
+
+       _PlayerStreamingEventArg(void);
+       virtual ~_PlayerStreamingEventArg(void);
+       int GetPercent(void) const;
+
+private:
+       void SetPercent(int val);
+
+
+private:
+       friend class _PlayerImpl;
+       int __percent;
+
+};
+
+
+}} // Tizen::Media
+
+#endif
diff --git a/src/FMedia_PlayerImpl.cpp b/src/FMedia_PlayerImpl.cpp
new file mode 100644 (file)
index 0000000..6ee64bf
--- /dev/null
@@ -0,0 +1,2464 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <FBase_StringConverter.h>
+#include <FBaseSysLog.h>
+#include <FGrpBitmapCommon.h>
+#include <FGrpDimension.h>
+#include <FIoFile.h>
+#include <FBaseCol.h>
+#include <FNetNetAccountManager.h>
+#include <FSys_SystemInfoImpl.h>
+#include <FGrp_VideoTextureImpl.h>
+#include <FMediaMediaStreamInfo.h>
+#include <FMediaCapability.h>
+#include "FMedia_ColorConverter.h"
+#include "FMedia_PlayerEvent.h"
+#include "FMedia_PlayerEventTypes.h"
+#include "FMedia_PlayerEventArg.h"
+#include "FMedia_PlayerVideoEvent.h"
+#include "FMedia_PlayerVideoEventTypes.h"
+#include "FMedia_PlayerVideoEventArg.h"
+#include <Evas.h>
+#include "FMedia_PlayerImpl.h"
+#include "FMedia_AudioManagerConvert.h"
+#include "FMedia_PlayerProgressiveDownloadEvent.h"
+#include "FMedia_PlayerProgressiveDownloadEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Graphics;
+using namespace Tizen::Net;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics::Opengl;
+
+namespace Tizen { namespace Media
+{
+
+int _PlayerImpl::__playerCount = 0;
+int _PlayerImpl::__maxInstanceCount = 0;
+std::unique_ptr<Tizen::Base::Runtime::Mutex> _PlayerImpl::__pMutex;
+bool _PlayerImpl::__isInstanceMutexInitialized = false;
+
+_PlayerImpl::_PlayerImpl(void)
+       : __hPlayer(null)
+       , __corePlayerCurState(PLAYER_STATE_NONE)
+       , __hCanvas(0)
+       , __handleType(_BufferInfoImpl::HANDLE_TYPE_NONE)
+       , __pPlayerEventListener(null)
+       , __pPlayerVideoEventListener(null)
+       , __pPlayerProgressiveDownloadListener(null)
+       , __orientation(ORIENTATION_PORTRAIT)
+       , __currentVolume(DEFAULT_PLAYER_VOLUME)
+       , __currentState(PLAYER_STATE_INITIALIZED)
+       , __videoPixelFormat(BITMAP_PIXEL_FORMAT_MIN)
+       , __bufferDataSize(0)
+       , __decodedFrameWidth(0)
+       , __decodedFrameHeight(0)
+       , __decodedFrameSize(0)
+       , __pdCallbackRate(10)
+       , __pVideoTextureImpl(null)
+       , __isOpenBuffer(false)
+       , __isMuted(false)
+       , __isLooped(false)
+       , __isLocalData(true)
+       , __isAsync(false)
+       , __checkCallbackForReadyState(false)
+       , __isStreamingContent(false)
+       , __videoEventCreated(false)
+       , __isPlayerConstructed(false)
+       , __isStateChangeForVideoCapture(false)
+       , __isProgressiveContent(false)
+       , __isProgressiveTimerStarted(false)
+       , __interruptFlag(false)
+{
+}
+
+_PlayerImpl::~_PlayerImpl(void)
+{
+       // Destruct only if player is constructed.
+       if (__isPlayerConstructed == false )
+       {
+               return;
+       }
+       SysTryLog(NID_MEDIA, false, "Destroy player");
+
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+       __isOpenBuffer = false;
+       __isStreamingContent = false;
+       __bufferDataSize = 0;
+       __isPlayerConstructed = false;
+       __isLocalData = true;
+
+       if (__hPlayer)
+       {
+               ret = player_get_state(__hPlayer, &__corePlayerCurState );
+               if (ret == 0)
+               {
+                       if ( __corePlayerCurState == :: PLAYER_STATE_PAUSED || __corePlayerCurState == ::PLAYER_STATE_PLAYING )
+                       {
+                               ret = player_stop(__hPlayer);
+                               r = MapExceptionToResult(ret);
+                               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+                               ret = player_get_state(__hPlayer, &__corePlayerCurState );
+                               r = MapExceptionToResult(ret);
+                               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+                       if ( __corePlayerCurState == :: PLAYER_STATE_READY )
+                       {
+
+                               ret = player_unprepare(__hPlayer);
+                               r = MapExceptionToResult(ret);
+                               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+                               ret = player_get_state(__hPlayer, &__corePlayerCurState );
+                               r = MapExceptionToResult(ret);
+                               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+                       //un-set the callbacks
+                       player_unset_completed_cb(__hPlayer);
+                       player_unset_interrupted_cb(__hPlayer);
+                       player_unset_error_cb(__hPlayer);
+                       if (__videoEventCreated)
+                       {
+                               player_unset_video_frame_decoded_cb(__hPlayer);
+                       }
+
+                       if (__corePlayerCurState == :: PLAYER_STATE_IDLE )
+                       {
+                               ret = player_destroy(__hPlayer);
+                               r = MapExceptionToResult(ret);
+                               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
+               __hPlayer = null;
+       }
+
+       r = __pMutex->Acquire();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+       if (__playerCount)
+       {
+               // Decrease a number of player instance
+               __playerCount--;
+               SysLog(NID_MEDIA, "_~PlayerImpl Instance number is %d", __playerCount);
+       }
+       r = __pMutex->Release();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (__pPlayerEvent && __pPlayerEventListener)
+       {
+               __pPlayerEvent->RemoveListener(*__pPlayerEventListener);
+               __pPlayerEventListener = null;
+       }
+
+       if (__pPlayerVideoEvent && __pPlayerVideoEventListener)
+       {
+               __pPlayerVideoEvent->RemoveListener(*__pPlayerVideoEventListener);
+               __pPlayerVideoEventListener = null;
+       }
+       __pVideoTextureImpl = null;
+}
+
+void
+_PlayerImpl::InitInstanceMutex(void)
+{
+       result r = E_SUCCESS;
+       __pMutex.reset(new (std::nothrow) Tizen::Base::Runtime::Mutex);
+       SysTryReturn(NID_MEDIA, __pMutex.get() != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] no memory to create instance Mutex");
+       r = __pMutex->Create("FMEDIA_PLAYER");
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Mutex::Create failed.");
+       __isInstanceMutexInitialized  = true;
+}
+
+_PlayerImpl*
+_PlayerImpl::GetInstance(Player* pPlayer)
+{
+       if (pPlayer != null)
+       {
+               return pPlayer->__pPlayerImpl;
+       }
+
+       return null;
+}
+
+const _PlayerImpl*
+_PlayerImpl::GetInstance(const Player* pPlayer)
+{
+       if (pPlayer != null)
+       {
+               return pPlayer->__pPlayerImpl;
+       }
+
+       return null;
+}
+
+
+result
+_PlayerImpl::Construct(IPlayerEventListener& listener, const Tizen::Graphics::BufferInfo* pBufferInfo)
+{
+       result r = E_SUCCESS;
+       const _BufferInfoImpl   *pbufferInfoImpl = null;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (!__isInstanceMutexInitialized)
+       {
+               pthread_once(&onceBlock, InitInstanceMutex);
+       }
+       SysTryCatch(NID_MEDIA, __isInstanceMutexInitialized == true, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation for Instance Mutex failed");
+
+       //if the __maxInstanceCount is not initialized do so using Capability
+       if (!__maxInstanceCount)
+       {
+               r = MediaCapability::GetValue(PLAYER_COUNT_MAX, __maxInstanceCount);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s]Propagating", GetErrorMessage(r));
+               SysTryCatch(NID_MEDIA, __maxInstanceCount > 0, , r, "[%s]Propagating", GetErrorMessage(r));
+       }
+
+       // Check the instance maximum
+       SysTryReturn(NID_MEDIA, __playerCount < __maxInstanceCount, E_RESOURCE_UNAVAILABLE, E_RESOURCE_UNAVAILABLE,
+               "__playerCount count -%d failed can only create - %d Player Instances ",__playerCount,  __maxInstanceCount);
+
+       // Create Event
+       __pPlayerEvent.reset(new (std::nothrow) _PlayerEvent);
+       SysTryCatch(NID_MEDIA, __pPlayerEvent != null , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. __pPlayerEvent is null.");
+
+       r = __pPlayerEvent->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct _PlayerEvent.", GetErrorMessage(r));
+
+       r = __pPlayerEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform AddListener operation.", GetErrorMessage(r));
+
+       __pPlayerEventListener = &listener;
+
+       r = CreatePlayerAndSetCallBack();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform CreateMMPlayerInstanceAndSetMsgCallBack operation.", GetErrorMessage(r));
+
+       r = SetVolume(DEFAULT_PLAYER_VOLUME);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform SetVolume operation.", GetErrorMessage(r));
+
+       r = SetMute(false);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform SetMute operation.", GetErrorMessage(r));
+
+       r = SetLooping(false);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform SetLooping operation.", GetErrorMessage(r));
+
+       // Set the canvas to subsystem's player
+       if (pBufferInfo)
+       {
+               pbufferInfoImpl = _BufferInfoImpl::GetInstance(*pBufferInfo);
+               SysTryCatch(NID_MEDIA, pbufferInfoImpl != NULL, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pbufferInfoImpl instance must not be null.");
+               __orientation = (Orientation)(pbufferInfoImpl->GetOrientation());
+
+               // Set an available handler even if handler is not available.
+               if (pbufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION))
+               {
+                       __hCanvas = pbufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION);
+                       __handleType = _BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION;
+               }
+               else if (pbufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE))
+               {
+                       __hCanvas = pbufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE);
+                       __handleType = _BufferInfoImpl::HANDLE_TYPE_VE_SURFACE;
+               }else
+               {
+                       // handle is invalid
+                       __hCanvas = 0;
+                       __handleType = _BufferInfoImpl::HANDLE_TYPE_NONE;
+               }
+
+               SysTryCatch(NID_MEDIA, __hCanvas != 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used.  __hCanvas = %d", __hCanvas);
+       }
+
+       __pMutex->Acquire();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+       __playerCount++;
+       r = __pMutex->Release();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+       SysLog(NID_MEDIA, "Instance number is %d.", __playerCount);
+
+       __currentState = PLAYER_STATE_INITIALIZED;
+       __isPlayerConstructed = true;
+
+       return r;
+CATCH:
+       __pPlayerEventListener = null;
+       return r;
+}
+
+result
+_PlayerImpl::Construct(IPlayerEventListener& listener, IPlayerVideoEventListener& videoListener, void* pPlayerObj)
+{
+       result r = E_SUCCESS;
+       String key(L"http://tizen.org/feature/screen.bpp");
+       int bit = 0;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (!__isInstanceMutexInitialized)
+       {
+               pthread_once(&onceBlock, InitInstanceMutex);
+       }
+       SysTryCatch(NID_MEDIA, __isInstanceMutexInitialized == true, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation for Instance Mutex failed");
+
+       if (!__maxInstanceCount)
+       {
+               r = MediaCapability::GetValue(PLAYER_COUNT_MAX, __maxInstanceCount);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+               SysTryCatch(NID_MEDIA, __maxInstanceCount > 0, , r, "[%s] Propagating", GetErrorMessage(r));
+       }
+
+       // Check the instance maximum
+       SysTryReturn(NID_MEDIA, __playerCount < __maxInstanceCount, r = E_RESOURCE_UNAVAILABLE, E_RESOURCE_UNAVAILABLE,
+               "[E_RESOURCE_UNAVAILABLE] __playerCount count -%d failed can only create - %d Player Instances ",__playerCount,  __maxInstanceCount);
+
+       // Create Event
+       __pPlayerEvent.reset(new (std::nothrow) _PlayerEvent);
+       SysTryCatch(NID_MEDIA, __pPlayerEvent, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. __pPlayerEvent is null.");
+
+       r = __pPlayerEvent->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct _PlayerEvent", GetErrorMessage(r));
+
+       r = __pPlayerEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform AddListner operation", GetErrorMessage(r));
+
+       __pPlayerEventListener = &listener;
+
+       // Create Video Event
+       __pPlayerVideoEvent.reset(new (std::nothrow) _PlayerVideoEvent);
+       SysTryCatch(NID_MEDIA, __pPlayerVideoEvent, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. pPlayerVideoEvent is null");
+
+       r = __pPlayerVideoEvent->Construct(pPlayerObj);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct _PlayerVideoEvent.", GetErrorMessage(r));
+
+       r = __pPlayerVideoEvent->AddListener(videoListener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform AddListner operation.", GetErrorMessage(r));
+
+       __pPlayerVideoEventListener = &videoListener;
+
+       // Set the bit per pixel of system
+       r = Tizen::System::_SystemInfoImpl::GetSysInfo(key, bit);
+
+       SetSystemBitPerPixel(bit);
+       __videoEventCreated = true;
+       // Set Canvas for surface in platform
+
+       r = CreatePlayerAndSetCallBack();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform CreateMMPlayerInstanceAndSetMsgCallBack operation.", GetErrorMessage(r));
+
+       r = SetVolume(DEFAULT_PLAYER_VOLUME);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform SetVolume operation.", GetErrorMessage(r));
+
+       r = SetMute(false);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform SetMute operation.", GetErrorMessage(r));
+
+       r = SetLooping(false);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform SetLooping operation.", GetErrorMessage(r));
+
+       __pMutex->Acquire();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+       __playerCount++;
+       r = __pMutex->Release();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+       SysLog(NID_MEDIA, "Instance number is %d", __playerCount);
+
+       __currentState = PLAYER_STATE_INITIALIZED;
+       __isPlayerConstructed = true;
+
+       return r;
+CATCH:
+
+       __pPlayerEventListener = null;
+       __pPlayerVideoEventListener=null;
+
+       return r;
+
+}
+
+result
+_PlayerImpl::Construct(IPlayerEventListener& listener, Tizen::Graphics::Opengl::VideoTexture& videoTexture)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (!__isInstanceMutexInitialized)
+       {
+               pthread_once(&onceBlock, InitInstanceMutex);
+       }
+       SysTryCatch(NID_MEDIA, __isInstanceMutexInitialized == true, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation for Instance Mutex failed");
+
+       //if the __maxInstanceCount is not initialized do so using Capability
+       if (!__maxInstanceCount)
+       {
+               r = MediaCapability::GetValue(PLAYER_COUNT_MAX, __maxInstanceCount);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s]Propagating", GetErrorMessage(r));
+               SysTryCatch(NID_MEDIA, __maxInstanceCount > 0, , r, "[%s]Propagating", GetErrorMessage(r));
+       }
+
+       // Check the instance maximum
+       SysTryReturn(NID_MEDIA, __playerCount < __maxInstanceCount, E_RESOURCE_UNAVAILABLE, E_RESOURCE_UNAVAILABLE,
+               "__playerCount count -%d failed can only create - %d Player Instances ",__playerCount,  __maxInstanceCount);
+
+       __pVideoTextureImpl = _VideoTextureImpl::GetInstance(videoTexture);
+       SysTryReturn(NID_MEDIA, __pVideoTextureImpl != null, E_INVALID_ARG, E_INVALID_ARG, "videoTexture argument passes is wrong");
+
+       // Create Event
+       __pPlayerEvent.reset(new (std::nothrow) _PlayerEvent);
+       SysTryCatch(NID_MEDIA, __pPlayerEvent != null , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. __pPlayerEvent is null.");
+
+       r = __pPlayerEvent->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct _PlayerEvent.", GetErrorMessage(r));
+
+       r = __pPlayerEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform AddListener operation.", GetErrorMessage(r));
+
+       __pPlayerEventListener = &listener;
+
+       r = CreatePlayerAndSetCallBack();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform CreateMMPlayerInstanceAndSetMsgCallBack operation.", GetErrorMessage(r));
+
+       r = SetVolume(DEFAULT_PLAYER_VOLUME);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform SetVolume operation.", GetErrorMessage(r));
+
+       r = SetMute(false);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform SetMute operation.", GetErrorMessage(r));
+
+       r = SetLooping(false);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform SetLooping operation.", GetErrorMessage(r));
+
+       __pMutex->Acquire();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+       __playerCount++;
+       r = __pMutex->Release();
+       SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+       SysLog(NID_MEDIA, "Instance number is %d.", __playerCount);
+
+       __currentState = PLAYER_STATE_INITIALIZED;
+       __isPlayerConstructed = true;
+
+       return r;
+CATCH:
+       __pPlayerEventListener = null;
+       return r;
+}
+
+result
+_PlayerImpl::OpenFile(const Tizen::Base::String& mediaLocalPath, bool isAsync)
+{
+       result r = E_SUCCESS;
+       int err = PLAYER_ERROR_NONE;
+       Tizen::Base::String strFileName;
+       std::unique_ptr<char[]> pInputFilePath;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       err = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred in player_get_state", GetErrorMessage(r));
+
+       SysTryReturn(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_IDLE,
+                       E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. State is %d", __corePlayerCurState);
+
+       strFileName = Tizen::Io::File::GetFileName(mediaLocalPath);
+
+       SysTryReturn(NID_MEDIA, ((mediaLocalPath.GetLength() > 0) && !strFileName.IsEmpty()), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+                               "[E_FILE_NOT_FOUND] mediaLocalPath's length is (%d).", mediaLocalPath.GetLength());
+
+       pInputFilePath.reset(_StringConverter::CopyToCharArrayN(mediaLocalPath));
+
+       SysTryCatch(NID_MEDIA, pInputFilePath.get() , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pInputFilePath is null");
+       SysLog(NID_MEDIA, "Input file path after conversion is [%s]", pInputFilePath.get());
+
+       __currentState = PLAYER_STATE_OPENING;
+       __isAsync = isAsync;
+
+       r = OpenInputData(std::move(pInputFilePath));
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform OpenInputData operation.", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       __currentState = PLAYER_STATE_INITIALIZED;
+       return r;
+}
+
+result
+_PlayerImpl::OpenBuffer(const Tizen::Base::ByteBuffer& mediaBuffer, bool isAsync)
+{
+       result r = E_SUCCESS;
+       int err = PLAYER_ERROR_NONE;
+       std::unique_ptr<char[]> pInputFilePath;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       err = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred. Failed to perform player_getstate operation with - 0x%x", GetErrorMessage(r), err);
+
+       SysTryReturn(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_IDLE,
+               E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. State is %d ", __corePlayerCurState);
+
+       __pTargetByteBuffer.reset(new (std::nothrow) ByteBuffer);
+       SysTryCatch(NID_MEDIA, __pTargetByteBuffer , r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed. pTargetByteBuffer is null");
+
+       r = __pTargetByteBuffer->Construct(mediaBuffer);
+
+       __isOpenBuffer = true;
+       __bufferDataSize = __pTargetByteBuffer->GetCapacity();
+
+       SysTryCatch(NID_MEDIA, __bufferDataSize > 0, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Buffer instance is not available.");
+       SysTryCatch(NID_MEDIA, __pTargetByteBuffer->GetPointer() , r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Buffer instance is not available.");
+
+       __currentState = PLAYER_STATE_OPENING;
+       __isAsync = isAsync;
+
+       r = OpenInputData(std::move(pInputFilePath));
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform OpenInputData operation.", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       __isOpenBuffer = false;
+       __currentState = PLAYER_STATE_INITIALIZED;
+       return r;
+}
+
+result
+_PlayerImpl::OpenUrl(const Tizen::Base::Utility::Uri& mediaUri, bool isAync)
+{
+       result r = E_SUCCESS;
+
+       Tizen::Base::String urlStr;
+       Tizen::Base::String scheme;
+       NetAccountManager accountMgr;
+       std::unique_ptr<char[]> pInputFilePath;
+
+       int err = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       err = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred. Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), err);
+
+       SysTryReturn(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_IDLE,
+                E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. State is %d", __corePlayerCurState);
+
+       SysTryReturn(NID_MEDIA, !mediaUri.ToString().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Input url is empty");
+
+       scheme = mediaUri.GetScheme();
+       SysTryCatch(NID_MEDIA, (scheme.Equals(L"rtsp", false) || scheme.Equals(L"http", false)), r = E_UNSUPPORTED_PROTOCOL,
+               E_UNSUPPORTED_PROTOCOL, "[E_UNSUPPORTED_PROTOCOL] error has been occurred.");
+
+       pInputFilePath.reset(_StringConverter::CopyToCharArrayN(mediaUri.ToString()));
+       __isAsync = isAync;
+       __isStreamingContent = true;
+       __currentState = PLAYER_STATE_OPENING;
+
+       r = OpenInputData(std::move(pInputFilePath));
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform OpenInputData operation.", GetErrorMessage(r));
+       __isLocalData = false;
+
+       return r;
+CATCH:
+       __isStreamingContent = false;
+       __currentState = PLAYER_STATE_INITIALIZED;
+       return r;
+}
+
+result
+_PlayerImpl::OpenInputData(std::unique_ptr<char[]> pStrInputFilePath)
+{
+       result r = E_SUCCESS;
+       int err = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       if (__isOpenBuffer)
+       {
+               err = player_set_memory_buffer(__hPlayer, (void *) __pTargetByteBuffer->GetPointer(), __bufferDataSize);
+       }
+       else
+       {
+               SysTryReturn(NID_MEDIA, pStrInputFilePath.get() , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. StrInputFilePath is null.");
+               err = player_set_uri(__hPlayer, pStrInputFilePath.get());
+       }
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred.", GetErrorMessage(r));
+
+       if (__hCanvas)
+       {
+               if (__handleType != _BufferInfoImpl::HANDLE_TYPE_VE_SURFACE)
+               {
+                       SysLog(NID_MEDIA, "PLAYER_DISPLAY_TYPE_X11");
+                       err = player_set_display(__hPlayer, PLAYER_DISPLAY_TYPE_X11, (player_display_h) __hCanvas);
+               }else
+               {
+                       SysLog(NID_MEDIA, "PLAYER_DISPLAY_TYPE_EVAS");
+                       err = player_set_display(__hPlayer, PLAYER_DISPLAY_TYPE_EVAS, (player_display_h) __hCanvas);
+               }
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred. Failed to perform player_set_display operation with - 0x%x", GetErrorMessage(r), err);
+
+               err = player_set_display_mode(__hPlayer, PLAYER_DISPLAY_MODE_FULL_SCREEN);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred. Failed to perform player_set_display_mode operation with - 0x%x", GetErrorMessage(r), err);
+       }
+
+       if (__pVideoTextureImpl)
+       {
+               err = player_set_display_mode(__hPlayer, PLAYER_DISPLAY_MODE_FULL_SCREEN);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred. Failed to perform player_set_display_mode operation with - 0x%x", GetErrorMessage(r), err);
+
+               err = player_set_x11_display_pixmap(__hPlayer, _VideoTextureImpl::GetPixmap, (void*)__pVideoTextureImpl);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred. Failed to perform player_set_x11_display_pixmap with - 0x%x", GetErrorMessage(r), err);
+       }
+       if (__videoEventCreated)
+       {
+               err = player_set_display(__hPlayer, PLAYER_DISPLAY_TYPE_X11, (player_display_h) null);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] error has been occurred. Failed to perform player_set_display operation with - 0x%x", GetErrorMessage(r), err);
+
+               err = player_set_x11_display_visible(__hPlayer, false);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] error has been occurred. Failed to perform player_set_x11_display_visible operation with - 0x%x", GetErrorMessage(r), err);
+       }
+
+       if (__isAsync == false)
+       {
+               // Sync call
+               err = player_prepare(__hPlayer);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] error has been occurred. Failed to perform player_prepare operation with 0x%x", GetErrorMessage(r), err);
+
+               err = player_get_state(__hPlayer, &__corePlayerCurState);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] error has been occurred. Failed to perform player_get_state operation with - 0x%x",GetErrorMessage(r), err);
+               SysTryCatch(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_READY , , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. wrong sync state is [%d]", __corePlayerCurState);
+               __currentState = PLAYER_STATE_OPENED;
+
+       }
+       else
+       {
+               // Async call
+               err = player_prepare_async(__hPlayer,PlayerPreparedCallBack,(void*)this);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] error has been occured. Failed to perform player_prepare_async operation with 0x%x", GetErrorMessage(r), err);
+       }
+
+       if (__isStreamingContent)
+       {
+               err = player_set_buffering_cb(__hPlayer, PlayerBufferingCallBack, (void*)this);
+               r = MapExceptionToResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] error has been occurred. Failed to perform player_set_buffering_cb with - 0x%x",GetErrorMessage(r), err);
+       }
+
+       return r;
+CATCH:
+       return r;
+}
+
+//Basic Functionalities of Tizen::Media::Player
+
+result
+_PlayerImpl::Close(void)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), ret);
+       SysTryReturn(NID_MEDIA, (__corePlayerCurState == ::PLAYER_STATE_READY ),
+               E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. State is %d", __corePlayerCurState);
+
+       ret = player_unprepare(__hPlayer);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform player_unprepare operation with - 0x%x", GetErrorMessage(r), ret);
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_getstate operation with - 0x%x", GetErrorMessage(r), ret);
+       SysTryCatch(NID_MEDIA, (__corePlayerCurState == ::PLAYER_STATE_IDLE ), r = E_INVALID_STATE, r, "[E_INVALID_STATE] Player state is in an invalid state - %d ",__corePlayerCurState);
+
+       //because player_unrealize is sync we can directly make the state as PLAYER_STATE_CLOSED
+       __currentState = PLAYER_STATE_CLOSED;
+       __isOpenBuffer = false;
+       __bufferDataSize = 0;
+       __isLocalData = true;
+
+       if (__isProgressiveContent)
+       {
+               if (__pPlayerProgressiveDownloadEvent)
+               {
+                       __pPlayerProgressiveDownloadEvent->RemoveListener(*__pPlayerProgressiveDownloadListener);
+                       __pPlayerProgressiveDownloadListener = null;
+               }
+               ret = player_unset_progressive_download_message_cb(__hPlayer);
+               r = MapExceptionToResult(ret);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_MEDIA, r == E_SUCCESS, "Failed to perform player_unset_progressive_download_message_cb operation with 0x%x", ret);
+               }
+               if (__pPdTimer)
+               {
+                       __pPdTimer->Cancel();
+                       __isProgressiveTimerStarted = false;
+               }
+               __isProgressiveContent = false;
+       }
+
+       if (__isStreamingContent)
+       {
+               ret = player_unset_buffering_cb(__hPlayer);
+               r = MapExceptionToResult(ret);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_MEDIA, r == E_SUCCESS, "Failed to perform player_unset_buffering_cb operation with 0x%x", ret);
+               }
+       }
+
+       if (__hCanvas)
+       {
+               if (__handleType == _BufferInfoImpl::HANDLE_TYPE_VE_SURFACE)
+               {
+                        evas_object_image_data_set((Evas_Object*)__hCanvas, NULL);
+               }
+       }
+               
+       __isStreamingContent = false;
+       return r;
+
+CATCH:
+       __currentState = PLAYER_STATE_ERROR;
+       return r;
+}
+
+result
+_PlayerImpl::Play(void)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] player_getstate failed with - 0x%x", GetErrorMessage(r), ret);
+       SysTryReturn(NID_MEDIA, ((__corePlayerCurState == ::PLAYER_STATE_READY ) || (__corePlayerCurState == ::PLAYER_STATE_PAUSED )),
+                        E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. State is %d", __corePlayerCurState);
+
+       ret = player_start(__hPlayer);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA,r == E_SUCCESS, r, r, "[%s] Failed to perform player_start operation with - 0x%x", GetErrorMessage(r), ret);
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with- 0x%x", GetErrorMessage(r), ret);
+       SysTryCatch(NID_MEDIA, (__corePlayerCurState == ::PLAYER_STATE_PLAYING),
+                       r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. State change was not proper returned state is - %d", __corePlayerCurState);
+       __isStateChangeForVideoCapture = false;
+
+       if (__isProgressiveContent)
+       {
+               if ((__pPdTimer != null) && (__isProgressiveTimerStarted == false))
+               {
+                       r = __pPdTimer->Start(_PLAYER_PROGRESSIVE_DOWNLOAD_TIMER_100_MS);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform Timer start operation.", GetErrorMessage(r));
+                       SysLog(NID_MEDIA, "Progressive Timer has started");
+                       __isProgressiveTimerStarted = true;
+               }
+       }
+       __currentState = PLAYER_STATE_PLAYING;
+       return r;
+CATCH:
+       __currentState = PLAYER_STATE_ERROR;
+       return r;
+}
+
+result
+_PlayerImpl::Stop(void)
+{
+
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), ret);
+       SysTryReturn(NID_MEDIA, ((__corePlayerCurState == ::PLAYER_STATE_PLAYING ) || (__corePlayerCurState == ::PLAYER_STATE_PAUSED )),
+                          E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. State is %d", __corePlayerCurState);
+
+       ret = player_stop(__hPlayer);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform player_stop operation with - 0x%x", GetErrorMessage(r), ret);
+       
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), ret);
+       SysTryCatch(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_READY,
+                          r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occured. State change was not proper returned state is %d", __corePlayerCurState);
+
+       __currentState = PLAYER_STATE_STOPPED;
+       return r;
+
+CATCH:
+       __currentState = PLAYER_STATE_ERROR;
+       return r;
+}
+
+result
+_PlayerImpl::Pause(void)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), ret);
+       SysTryReturn(NID_MEDIA, (__corePlayerCurState == ::PLAYER_STATE_PLAYING ), E_INVALID_STATE, E_INVALID_STATE,
+                                                                                                                                                                                                                                                       "[E_INVALID_STATE] Player state is in an invalid state. State is %d", __corePlayerCurState);
+
+       ret = player_pause(__hPlayer);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform player_pause operation with - 0x%x", GetErrorMessage(r), ret);
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), ret);
+       SysTryCatch(NID_MEDIA, (__corePlayerCurState == ::PLAYER_STATE_PAUSED ),
+                       r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. State change was not proper returned state is %d", __corePlayerCurState);
+
+       __currentState = PLAYER_STATE_PAUSED;
+       return r;
+
+CATCH:
+       __currentState = PLAYER_STATE_ERROR;
+       return r;
+}
+
+//Gets of Tizen::Media::Player
+
+PlayerState
+_PlayerImpl::GetState(void)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       if (__currentState == PLAYER_STATE_ERROR)
+       {
+               return PLAYER_STATE_ERROR;
+       }
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), ret);
+
+       if (__corePlayerCurState == ::PLAYER_STATE_PAUSED)
+       {
+               __currentState = PLAYER_STATE_PAUSED;
+               return PLAYER_STATE_PAUSED;
+       }
+       if (__corePlayerCurState == ::PLAYER_STATE_IDLE)
+       {
+               if (__currentState == PLAYER_STATE_INITIALIZED)
+               {
+                       return PLAYER_STATE_INITIALIZED;
+               }
+               __currentState = PLAYER_STATE_CLOSED;
+               return PLAYER_STATE_CLOSED;
+       }
+       return __currentState;
+CATCH:
+       return (PlayerState) - 1;
+}
+
+long
+_PlayerImpl::GetPosition(void) const
+{
+       int ret = PLAYER_ERROR_NONE;
+       int pos = 0;
+       result r = E_SUCCESS;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       ret = player_get_position(__hPlayer, &pos);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_position operation with 0x%x", GetErrorMessage(r), ret);
+
+       return((long) pos);
+CATCH:
+       return -1;
+}
+
+long
+_PlayerImpl::GetDuration(void)
+{
+       int err = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+       int duration = 0;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       SysTryCatch(NID_MEDIA, ((__currentState == PLAYER_STATE_PLAYING) || (__currentState == PLAYER_STATE_PAUSED)),
+                       r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. State is %d", __currentState);
+
+       //As a last resort try with palyer_get_duration
+       err = player_get_duration(__hPlayer, &duration);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_duration operation with 0x%x", GetErrorMessage(r), err);
+       SysLog(NID_MEDIA, "Duration is %d after player_get_duration.",duration);
+       return duration;
+
+CATCH:
+       return -1;
+}
+
+int
+_PlayerImpl::GetVolume(void) const
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       return __currentVolume;
+}
+
+bool
+_PlayerImpl::IsMute(void) const
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       return __isMuted;
+}
+
+bool
+_PlayerImpl::IsLooping(void) const
+{
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       return __isLooped;
+}
+
+result
+_PlayerImpl::SeekTo(long msTime)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with 0x%x", GetErrorMessage(r), ret);
+
+       SysTryReturn(NID_MEDIA, ((__corePlayerCurState == ::PLAYER_STATE_PLAYING ) || (__corePlayerCurState == ::PLAYER_STATE_PAUSED )
+                       || ((__isLocalData == true) && (__corePlayerCurState == ::PLAYER_STATE_READY ))),       E_INVALID_STATE, E_INVALID_STATE
+                       , "[E_INVALID_STATE] Player state is in an invalid state. Current state is %d", __corePlayerCurState);
+
+       SysTryReturn(NID_MEDIA, msTime >= 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The msTime is not greater than 0");
+
+       ret = player_set_position(__hPlayer, (int)msTime, PlayerSeekCompletedCallBack, (void *)this);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_set_position operation with [0x%x]", GetErrorMessage(r), ret);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_PlayerImpl::SetVolume(int volume)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+       float mmVolumeVal = 0;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       SysTryReturn(NID_MEDIA, volume >= MIN_PLAYER_VOLUME && volume <= MAX_PLAYER_VOLUME, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                                               "[E_OUT_OF_RANGE] Player volume (%d) is out of range.", volume);
+
+       mmVolumeVal = (float) volume / 100;
+
+       SysLog(NID_MEDIA, "Converted volume is [%f]", mmVolumeVal);
+       if ((mmVolumeVal < _PLAYER_MIN_VOLUME) || (mmVolumeVal > _PLAYER_MAX_VOLUME))
+       {
+               SysLog(NID_MEDIA, "[E_OUT_OF_RANGE] Player volume(%d) is out of range", volume);
+               return E_OUT_OF_RANGE;
+       }
+
+       ret = player_set_volume(__hPlayer, mmVolumeVal, mmVolumeVal);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform player_set_volume operation with - 0x%x", GetErrorMessage(r), ret);
+
+       __currentVolume = volume;
+       return r;
+}
+
+result
+_PlayerImpl::SetMute(bool mute)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       ret = player_set_mute(__hPlayer, mute);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform player_set_mute operation with 0x%x", GetErrorMessage(r), ret);
+
+       __isMuted = mute;
+       return r;
+}
+
+result
+_PlayerImpl::SetLooping(bool looping)
+{
+       result r = E_SUCCESS;
+       int err = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       err = player_set_looping(__hPlayer, looping);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_set_looping operation with 0x%x", GetErrorMessage(r), err);
+       __isLooped = looping;
+CATCH:
+       return r;
+}
+
+
+result
+_PlayerImpl::SetRenderingBuffer(const Tizen::Graphics::BufferInfo& bufferInfo)
+{
+       result r = E_SUCCESS;
+       int err = PLAYER_ERROR_NONE;
+       const _BufferInfoImpl* pbufferInfoImpl = NULL;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       PlayerState checkPlayerState = GetState();
+       SysTryReturn(
+               NID_MEDIA, checkPlayerState == PLAYER_STATE_PLAYING || checkPlayerState == PLAYER_STATE_OPENED
+               || checkPlayerState == PLAYER_STATE_ENDOFCLIP || checkPlayerState == PLAYER_STATE_STOPPED
+               || checkPlayerState == PLAYER_STATE_PAUSED , E_INVALID_STATE, E_INVALID_STATE,
+               "[E_INVALID_STATE] Player state is in an invalid state.");
+
+       // Set the canvas to subsystem's player
+       pbufferInfoImpl = _BufferInfoImpl::GetInstance(bufferInfo);
+       SysTryCatch(NID_MEDIA, pbufferInfoImpl != NULL, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pbufferInfoImpl is not valid");
+       __orientation = (Orientation)(pbufferInfoImpl->GetOrientation());
+
+       // Set an available handler.
+       if (pbufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION))
+       {
+               __hCanvas = pbufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION);
+               __handleType = _BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION;
+       }
+       else if (pbufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE))
+       {
+               __hCanvas = pbufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE);
+               __handleType = _BufferInfoImpl::HANDLE_TYPE_VE_SURFACE;
+       }else
+       {
+               // handle is invalid
+               __hCanvas = 0;
+               __handleType = _BufferInfoImpl::HANDLE_TYPE_NONE;
+       }
+
+       SysTryCatch(NID_MEDIA, __hCanvas != 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. BufferInfo is not valid.");
+
+       if (__handleType != _BufferInfoImpl::HANDLE_TYPE_VE_SURFACE)
+       {
+               SysLog(NID_MEDIA, "PLAYER_DISPLAY_TYPE_X11");
+               err = player_set_display(__hPlayer, PLAYER_DISPLAY_TYPE_X11, (player_display_h) __hCanvas);
+       }else
+       {
+               SysLog(NID_MEDIA, "PLAYER_DISPLAY_TYPE_EVAS");
+               err = player_set_display(__hPlayer, PLAYER_DISPLAY_TYPE_EVAS, (player_display_h) __hCanvas);
+       }
+
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_set_display operation with 0x%x", GetErrorMessage(r), err);
+
+       err = player_set_display_mode(__hPlayer, PLAYER_DISPLAY_MODE_FULL_SCREEN);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "%s error has been occurred. Failed to perform player_set_display_mode operation with - 0x%x", GetErrorMessage(r), err);
+CATCH:
+       return r;
+}
+
+result
+_PlayerImpl::CaptureVideo(void)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+       bool playbackFlag = false;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       SysTryReturn(NID_MEDIA, __videoEventCreated == true , E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] Player state is in an invalid without the video event listener");
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x state - %d", GetErrorMessage(r), ret, __corePlayerCurState);
+       SysTryReturn(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_READY || __corePlayerCurState == ::PLAYER_STATE_PAUSED, E_INVALID_STATE, E_INVALID_STATE,
+                               "mmPlayer state is in an invalid state. Current state is %d", __corePlayerCurState);
+
+       __isStateChangeForVideoCapture = true;
+
+       ret = player_set_volume(__hPlayer,0.0,0.0);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_set_volume operation with - 0x%x", GetErrorMessage(r), ret);
+
+       ret = player_start(__hPlayer);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_start operation with - 0x%x", GetErrorMessage(r), ret);
+       playbackFlag = true;
+
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x ", GetErrorMessage(r), ret);
+       SysTryReturn(NID_MEDIA, (__corePlayerCurState == ::PLAYER_STATE_PLAYING),       E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] mmPlayer state is in an invalid state. Current state is %d", __corePlayerCurState);
+       SysLog(NID_MEDIA, "player_state is %d ", __corePlayerCurState);
+
+       ret = player_capture_video(__hPlayer, PlayerVideoCapturedCallBack, (void*)this);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform CaptureVideoInternal operation with 0x%x", GetErrorMessage(r), ret);
+       return r;
+CATCH:
+       if (playbackFlag)
+       {
+               ret = player_stop(__hPlayer);
+               r = MapExceptionToResult(ret);
+               SysTryLog(NID_MEDIA,r==E_SUCCESS, "[%s] Failed to perform player_stop operation with - 0x%x ", GetErrorMessage(r), ret);
+
+               r = SetVolume(__currentVolume);
+               SysTryLog(NID_MEDIA,r == E_SUCCESS, "[%s] Propagating ", GetErrorMessage(r));
+
+               playbackFlag = false;
+       }
+       __isStateChangeForVideoCapture = false;
+       SysLog(NID_MEDIA, "__isStateChangeForVideoCapture is %d",__isStateChangeForVideoCapture);
+       return r;
+}
+
+//Internal Functions
+
+void
+_PlayerImpl::SetSystemBitPerPixel(int PixelFormat)
+{
+       if (PixelFormat == _PLAYER_IMPL_VIDEO_PIXEL_SIZE_RGB565)
+       {
+               __videoPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
+       }
+       else
+       {
+               __videoPixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888;
+       }
+       return;
+}
+
+bool
+_PlayerImpl::SendEvent(_PlayerEventType eventType, int value)
+{
+       result r = E_SUCCESS;
+       if (eventType == _PLAYER_EVENT_BUFFERING )
+       {
+               _PlayerStreamingEventArg* pPlayerStreamingEventArg = new (std::nothrow) _PlayerStreamingEventArg;
+               if (pPlayerStreamingEventArg == null)
+               {
+                       return false;
+               }
+               pPlayerStreamingEventArg->SetEventType(_PLAYER_EVENT_BUFFERING);
+               pPlayerStreamingEventArg->SetPercent(value);
+
+
+               r = __pPlayerEvent->FireAsync(*pPlayerStreamingEventArg);
+               SysLog(NID_MEDIA, "eventType is %d in _PlayerImpl::SendEvent.", eventType);
+               if (IsFailed(r))
+               {
+                       delete pPlayerStreamingEventArg;
+                       return false;
+               }
+       }
+       else if (eventType == _PLAYER_EVENT_ERROR )
+       {
+               _PlayerErrorArg* pPlayerErrorArg = new (std::nothrow) _PlayerErrorArg;
+               if (pPlayerErrorArg == null)
+               {
+                       return false;
+               }
+               pPlayerErrorArg->SetEventType(_PLAYER_EVENT_ERROR);
+               pPlayerErrorArg->SetError((PlayerErrorReason) value);
+
+               r = __pPlayerEvent->FireAsync(*pPlayerErrorArg);
+               SysLog(NID_MEDIA, "eventType is %d in PlayInternaler::SendEvent.", eventType);
+               if (IsFailed(r))
+               {
+                       delete pPlayerErrorArg;
+                       return false;
+               }
+
+       }
+       else
+       {
+               _PlayerEventArg* pPlayerEventArg = new (std::nothrow) _PlayerEventArg;
+               if (pPlayerEventArg == null)
+               {
+                       return false;
+               }
+               pPlayerEventArg->SetEventType(eventType);
+               pPlayerEventArg->SetResult((result) value);
+
+               r = __pPlayerEvent->FireAsync(*pPlayerEventArg);
+               SysLog(NID_MEDIA, "eventType is %d in PlayInternaler::SendEvent.", eventType);
+               if (IsFailed(r))
+               {
+                       delete pPlayerEventArg;
+                       return false;
+               }
+       }
+       return true;
+}
+
+result
+_PlayerImpl::SendCapturedVideoFrame(_PlayerVideoEventType event, void* pStream, int streamSize, int width, int height, result r)
+{
+       result result = E_SUCCESS;
+       Tizen::Graphics::Dimension dimension(0, 0);
+       byte* pData = null;
+       _PlayerVideoEventArg* pPlayerVideoEventArg = new (std::nothrow) _PlayerVideoEventArg;
+       SysTryReturn(NID_MEDIA, pPlayerVideoEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. pPlayerVideoEventArg is null.");
+
+       if (event == _PLAYER_VIDEO_EVENT_DECODED)
+       {
+               dimension.width = width;
+               dimension.height = height;
+
+               pData = new (std::nothrow) byte[streamSize];
+               SysTryCatch(NID_MEDIA, pData != null, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. pData is null.");
+               memcpy(pData, pStream, streamSize);
+
+               pPlayerVideoEventArg->SetVideoEventType(_PLAYER_VIDEO_EVENT_DECODED);
+               pPlayerVideoEventArg->SetBuffer((byte*) pData);
+               pPlayerVideoEventArg->SetSizeOfBuffer((int) streamSize);
+               pPlayerVideoEventArg->SetDim(dimension);
+               pPlayerVideoEventArg->SetPixelFormat(__videoPixelFormat);
+               pPlayerVideoEventArg->SetResult(r);
+               result = __pPlayerVideoEvent->FireAsync(*pPlayerVideoEventArg);
+               SysTryCatch(NID_MEDIA, result == E_SUCCESS, , result, "[%s] Propagating", GetErrorMessage(r));
+       }
+       else if (event == _PLAYER_VIDEO_EVENT_ERROR )
+       {
+               pPlayerVideoEventArg->SetVideoEventType(_PLAYER_VIDEO_EVENT_ERROR);
+               pPlayerVideoEventArg->SetResult(r);
+               result = __pPlayerVideoEvent->FireAsync(*pPlayerVideoEventArg);
+               SysTryCatch(NID_MEDIA, result == E_SUCCESS, , result, "[%s] Propagating", GetErrorMessage(r));
+       }
+       else if (event == _PLAYER_VIDEO_EVENT_DECODED_WITHOUT_DATA )
+       {
+               pPlayerVideoEventArg->SetVideoEventType(_PLAYER_VIDEO_EVENT_DECODED_WITHOUT_DATA);
+               pPlayerVideoEventArg->SetResult(r);
+               result = __pPlayerVideoEvent->FireAsync(*pPlayerVideoEventArg);
+               SysTryCatch(NID_MEDIA, result == E_SUCCESS, , result, "[%s] Propagating", GetErrorMessage(r));
+       }
+       else
+       {
+               SysTryCatch(NID_MEDIA, false, , E_SYSTEM, "[E_SYSTEM] A system error has been occured.");
+       }
+       return E_SUCCESS;
+CATCH:
+       if (pData)
+       {
+               delete[] pData;
+               pData = null;
+       }
+       if (pPlayerVideoEventArg)
+       {
+               delete pPlayerVideoEventArg;
+               pPlayerVideoEventArg = null;
+       }
+       return result;
+}
+
+
+//Tizen Calls
+result
+_PlayerImpl::CreatePlayerAndSetCallBack(void)
+{
+       result r = E_SUCCESS;
+       int err = PLAYER_ERROR_NONE;
+
+       err = player_create(&__hPlayer);
+       r = MapExceptionToResult(err);
+
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "player_create failed");
+
+       err = player_set_completed_cb(__hPlayer, PlayerCompletedCallBack, (void *)this);
+       SysTryCatch(NID_MEDIA, err == PLAYER_ERROR_NONE, r = E_SYSTEM,E_SYSTEM,
+                                                               "[E_SYSTEM] A system error has been occurred. Failed to perform player_set_completed_cb operation.");
+
+       err = player_set_interrupted_cb(__hPlayer, PlayerInterruptedCallBack, (void *)this);
+       SysTryCatch(NID_MEDIA, err == PLAYER_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[E_SYSTEM] A system error has been occurred. Failed to perform player_set_interrupted_cb operation.");
+
+       err = player_set_error_cb(__hPlayer, PlayerErrorCallBack, (void *)this);
+       SysTryCatch(NID_MEDIA, err == PLAYER_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[E_SYSTEM] A system error has been occurred. Failed to perform player_set_error_cb operation.");
+
+       if (__videoEventCreated)
+       {
+               err = player_set_video_frame_decoded_cb(__hPlayer, PlayerVideoFrameDecodedCallBack, (void *)this);
+               SysTryCatch(NID_MEDIA, err == PLAYER_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                               "[E_SYSTEM] A system error has been occurred. Failed to perform player_video_frame_decoded_cb operation");
+       }
+       return E_SUCCESS;
+CATCH:
+       player_destroy(__hPlayer);
+       return r;
+}
+
+//Tizen->Osp Error Code conversion
+PlayerErrorReason
+_PlayerImpl::MapExceptionToPlayerErrorReason(int reason)
+{
+       //All the fall through are intentional
+       switch (reason)
+       {
+       //Successful
+       case PLAYER_ERROR_NONE:
+               return PLAYER_ERROR_NONE;
+               break;
+
+       //Out of memory
+       case PLAYER_ERROR_OUT_OF_MEMORY:
+               return PLAYER_ERROR_OUT_OF_MEMORY;
+               break;
+
+       //Invalid parameter
+       case PLAYER_ERROR_INVALID_PARAMETER:
+       //fall through
+       //Invalid URI
+       case PLAYER_ERROR_INVALID_URI:
+       //fall through
+       //Not supported file format
+       case PLAYER_ERROR_NOT_SUPPORTED_FILE:
+       //fall through
+       //No such file or directory
+       case PLAYER_ERROR_NO_SUCH_FILE:
+               return PLAYER_ERROR_INVALID_DATA;
+               break;
+
+       //Streaming connection failed
+       case PLAYER_ERROR_CONNECTION_FAILED:
+               return PLAYER_ERROR_STREAMING_TIMEOUT;
+               break;
+
+       //Sound policy error
+       case PLAYER_ERROR_SOUND_POLICY:
+       //fall through
+       //Video capture failure
+       case PLAYER_ERROR_VIDEO_CAPTURE_FAILED:
+       //fall through
+       //Invalid operation
+       case PLAYER_ERROR_INVALID_OPERATION:
+       //fall through
+       //Seek operation failure
+       case PLAYER_ERROR_SEEK_FAILED:
+       //fall through
+       //Invalid state
+       case PLAYER_ERROR_INVALID_STATE:
+       //fall through
+       default:
+               return PLAYER_ERROR_DEVICE_FAILED;
+               break;
+       }
+}
+
+result
+_PlayerImpl::MapExceptionToResult(int reason)
+{
+       //All the fall through are intentional
+       switch (reason)
+       {
+       //Successful
+       case PLAYER_ERROR_NONE:
+               return E_SUCCESS;
+               break;
+       //Out of memory
+       case PLAYER_ERROR_OUT_OF_MEMORY:
+               return E_OUT_OF_MEMORY;
+               break;
+       //Invalid parameter
+       case PLAYER_ERROR_INVALID_PARAMETER:
+               return E_INVALID_ARG;
+               break;
+       //No such file or directory
+       case PLAYER_ERROR_NO_SUCH_FILE:
+               return E_FILE_NOT_FOUND;
+               break;
+       //Invalid operation
+       case PLAYER_ERROR_INVALID_OPERATION:
+               return E_INVALID_OPERATION;
+               break;
+       //Invalid state
+       case PLAYER_ERROR_INVALID_STATE:
+               return E_INVALID_STATE;
+               break;
+       //Not supported file format
+       case PLAYER_ERROR_NOT_SUPPORTED_FILE:
+               return E_UNSUPPORTED_FORMAT;
+               break;
+       //Invalid URI
+       case PLAYER_ERROR_INVALID_URI:
+               return E_FILE_NOT_FOUND;
+               break;
+       //Sound policy error
+       case PLAYER_ERROR_SOUND_POLICY:
+               return E_DEVICE_BUSY;
+               break;
+       //Streaming connection failed
+       case PLAYER_ERROR_CONNECTION_FAILED:
+               return E_CONNECTION_FAILED;
+               break;
+
+       //Seek operation failure
+       case PLAYER_ERROR_SEEK_FAILED:
+       //fall through
+       //Video capture failure
+       case PLAYER_ERROR_VIDEO_CAPTURE_FAILED:
+               return E_OPERATION_FAILED;
+               break;
+       default:
+               return E_SYSTEM;
+               break;
+       }
+}
+
+//Tizen Callbacks
+void
+_PlayerImpl::PlayerPreparedCallBack(void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       pPlyarImpl->HandlePlayerPrepared();
+}
+
+void
+_PlayerImpl::PlayerCompletedCallBack(void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       pPlyarImpl->HandlePlayerCompleted();
+}
+
+void
+_PlayerImpl::PlayerInterruptedCallBack(player_interrupted_code_e code, void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       switch (code)
+       {
+       case PLAYER_INTERRUPTED_COMPLETED:
+               // Interrupt completed
+               if (!(pPlyarImpl->__interruptFlag))
+               {
+                       pPlyarImpl->HandlePlayerReleased();
+               }
+               pPlyarImpl->__interruptFlag = false;
+               break;
+       case PLAYER_INTERRUPTED_BY_CALL:
+               //Interrupted by incoming call
+               //Intentional fall through
+               pPlyarImpl->__interruptFlag = true;
+       case PLAYER_INTERRUPTED_BY_MEDIA:
+               //Interrupted by another application
+               //Intentional fall through
+       case PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT:
+               //Interrupted by resource conflict
+               //Intentional fall through
+       case PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG:
+               //Interrupted by earjack unplug
+               pPlyarImpl->HandlePlayerAudioFoucsChanged();
+               break;
+       case PLAYER_INTERRUPTED_BY_EMERGENCY:
+               //Interrupted by emergency
+               //Intentional fall through
+       case PLAYER_INTERRUPTED_BY_ALARM:
+               //Interrupted by alarm
+               pPlyarImpl->HandlePlayerInterrupted();
+               break;
+       default:
+               SysLog(NID_MEDIA, "Player interrupt is not set.");
+               break;
+       }
+}
+void
+_PlayerImpl::PlayerErrorCallBack(int errorCode, void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       pPlyarImpl->HandlePlayerError(errorCode);
+}
+void
+_PlayerImpl::PlayerBufferingCallBack(int percent, void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       SysTryReturn(NID_MEDIA, percent >= 0 && percent <= 100, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. percent (%d) is out of range- %d",percent);
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       pPlyarImpl->HandlePlayerBuffering(percent);
+}
+void
+_PlayerImpl::PlayerSubtitleUpdatedCallBack(unsigned long duration, char *pText, void *pUserData)
+{
+       SysLog(NID_MEDIA, "PlayerSubtitleUpdatedCallBack has started.");
+}
+void
+_PlayerImpl::PlayerVideoCapturedCallBack(unsigned char *pData, int width, int height, unsigned int size, void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       SysTryReturn(NID_MEDIA, pData, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. pData is null.");
+       SysTryReturn(NID_MEDIA, width && height && size, , E_INVALID_ARG,
+                                       "[E_INVALID_ARG] Invalid argument is used. hieght = %d or width = %d size = %d", width, height, size);
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       pPlyarImpl->HandlePlayerVideoCaptured(pData, width , height, size);
+}
+void
+_PlayerImpl::PlayerVideoFrameDecodedCallBack(unsigned char *pData, int width, int height, unsigned int size, void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       SysTryReturn(NID_MEDIA, pData, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. pData is null.");
+       SysTryReturn(NID_MEDIA, width && height && size, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. height = %d width = %d size = %d", width, height, size);
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       pPlyarImpl->HandlePlayerVideoFrameDecoded(pData, width , height, size);
+}
+void
+_PlayerImpl::PlayerAudioFrameDecodedCallBack(unsigned char *pData, unsigned int size, void *pUserData)
+{
+}
+
+void
+_PlayerImpl::PlayerSeekCompletedCallBack(void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       pPlyarImpl->HandlePlayerSeekCompleted();
+}
+
+//Tizen Handle Functions
+void
+_PlayerImpl::HandlePlayerPrepared(void)
+{
+       int err = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+
+       err = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), err);
+       SysTryReturn(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_READY , , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Current state is %d.", __corePlayerCurState);
+
+       __currentState = PLAYER_STATE_OPENED;
+       SendEvent(_PLAYER_EVENT_OPENED, 0);
+}
+
+void
+_PlayerImpl::HandlePlayerCompleted(void)
+{
+       player_stop(__hPlayer);
+       __currentState = PLAYER_STATE_ENDOFCLIP;
+       SendEvent(_PLAYER_EVENT_ENDOFCLIP, 0);
+}
+
+void
+_PlayerImpl::HandlePlayerError(int errorCode)
+{
+       __currentState = PLAYER_STATE_ERROR;
+       SendEvent(_PLAYER_EVENT_ERROR, MapExceptionToPlayerErrorReason(errorCode));
+}
+
+void
+_PlayerImpl::HandlePlayerBuffering(int percent)
+{
+       SendEvent(_PLAYER_EVENT_BUFFERING, percent);
+}
+
+void
+_PlayerImpl::HandlePlayerVideoCaptured(unsigned char *pData, int width, int height, unsigned int size)
+{
+       SysLog(NID_MEDIA, "The current value of width is %d ", width);
+       SysLog(NID_MEDIA, "The current value of height is %d", height);
+       SysLog(NID_MEDIA, "The current value of size is %d", size);
+
+       result r = E_SUCCESS;
+       std::unique_ptr<byte[]> pOputPtr;
+       int streamSize = 0;
+       int err = PLAYER_ERROR_NONE;
+
+       err = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(err);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), err);
+
+       if (__corePlayerCurState == ::PLAYER_STATE_PLAYING)
+       {
+               err = player_pause(__hPlayer);
+               r = MapExceptionToResult(err);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_pause operation with - 0x%x", GetErrorMessage(r), err);
+
+               err = player_get_state(__hPlayer, &__corePlayerCurState);
+               r = MapExceptionToResult(err);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with - 0x%x", GetErrorMessage(r), err);
+       }
+
+       SysTryCatch(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_PAUSED, r = E_INVALID_STATE, E_INVALID_STATE,
+                                                       "[E_INVALID_STATE] Player state is in an invalid state. Current state is %d", __corePlayerCurState);
+
+
+       SysTryCatch(NID_MEDIA, !((width == 0) || (height == 0)), r = E_INVALID_DATA, E_INVALID_DATA,
+                       ("[E_INVALID_DATA] A error has been occurred. width or height size is wrong !"));
+
+       //send frame to video event listenner
+       if (pData != null)
+       {
+               MediaPixelFormat srcFmt = MEDIA_PIXEL_FORMAT_RGB888;
+               unsigned int frameSize = width*height*4;
+               if (frameSize == size)
+               {
+                       srcFmt = MEDIA_PIXEL_FORMAT_BGRA8888;
+               }
+
+               if (__videoPixelFormat == BITMAP_PIXEL_FORMAT_RGB565 )
+               {
+                       _ColorConverter cvt;
+                       // Converter construction
+                       r = cvt.Construct(srcFmt, width, height,
+                                               MEDIA_PIXEL_FORMAT_RGB565LE, width, height);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       // Convert to output format
+                       pOputPtr.reset(cvt.ConvertN((byte *)pData, size, streamSize));
+                       r = GetLastResult();
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else
+               {
+                       _ColorConverter cvt;
+                       r = cvt.Construct(srcFmt, width, height,
+                                               MEDIA_PIXEL_FORMAT_BGRA8888, width, height);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       // Convert to output format
+                       pOputPtr.reset(cvt.ConvertN((byte *)pData, size, streamSize));
+                       r = GetLastResult();
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               SysTryCatch(NID_MEDIA, pOputPtr.get(), r = E_INVALID_DATA, E_INVALID_DATA, "[E_INVALID_DATA] A error has been occurred. pOputPtr is null.");
+               r = SendCapturedVideoFrame( _PLAYER_VIDEO_EVENT_DECODED, pOputPtr.get(), streamSize, width, height, E_SUCCESS);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s]Propagating", GetErrorMessage(r));
+       }
+       else
+       {
+               r = SendCapturedVideoFrame( _PLAYER_VIDEO_EVENT_DECODED_WITHOUT_DATA, pData, size, width, height, E_SUCCESS);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s]Propagating", GetErrorMessage(r));
+       }
+       __currentState = PLAYER_STATE_PAUSED;
+       return;
+CATCH:
+       __isStateChangeForVideoCapture = false;
+       SysLog(NID_MEDIA, "__isStateChangeForVideoCapture is %d",__isStateChangeForVideoCapture);
+       return;
+}
+void
+_PlayerImpl::HandlePlayerVideoFrameDecoded(unsigned char *pData, int width, int height, unsigned int size)
+{
+       SysLog(NID_MEDIA, "The current value of width is %d ", width);
+       SysLog(NID_MEDIA, "The current value of height is %d", height);
+       SysLog(NID_MEDIA, "The current value of size is %d", size);
+
+       result r = E_SUCCESS;
+       if (__isStateChangeForVideoCapture)
+       {
+               // caused by PlayerVideoCapturedCallBack()
+               SysLog(NID_MEDIA, "Skip HandlePlayerVideoFrameDecoded()");
+               return;
+       }
+       if (pData)
+       {
+               r = SendCapturedVideoFrame( _PLAYER_VIDEO_EVENT_DECODED, pData, size, width, height, E_SUCCESS);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s]Propagating", GetErrorMessage(r));
+       }
+       else
+       {
+               SendCapturedVideoFrame( _PLAYER_VIDEO_EVENT_DECODED_WITHOUT_DATA, pData, size, width, height, E_SUCCESS);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s]Propagating", GetErrorMessage(r));
+       }
+
+CATCH:
+       return;
+}
+
+void
+_PlayerImpl::HandlePlayerSeekCompleted(void)
+{
+       int err = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+
+       if (__pPlayerVideoEvent)
+       {
+               SysLog(NID_MEDIA, "CaptureStatus is %d", __isStateChangeForVideoCapture);
+
+               if (__isStateChangeForVideoCapture)
+               {
+                       err = player_capture_video(__hPlayer, PlayerVideoCapturedCallBack, (void*)this);
+                       r = MapExceptionToResult(err);
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_capture_video operation with 0x%x", GetErrorMessage(r), err);
+               }
+
+       }
+       SendEvent(_PLAYER_EVENT_SEEKTO, 0);
+}
+
+void
+_PlayerImpl::HandlePlayerInterrupted(void)
+{
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysLog(NID_MEDIA, "[%s] Player state is %d", GetErrorMessage(r), __corePlayerCurState);
+       if (__corePlayerCurState == ::PLAYER_STATE_PAUSED)
+       {
+               SysLog(NID_MEDIA, "Setting player state to be paused");
+               __currentState = PLAYER_STATE_PAUSED;
+               SendEvent(_PLAYER_EVENT_INTERRUPTED, 0);
+       }
+       else if (__corePlayerCurState == ::PLAYER_STATE_IDLE)
+       {
+               SysLog(NID_MEDIA, "Setting player state to be Closed");
+               __currentState = PLAYER_STATE_CLOSED;
+               __isStreamingContent = false;
+               __isOpenBuffer = false;
+               __bufferDataSize = 0;
+
+               SendEvent(_PLAYER_EVENT_INTERRUPTED, 0);
+       }
+       else
+       {
+               SysLog(NID_MEDIA, "player state is %d so sending error", __currentState);
+               ret = player_stop(__hPlayer);
+               r = MapExceptionToResult(ret);
+               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+               ret = player_unprepare(__hPlayer);
+               r = MapExceptionToResult(ret);
+               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+               __isStreamingContent = false;
+               __isOpenBuffer = false;
+               __bufferDataSize = 0;
+
+               __currentState = PLAYER_STATE_ERROR;
+               SendEvent(_PLAYER_EVENT_ERROR, PLAYER_ERROR_DEVICE_FAILED);
+       }
+}
+
+void
+_PlayerImpl::HandlePlayerAudioFoucsChanged(void)
+{
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysLog(NID_MEDIA, "[%s] Player state is - %d", GetErrorMessage(r), __corePlayerCurState);
+       if (__corePlayerCurState == ::PLAYER_STATE_PAUSED)
+       {
+               SysLog(NID_MEDIA, "Setting player state to be paused");
+               __currentState = PLAYER_STATE_PAUSED;
+               SendEvent(_PLAYER_EVENT_AUDIO_FOCUS_CHANGED, 0);
+       }
+       else if (__corePlayerCurState == ::PLAYER_STATE_IDLE)
+       {
+               SysLog(NID_MEDIA, "Setting player state to be Closed");
+               __currentState = PLAYER_STATE_CLOSED;
+               __isStreamingContent = false;
+               __isOpenBuffer = false;
+               __bufferDataSize = 0;
+
+               SendEvent(_PLAYER_EVENT_AUDIO_FOCUS_CHANGED, 0);
+       }
+       else
+       {
+               SysLog(NID_MEDIA, "player state is %d so sending error", __currentState);
+               ret = player_stop(__hPlayer);
+               r = MapExceptionToResult(ret);
+               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+               ret = player_unprepare(__hPlayer);
+               r = MapExceptionToResult(ret);
+               SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
+               __isStreamingContent = false;
+               __isOpenBuffer = false;
+               __bufferDataSize = 0;
+
+               __currentState = PLAYER_STATE_ERROR;
+               SendEvent(_PLAYER_EVENT_ERROR, PLAYER_ERROR_DEVICE_FAILED);
+       }
+}
+
+void
+_PlayerImpl::HandlePlayerReleased(void)
+{
+       SendEvent(_PLAYER_EVENT_RELEASED, 0);
+}
+
+CodecType
+_PlayerImpl::ConvertAudioCodec(char *pAudioCodec)
+{
+       if (!String::Compare(String(pAudioCodec), String("MPEG 1 Audio, Layer 3 (MP3)")))
+       {
+               return CODEC_MP3;
+       }
+       if (!String::Compare(String(pAudioCodec), String("MPEG 3 Audio, Layer 3 (MP3)")))
+       {
+               return CODEC_MP3;
+       }
+       if (!String::Compare(String(pAudioCodec),String("AAC")))
+       {
+               return CODEC_AAC;
+       }
+       if (!String::Compare(String(pAudioCodec),String("MPEG-4 AAC audio")))
+       {
+               return CODEC_AAC;
+       }
+       if (!String::Compare(String(pAudioCodec), String("Adaptive Multi Rate (AMR)")))
+       {
+               return CODEC_AMR_NB;
+       }
+       if (!String::Compare(String(pAudioCodec), String("WMA")))
+       {
+               return CODEC_WMA;
+       }
+       if (!String::Compare(String(pAudioCodec), String("WMA Version 8")))
+       {
+               return CODEC_WMA;
+       }
+       if (!String::Compare(String(pAudioCodec), String("Uncompressed 16-bit PCM audio")))
+       {
+               return CODEC_LPCM;
+       }
+       if (!String::Compare(String(pAudioCodec), String("MIDI")))
+       {
+               return CODEC_MIDI;
+       }
+       return CODEC_UNKNOWN;
+}
+
+CodecType
+_PlayerImpl::ConvertVideoCodec(char *pVideoCodec)
+{
+       if (!String::Compare(String(pVideoCodec),String( "H263")))
+       {
+               return CODEC_H263;
+       }
+       if (!String::Compare(String(pVideoCodec),String( "H.263")))
+       {
+               return CODEC_H263;
+       }
+       if (!String::Compare(String(pVideoCodec), String("MPEG-4 video")))
+       {
+               return CODEC_MPEG4;
+       }
+       if (!String::Compare(String(pVideoCodec),String( "H.264 / AVC")))
+       {
+               return CODEC_H264;
+       }
+       if (!String::Compare(String(pVideoCodec),String( "Microsoft Windows Media 9")))
+       {
+               return CODEC_WMV;
+       }
+       if (!String::Compare(String(pVideoCodec),String( "THEORA")))
+       {
+               return CODEC_THEORA;
+       }
+       return CODEC_UNKNOWN;
+}
+
+
+MediaStreamInfo*
+_PlayerImpl::GetCurrentMediaStreamInfoN()
+{
+       result r = E_SUCCESS;
+       int err = PLAYER_ERROR_NONE;
+       MediaStreamInfo* pMediaStreamInfo = null;
+       Tizen::Base::Collection::IList* pAudioList = null;
+       Tizen::Base::Collection::IList* pVideoList = null;
+       AudioStreamInfo* pAudioStream = null;
+       VideoStreamInfo* pVideoStream = null;
+       result audioStreamException = E_SUCCESS;
+       result videoStreamException = E_SUCCESS;
+       String strArtist;
+       String strTitle;
+       String strAlbum;
+       String strGenre;
+       String strAuthor;
+       int year = 0;
+       char *pToCollect = null;
+       int sizeArtWork = 0;
+
+       ByteBuffer* pImageByteBuffer = null;
+       char* pAudioCodec = null;
+       char* pVideoCodec = null;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       err = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with 0x%x ", GetErrorMessage(r), err);
+
+       SysTryCatch(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_PLAYING || __corePlayerCurState == ::PLAYER_STATE_PAUSED ,
+                          r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. Current state is %d", __corePlayerCurState);
+
+       err = player_get_codec_info(__hPlayer, &pAudioCodec, &pVideoCodec);
+       SysTryCatch(NID_MEDIA, err == PLAYER_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                                       "[E_SYSTEM] A system error has been occurred. Failed to perform player_get_codec_info operation with 0x%x", err);
+
+       pAudioList = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+       if (pAudioList && String::Compare(String(pAudioCodec),(String("unknown"))))
+       {
+               SysLog(NID_MEDIA, "Audio Codec is %s",pAudioCodec);
+               AudioChannelType channel = AUDIO_CHANNEL_TYPE_NONE;
+               CodecType codec = CODEC_UNKNOWN;
+               int bitrate = 0;
+               int samplingRate = 0;
+               int channels = 0;
+               err = player_get_audio_stream_info(__hPlayer, &samplingRate, &channels, &bitrate);
+               if (err != PLAYER_ERROR_NONE)
+               {
+                       SysTryLog(NID_MEDIA, false, "Failed to perform player_get_audio_stream_info operation with 0x%x", err);
+               }
+               else
+               {
+                       if (channels == 1 )
+                       {
+                               channel = AUDIO_CHANNEL_TYPE_MONO;
+                       }
+                       else if (channels == 2 )
+                       {
+                               channel = AUDIO_CHANNEL_TYPE_STEREO;
+                       }
+                       //Reserved for Audio CodecCodec
+                       codec = ConvertAudioCodec(pAudioCodec);
+                       SysLog(NID_MEDIA, "Channel is %d , bitrate is %d , sampling rate is %d, Codec is %d.",channel, bitrate, samplingRate, codec);
+                       pAudioStream = new (std::nothrow) Tizen::Media::AudioStreamInfo(codec, bitrate, samplingRate, channel);
+                       pAudioList->Add(*pAudioStream);
+               }
+       }
+       if (pAudioCodec)
+       {
+               free(pAudioCodec);
+       }
+
+       pVideoList = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+       if (pVideoList && *pVideoCodec != '\0')
+       {
+               CodecType codec = CODEC_UNKNOWN;
+               int width = 0;
+               int height = 0;
+               int bitrate = 0;
+               int frameRate = 0;
+               SysLog(NID_MEDIA, "Video Codec is %s",pVideoCodec);
+
+               err = player_get_video_size(__hPlayer, &width, &height);
+               if (err != PLAYER_ERROR_NONE)
+               {
+                       SysTryLog(NID_MEDIA, false, "Failed to perform player_get_video_size operation with 0x%x", err);
+               }
+               else
+               {
+                       err = player_get_video_stream_info(__hPlayer, &frameRate, &bitrate);
+                       if (err != PLAYER_ERROR_NONE)
+                       {
+                               SysTryLog(NID_MEDIA, false, "Failed to perform player_get_video_stream_info operation with 0x%x", err);
+                       }
+                       else
+                       {
+                               codec = ConvertVideoCodec(pVideoCodec);
+                               SysLog(NID_MEDIA, "bitrate is %d, frame rate is %d, width is %d, height is %d, Codec is %d ",bitrate, frameRate, width, height, codec);
+                               float frameRateFloat = frameRate * 1.0;
+                               pVideoStream = new (std::nothrow) Tizen::Media::VideoStreamInfo(codec, width, height, bitrate, frameRateFloat);
+                               pVideoList->Add(*pVideoStream);
+                       }
+               }
+       }
+       if (pVideoCodec)
+       {
+               free(pVideoCodec);
+       }
+
+       //Obtain the Tag info
+       err = player_get_content_info(__hPlayer, PLAYER_CONTENT_INFO_ARTIST, &pToCollect);
+       if (err != PLAYER_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "Failed to perform player_get_content_info operation with 0x%x", err);
+       }
+       else if (pToCollect)
+       {
+               SysTryLog(NID_MEDIA, false, "Artist is %s ", pToCollect);
+               strArtist.Append(pToCollect);
+               free(pToCollect);
+               pToCollect = null;
+       }
+       err = player_get_content_info(__hPlayer, PLAYER_CONTENT_INFO_TITLE, &pToCollect);
+       if (err != PLAYER_ERROR_NONE)
+       {
+               SysTryLog(NID_MEDIA, false, "Failed to perform player_get_content_info operation with 0x%x", err);
+       }
+       else if (pToCollect)
+       {
+               SysLog(NID_MEDIA, "Title is %s ", pToCollect);
+               strTitle.Append(pToCollect);
+               free(pToCollect);
+               pToCollect = null;
+       }
+       err = player_get_content_info(__hPlayer, PLAYER_CONTENT_INFO_ALBUM, &pToCollect);
+       if (err != PLAYER_ERROR_NONE)
+       {
+               SysTryLog(NID_MEDIA, false, "Failed to perform player_get_content_info operation with 0x%x", err);
+       }
+       else if (pToCollect)
+       {
+               SysLog(NID_MEDIA, "Album is %s ", pToCollect);
+               strAlbum.Append(pToCollect);
+               free(pToCollect);
+               pToCollect = null;
+       }
+       err = player_get_content_info(__hPlayer, PLAYER_CONTENT_INFO_GENRE, &pToCollect);
+       if (err != PLAYER_ERROR_NONE)
+       {
+               SysTryLog(NID_MEDIA, false, "Failed to perform player_get_content_info operation with 0x%x", err);
+       }
+       else if (pToCollect)
+       {
+               SysLog(NID_MEDIA, "Genre is %s ", pToCollect);
+               strGenre.Append(pToCollect);
+               free(pToCollect);
+               pToCollect = null;
+       }
+       err = player_get_content_info(__hPlayer, PLAYER_CONTENT_INFO_AUTHOR, &pToCollect);
+       if (err != PLAYER_ERROR_NONE)
+       {
+               SysTryLog(NID_MEDIA, false, "Failed to perform player_get_content_info operation with 0x%x", err);
+       }
+       else if (pToCollect)
+       {
+               SysLog(NID_MEDIA, "Author is %s ", pToCollect);
+               strAuthor.Append(pToCollect);
+               free(pToCollect);
+               pToCollect = null;
+       }
+       err = player_get_content_info(__hPlayer, PLAYER_CONTENT_INFO_YEAR, &pToCollect);
+       if (err != PLAYER_ERROR_NONE)
+       {
+               SysTryLog(NID_MEDIA, false, "Failed to perform player_get_content_info operation with 0x%x", err);
+       }
+       else if (pToCollect)
+       {
+               year = atoi(pToCollect);
+               SysLog(NID_MEDIA, "Year is %d ", year);
+               free(pToCollect);
+               pToCollect = null;
+       }
+       //Artwork
+       err = player_get_album_art(__hPlayer, (void **)&pToCollect, &sizeArtWork);
+       if (err != PLAYER_ERROR_NONE)
+       {
+               SysTryLog(NID_MEDIA, false, "Failed to perform player_get_album_art operation with 0x%x", err);
+       }
+       else if (pToCollect && sizeArtWork > 0)
+       {
+               SysLog(NID_MEDIA, "there is art work so packing that in bytebuffer size of the ArtWork is %d", sizeArtWork);
+               pImageByteBuffer = new (std::nothrow) ByteBuffer;
+               if (pImageByteBuffer)
+               {
+                       pImageByteBuffer->Construct(sizeArtWork);
+                       pImageByteBuffer->SetArray((const byte *) pToCollect, 0, sizeArtWork);
+                       pImageByteBuffer->Flip();
+               }
+       }
+
+       pMediaStreamInfo = new (std::nothrow) MediaStreamInfo(strTitle, strArtist, strAlbum,
+                                                       strGenre, year, pImageByteBuffer,
+                                                       pAudioList, pVideoList, audioStreamException, videoStreamException);
+
+       SetLastResult(r);
+       return pMediaStreamInfo;
+CATCH:
+       if (pAudioCodec)
+       {
+               free(pAudioCodec);
+       }
+       if (pVideoCodec)
+       {
+               free(pVideoCodec);
+       }
+       return null;
+}
+
+result
+_PlayerImpl::SetAudioStreamType(AudioStreamType type)
+{
+       result r = E_SUCCESS;
+       int ret = PLAYER_ERROR_NONE;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+
+       ret = player_set_sound_type(__hPlayer, _AudioManagerConvert::ConvertAudioStreamType2SoundType(type));
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_set_sound_type operation with 0x%x", GetErrorMessage(r), ret);
+       return E_SUCCESS;
+CATCH:
+       return r;
+}
+
+result
+_PlayerImpl::OpenUrlAsync(const Tizen::Base::String& url, const Tizen::Base::Collection::IMap* pHeader)
+{
+       result r = E_SUCCESS;
+
+       int err = PLAYER_ERROR_NONE;
+       Tizen::Base::Utility::Uri mediaUri;
+       Tizen::Base::String scheme;
+       bool containsCookie = false;
+       bool containsUserAgent = false;
+       std::unique_ptr<const String> pCookieValue;
+       std::unique_ptr<const String> pUserAgentValue;
+       std::unique_ptr<char[]> pCookieChars;
+       std::unique_ptr<char[]> pUsetAgentChars;
+       std::unique_ptr<char[]> pInputFilePath;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       
+       err = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_getstate operation with - 0x%x", GetErrorMessage(r), err);
+
+       SysTryReturn(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_IDLE,
+                E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. returned state is %d", __corePlayerCurState);
+
+       SysTryReturn(NID_MEDIA, !url.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Input url is empty");
+
+       mediaUri.SetUri(url);
+       scheme = mediaUri.GetScheme();
+       SysTryCatch(NID_MEDIA, scheme.Equals(L"http", false), r = E_UNSUPPORTED_PROTOCOL,
+               E_UNSUPPORTED_PROTOCOL, "[E_UNSUPPORTED_PROTOCOL] scheme is Unsupported protocol");
+
+       if (pHeader)
+       {
+               const HashMap *pMapHeader = dynamic_cast<const HashMap *>(pHeader);
+               SysTryCatch(NID_MEDIA, pMapHeader != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.");
+               pMapHeader->ContainsKey(String("Cookie"), containsCookie);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_MEDIA, r, "[%s] Failed to perform HashMap::ContainsKey operation", GetErrorMessage(r));
+               }
+               else if (containsCookie)
+               {
+                       pCookieValue.reset(dynamic_cast<const String *>(pMapHeader->GetValue(String("Cookie"))));
+                       if (pCookieValue)
+                       {
+                               pCookieChars.reset(_StringConverter::CopyToCharArrayN(*(pCookieValue.get())));
+                               if (pCookieChars.get())
+                               {
+                                       err = player_set_streaming_cookie(__hPlayer, pCookieChars.get(),pCookieValue->GetLength());
+                               }
+                       }
+                       else
+                       {
+                               r = GetLastResult();
+                               SysLogException(NID_MEDIA, r, "[%s]Failed to perform HashMap::GetValue(Cookie) operation.", GetErrorMessage(r));
+                       }
+               }
+               pMapHeader->ContainsKey(String("User-Agent"), containsUserAgent);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_MEDIA, r, "[%s]Failed to perform HashMap::ContainsKey operation.", GetErrorMessage(r));
+               }
+               else if (containsUserAgent)
+               {
+                       pUserAgentValue.reset(dynamic_cast<const String *>(pMapHeader->GetValue(String("User-Agent"))));
+                       if (pUserAgentValue.get())
+                       {
+                               pUsetAgentChars.reset(_StringConverter::CopyToCharArrayN(*(pUserAgentValue.get())));
+                               err = player_set_streaming_cookie(__hPlayer, pUsetAgentChars.get(),pUserAgentValue->GetLength());
+                       }
+                       else
+                       {
+                               r = GetLastResult();
+                               SysLogException(NID_MEDIA, r, "[%s] Failed to perform HashMap::GetValue(User-Agent) operation.", GetErrorMessage(r));
+                       }
+               }
+       }
+
+       pInputFilePath.reset(_StringConverter::CopyToCharArrayN(url));
+       __isAsync = true;
+       __isStreamingContent = true;
+       __currentState = PLAYER_STATE_OPENING;
+
+       r = OpenInputData(std::move(pInputFilePath));
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform OpenInputData operation.", GetErrorMessage(r));
+
+       return r;
+CATCH:
+       __isStreamingContent = false;
+       __currentState = PLAYER_STATE_INITIALIZED;
+       return r;
+}
+
+void
+_PlayerImpl::PlayerPdMessageCallBack(player_pd_message_type_e type, void* pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occured. pUserData is NULL!!");
+       _PlayerImpl *pPlyarImpl = (_PlayerImpl *)pUserData;
+       pPlyarImpl->HandlePdMessageCallBack(type);
+}
+
+result
+_PlayerImpl::HandlePdMessageCallBack(player_pd_message_type_e type)
+{
+       result r = E_SUCCESS;
+       SysTryReturn(NID_MEDIA, __pPlayerProgressiveDownloadEvent != null, E_SYSTEM, E_SYSTEM,
+               "[E_SYSTEM] A system error has been occurred. PlayerProgressiveEvent is null.");
+       _PlayerProgressiveDownloadEventArg* pPlayerProgressiveDownloadEventArg = null;
+       pPlayerProgressiveDownloadEventArg = new (std::nothrow) _PlayerProgressiveDownloadEventArg;
+       SysTryCatch(NID_MEDIA, __pPlayerProgressiveDownloadEvent != null , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       switch (type)
+       {
+       case PLAYER_PD_STARTED:
+               SysLog(NID_MEDIA, "Type is set to PLAYER_PD_STARTED");
+               pPlayerProgressiveDownloadEventArg->SetEventType(PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_STARTED);
+               r = __pPlayerProgressiveDownloadEvent->FireAsync(*pPlayerProgressiveDownloadEventArg);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+       case PLAYER_PD_COMPLETED:
+               SysLog(NID_MEDIA, "Type is set to PLAYER_PD_COMPLETED");
+
+               if (__pPdTimer)
+               {
+                       __pPdTimer->Cancel();
+                       __isProgressiveTimerStarted = false;
+               }
+               pPlayerProgressiveDownloadEventArg->SetEventType(PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_COMPLETED);
+               pPlayerProgressiveDownloadEventArg->SetResult(E_SUCCESS);
+               r = __pPlayerProgressiveDownloadEvent->FireAsync(*pPlayerProgressiveDownloadEventArg);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+       default:
+               SysLogException(NID_MEDIA, E_SYSTEM, "A system error has been occurred. Never come here player_pd_message is wrong -%d", type);
+               break;
+       }
+
+       return E_SUCCESS;
+CATCH:
+       if (pPlayerProgressiveDownloadEventArg)
+       {
+               delete pPlayerProgressiveDownloadEventArg;
+               pPlayerProgressiveDownloadEventArg = null;
+       }
+       return r;
+}
+
+void
+_PlayerImpl::OnTimerExpired(Timer& timer)
+{
+       int ret = PLAYER_ERROR_NONE;
+       result r = E_SUCCESS;
+       unsigned long currentSize = 0;
+       unsigned long totalSize = 0;
+       unsigned int callbackSizeQuantum = 0;
+       _PlayerProgressiveDownloadEventArg* pPlayerProgressiveDownloadEventArg = null;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       
+       ret = player_get_progressive_download_status(__hPlayer, &currentSize, &totalSize);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_progressive_download_status operation with - 0x%x", GetErrorMessage(r), ret);
+       SysLog(NID_MEDIA, "Current Size is %d Total Size is %d", currentSize, totalSize);
+       callbackSizeQuantum = (totalSize * __pdCallbackRate ) / 100;
+       if (__pdNextCallbackSize == 0)
+       {
+               __pdNextCallbackSize = __pdNextCallbackSize + callbackSizeQuantum;
+       }
+       if (currentSize >= __pdNextCallbackSize)
+       {
+               pPlayerProgressiveDownloadEventArg = new (std::nothrow) _PlayerProgressiveDownloadEventArg;
+               SysTryCatch(NID_MEDIA, __pPlayerProgressiveDownloadEvent != null , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               pPlayerProgressiveDownloadEventArg->SetEventType(PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_IN_PROGRESS);
+               pPlayerProgressiveDownloadEventArg->SetDownloadedSize(currentSize);
+               pPlayerProgressiveDownloadEventArg->SetTotalSize(totalSize);
+               r = __pPlayerProgressiveDownloadEvent->FireAsync(*pPlayerProgressiveDownloadEventArg);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               __pdNextCallbackSize = __pdNextCallbackSize + callbackSizeQuantum;
+
+       }
+       r = timer.Start(_PLAYER_PROGRESSIVE_DOWNLOAD_TIMER_100_MS);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       return;
+CATCH:
+       if (pPlayerProgressiveDownloadEventArg)
+       {
+               delete pPlayerProgressiveDownloadEventArg;
+               pPlayerProgressiveDownloadEventArg = null;
+       }
+}
+
+result
+_PlayerImpl::OpenUrlAsync(Player* pPlayerInstance, const Tizen::Base::String& url, const Tizen::Base::String& filePath, IPlayerProgressiveDownloadListener& listener, const Tizen::Base::Collection::IMap* pHeader)
+{
+       result r = E_SUCCESS;
+
+       int err = PLAYER_ERROR_NONE;
+       Tizen::Base::Utility::Uri mediaUri;
+       Tizen::Base::String scheme;
+       bool containsCookie = false;
+       bool containsUserAgent = false;
+       std::unique_ptr<char[]> pProgressiveDownloadPath;
+       std::unique_ptr<const String> pCookieValue;
+       std::unique_ptr<const String> pUserAgentValue;
+       std::unique_ptr<char[]> pCookieChars;
+       std::unique_ptr<char[]> pUsetAgentChars;
+       std::unique_ptr<char[]> pInputFilePath;
+
+       SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
+       
+       SysTryReturn(NID_MEDIA, pPlayerInstance != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM]A system error has been occurred. Player instance is null.");
+
+       pProgressiveDownloadPath.reset(_StringConverter::CopyToCharArrayN(filePath));
+       SysTryReturn(NID_MEDIA, pProgressiveDownloadPath.get() != null, E_INVALID_ARG, E_INVALID_ARG,
+               "[E_INVALID_ARG] Invalid argument is used. progressive download file path is wrong");
+
+       err = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_getstate operation with - 0x%x", GetErrorMessage(r), err);
+
+       SysTryReturn(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_IDLE,
+                E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. returned state is %d", __corePlayerCurState);
+
+       SysTryReturn(NID_MEDIA, !url.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Input url is empty");
+
+       mediaUri.SetUri(url);
+       scheme = mediaUri.GetScheme();
+       SysTryCatch(NID_MEDIA, scheme.Equals(L"http", false), r = E_UNSUPPORTED_PROTOCOL,
+               E_UNSUPPORTED_PROTOCOL, "[E_UNSUPPORTED_PROTOCOL] scheme is Unsupported protocol");
+
+       pInputFilePath.reset(_StringConverter::CopyToCharArrayN(url));
+       __isAsync = true;
+       __isStreamingContent = true;
+       __isProgressiveContent = true;
+
+       // Create progressive download Event
+       __pPlayerProgressiveDownloadEvent.reset(new (std::nothrow) _PlayerProgressiveDownloadEvent);
+       SysTryCatch(NID_MEDIA, __pPlayerProgressiveDownloadEvent != null , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       __pPdTimer.reset(new (std::nothrow) Timer);
+       SysTryCatch(NID_MEDIA, __pPdTimer != null , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       __pPdTimer->Construct(*this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pPlayerProgressiveDownloadEvent->Construct(pPlayerInstance);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct PlayerProgressiveDownloadEvent.", GetErrorMessage(r));
+       r = __pPlayerProgressiveDownloadEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform PlayerProgressiveDownloadEvent AddListener operation.", GetErrorMessage(r));
+
+       __pPlayerProgressiveDownloadListener = &listener;
+
+       err = player_set_progressive_download_message_cb(__hPlayer, PlayerPdMessageCallBack, this);
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_set_progressive_download_message_cb operation with - 0x%x", GetErrorMessage(r), err);
+
+       err = player_set_progressive_download_path(__hPlayer, pProgressiveDownloadPath.get());
+       r = MapExceptionToResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_set_progressive_download_path operation with - 0x%x", GetErrorMessage(r), err);
+
+       if (pHeader)
+       {
+               const HashMap *pMapHeader = dynamic_cast<const HashMap *>(pHeader);
+               SysTryCatch(NID_MEDIA, pMapHeader != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.");
+               pMapHeader->ContainsKey(String("Cookie"), containsCookie);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_MEDIA, r, "[%s] Failed to perform HashMap::ContainsKey operation.", GetErrorMessage(r));
+               }
+               else if (containsCookie)
+               {
+                       pCookieValue.reset(dynamic_cast<const String *>(pMapHeader->GetValue(String("Cookie"))));
+                       if (pCookieValue.get())
+                       {
+                               pCookieChars.reset(_StringConverter::CopyToCharArrayN(*(pCookieValue.get())));
+                               if (pCookieChars.get())
+                               {
+                                       err = player_set_streaming_cookie(__hPlayer, pCookieChars.get(),pCookieValue->GetLength());
+                               }
+                       }
+                       else
+                       {
+                               r = GetLastResult();
+                               SysLogException(NID_MEDIA, r, "[%s] Failed to perform HashMap::GetValue(Cookie) operation.", GetErrorMessage(r));
+                       }
+               }
+               pMapHeader->ContainsKey(String("User-Agent"), containsUserAgent);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_MEDIA, r, "[%s] Failed to perform HashMap::ContainsKey operation.", GetErrorMessage(r));
+               }
+               else if (containsUserAgent)
+               {
+                       pUserAgentValue.reset(dynamic_cast<const String *>(pMapHeader->GetValue(String("User-Agent"))));
+                       if (pUserAgentValue.get())
+                       {
+                               pUsetAgentChars.reset(_StringConverter::CopyToCharArrayN(*(pUserAgentValue.get())));
+                               err = player_set_streaming_user_agent(__hPlayer, pUsetAgentChars.get(),pUserAgentValue->GetLength());
+                       }
+                       else
+                       {
+                               r = GetLastResult();
+                               SysLogException(NID_MEDIA, r, "[%s]HashMap::GetValue(User-Agent) Failed", GetErrorMessage(r));
+                       }
+               }
+       }
+
+       __currentState = PLAYER_STATE_OPENING;
+
+       r = OpenInputData(std::move(pInputFilePath));
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform OpenInputData operation.", GetErrorMessage(r));
+
+       return r;
+CATCH:
+       __isStreamingContent = false;
+       __currentState = PLAYER_STATE_INITIALIZED;
+       return r;
+}
+
+void
+_PlayerImpl::SetProgressiveDownloadIntervalByPercent(int percent)
+{
+       if((0 <= percent) && (percent <= 100))
+       {
+               __pdCallbackRate = percent;
+       }
+}
+
+};
+};  // Tizen::Media
+
diff --git a/src/FMedia_PlayerProgressiveDownloadEvent.cpp b/src/FMedia_PlayerProgressiveDownloadEvent.cpp
new file mode 100644 (file)
index 0000000..9416e37
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+#include "FMedia_PlayerProgressiveDownloadEvent.h"
+#include "FMedia_PlayerProgressiveDownloadEventArg.h"
+#include <FMediaIPlayerProgressiveDownloadListener.h>
+
+namespace Tizen { namespace Media
+{
+
+_PlayerProgressiveDownloadEvent::_PlayerProgressiveDownloadEvent()
+       : __pPlayerInstance(null)
+{
+
+}
+
+_PlayerProgressiveDownloadEvent::~_PlayerProgressiveDownloadEvent(void)
+{
+
+}
+
+result
+_PlayerProgressiveDownloadEvent::Construct(Player* playerInstance)
+{
+       SysTryReturn(NID_MEDIA, playerInstance != null, E_SYSTEM, E_SYSTEM,
+       "[E_SYSTEM] A system error has been occured. Player instance cannot be null");
+       __pPlayerInstance = playerInstance;
+       return _Event::Initialize();
+}
+
+void
+_PlayerProgressiveDownloadEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       IPlayerProgressiveDownloadListener* pPlayerProgressiveDownloadListener = dynamic_cast<IPlayerProgressiveDownloadListener*> (&listener);
+       SysTryReturn(NID_MEDIA, pPlayerProgressiveDownloadListener != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Listener is null.");
+       SysTryReturn(NID_MEDIA, __pPlayerInstance != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Player instance is null.");
+
+       const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
+       SysTryReturn(NID_MEDIA, pTempArg, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Arg is null.");
+       _PlayerProgressiveDownloadEventArg* pArg = (_PlayerProgressiveDownloadEventArg*) pTempArg;
+
+       switch (pArg->GetEventType())
+       {
+       case PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_STARTED:
+               pPlayerProgressiveDownloadListener->OnPlayerProgressiveDownloadStarted(*__pPlayerInstance);
+               break;
+
+       case PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_IN_PROGRESS:
+               pPlayerProgressiveDownloadListener->OnPlayerProgressiveDownloadInProgress(*__pPlayerInstance, pArg->GetDownloadedSize(), pArg->GetTotalSize());
+               break;
+
+       case PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_COMPLETED:
+               pPlayerProgressiveDownloadListener->OnPlayerProgressiveDownloadCompleted(*__pPlayerInstance, pArg->GetResult());
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_SYSTEM, "Never Come here");
+               break;
+
+       }
+}
+
+};
+};
diff --git a/src/FMedia_PlayerProgressiveDownloadEventArg.cpp b/src/FMedia_PlayerProgressiveDownloadEventArg.cpp
new file mode 100644 (file)
index 0000000..7c16808
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include "FMedia_PlayerProgressiveDownloadEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_PlayerProgressiveDownloadEventTypeArg::_PlayerProgressiveDownloadEventTypeArg(void)
+       : __playerProgresiveDownloadEventType(PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_NONE)
+{
+
+}
+
+_PlayerProgressiveDownloadEventTypeArg::~_PlayerProgressiveDownloadEventTypeArg(void)
+{
+
+}
+
+void
+_PlayerProgressiveDownloadEventTypeArg::SetEventType(_PlayerProgressiveDownloadEventType eType)
+{
+       __playerProgresiveDownloadEventType = eType;
+}
+
+_PlayerProgressiveDownloadEventType
+_PlayerProgressiveDownloadEventTypeArg::GetEventType(void) const
+{
+       return __playerProgresiveDownloadEventType;
+}
+
+_PlayerProgressiveDownloadEventArg::_PlayerProgressiveDownloadEventArg(void)
+       : __downloadedSize(0)
+       , __totalSize(0)
+       , __resultReturned(E_SUCCESS)
+{
+}
+
+_PlayerProgressiveDownloadEventArg::~_PlayerProgressiveDownloadEventArg(void)
+{
+}
+
+void
+_PlayerProgressiveDownloadEventArg::SetDownloadedSize(int downloadedSize)
+{
+       __downloadedSize = downloadedSize;
+}
+
+int
+_PlayerProgressiveDownloadEventArg::GetDownloadedSize(void) const
+{
+       return __downloadedSize;
+}
+
+void
+_PlayerProgressiveDownloadEventArg::SetTotalSize(int totalSize)
+{
+       __totalSize = totalSize;
+}
+
+int
+_PlayerProgressiveDownloadEventArg::GetTotalSize(void) const
+{
+       return __totalSize;
+}
+void
+_PlayerProgressiveDownloadEventArg::SetResult(result returnResult)
+{
+       __resultReturned = returnResult;
+}
+
+result
+_PlayerProgressiveDownloadEventArg::GetResult() const
+{
+       return __resultReturned;
+}
+
+};
+};             // Tizen::Media
diff --git a/src/FMedia_PlayerVideoEvent.cpp b/src/FMedia_PlayerVideoEvent.cpp
new file mode 100644 (file)
index 0000000..1e5b188
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaPlayerVideoEvent.cpp
+ */
+
+#include <FBaseSysLog.h>
+#include "FMedia_PlayerVideoEvent.h"
+#include "FMedia_PlayerVideoEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_PlayerVideoEvent::_PlayerVideoEvent(void)
+       : __pPlayerSrc(null)
+       , __cntListener(0)
+{
+
+}
+
+_PlayerVideoEvent::~_PlayerVideoEvent(void)
+{
+
+}
+
+result
+_PlayerVideoEvent::Construct(void* pPlayer)
+{
+       result r = E_SUCCESS;
+       __pPlayerSrc = (Player*) pPlayer;
+       r = _Event::Initialize();
+       return r;
+}
+
+void
+_PlayerVideoEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       IPlayerVideoEventListener* pPlayerVideoEventListener = dynamic_cast<IPlayerVideoEventListener*> (&listener);
+       SysTryReturn(NID_MEDIA, pPlayerVideoEventListener, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pPlayerVideoEventListener is null.");
+
+       const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
+       SysTryReturn(NID_MEDIA, pTempArg, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pTempArg is null.");
+       _PlayerVideoEventTypeArg* pArg = (_PlayerVideoEventTypeArg*) pTempArg;
+
+       switch (pArg->GetVideoEventType())
+       {
+       case _PLAYER_VIDEO_EVENT_ERROR:
+               pPlayerVideoEventListener->OnVideoFrameDecoded(*__pPlayerSrc, ((_PlayerVideoEventArg*) pArg)->GetPixelFormat(),
+                                                                                                          ((_PlayerVideoEventArg*) pArg)->GetDim(), 0, 0,
+                                                                                                          ((_PlayerVideoEventArg*) pArg)->GetResult());
+               break;
+
+       case _PLAYER_VIDEO_EVENT_DECODED:
+               pPlayerVideoEventListener->OnVideoFrameDecoded(*__pPlayerSrc, ((_PlayerVideoEventArg*) pArg)->GetPixelFormat(),
+                                                                                                          ((_PlayerVideoEventArg*) pArg)->GetDim(),
+                                                                                                          ((_PlayerVideoEventArg*) pArg)->GetBuffer(),
+                                                                                                          ((_PlayerVideoEventArg*) pArg)->GetSizeOfBuffer(),
+                                                                                                          ((_PlayerVideoEventArg*) pArg)->GetResult());
+               break;
+
+       case _PLAYER_VIDEO_EVENT_DECODED_WITHOUT_DATA:
+               pPlayerVideoEventListener->OnVideoFrameDecoded(*__pPlayerSrc, ((_PlayerVideoEventArg*) pArg)->GetPixelFormat(),
+                                                                                                          ((_PlayerVideoEventArg*) pArg)->GetDim(), 0, 0,
+                                                                                                          ((_PlayerVideoEventArg*) pArg)->GetResult());
+               break;
+
+       default:
+               break;
+       }
+}
+
+};
+};
diff --git a/src/FMedia_PlayerVideoEventArg.cpp b/src/FMedia_PlayerVideoEventArg.cpp
new file mode 100644 (file)
index 0000000..0bd6262
--- /dev/null
@@ -0,0 +1,130 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaPlayerVideoEventArg.cpp
+ * @brief                      This file contains the Video event arguments from subsystem to FMedia's event listener.
+ */
+
+#include "FMedia_PlayerVideoEventArg.h"
+
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media
+{
+
+_PlayerVideoEventTypeArg::_PlayerVideoEventTypeArg(void)
+       : __playerVideoEventType(_PLAYER_VIDEO_EVENT_NONE)
+{
+
+}
+
+_PlayerVideoEventTypeArg::~_PlayerVideoEventTypeArg(void)
+{
+
+
+}
+void
+_PlayerVideoEventTypeArg::SetVideoEventType(_PlayerVideoEventType eType)
+{
+       __playerVideoEventType = eType;
+}
+
+_PlayerVideoEventType
+_PlayerVideoEventTypeArg::GetVideoEventType(void) const
+{
+       return __playerVideoEventType;
+}
+
+_PlayerVideoEventArg::_PlayerVideoEventArg(void)
+       : __pDecodedFrameDataBuffer(null)
+{
+       __dim.height = 0;
+       __dim.width = 0;
+       __pixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
+       __result = E_SUCCESS;
+       __sizeOfBuffer = 0;
+}
+
+_PlayerVideoEventArg::~_PlayerVideoEventArg(void)
+{
+       //we unmap shared memory for each frame cb before but it decrease performance.
+       if (__pDecodedFrameDataBuffer != null)
+       {
+               delete [] __pDecodedFrameDataBuffer;
+       }
+}
+
+byte*
+_PlayerVideoEventArg::GetBuffer(void) const
+{
+       return __pDecodedFrameDataBuffer;
+}
+
+void
+_PlayerVideoEventArg::SetBuffer(byte* data)
+{
+       __pDecodedFrameDataBuffer = data;
+}
+
+int
+_PlayerVideoEventArg::GetSizeOfBuffer(void) const
+{
+       return __sizeOfBuffer;
+}
+void
+_PlayerVideoEventArg::SetSizeOfBuffer(int size)
+{
+       __sizeOfBuffer = size;
+}
+
+Tizen::Graphics::BitmapPixelFormat
+_PlayerVideoEventArg::GetPixelFormat(void) const
+{
+       return __pixelFormat;
+}
+void
+_PlayerVideoEventArg::SetPixelFormat(Tizen::Graphics::BitmapPixelFormat pixelFormat)
+{
+       __pixelFormat = pixelFormat;
+}
+
+Tizen::Graphics::Dimension
+_PlayerVideoEventArg::GetDim(void) const
+{
+       return __dim;
+}
+void
+_PlayerVideoEventArg::SetDim(Tizen::Graphics::Dimension dim)
+{
+       __dim.width = dim.width;
+       __dim.height = dim.height;
+}
+
+result
+_PlayerVideoEventArg::GetResult(void) const
+{
+       return __result;
+}
+void
+_PlayerVideoEventArg::SetResult(result r)
+{
+       __result = r;
+}
+
+};
+};   // Tizen::Media
diff --git a/src/FMedia_PlayerVideoEventArg.h b/src/FMedia_PlayerVideoEventArg.h
new file mode 100644 (file)
index 0000000..3824c9d
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_PlayerVideoEventArg.h
+ * @brief                      This header file contains the declaration of Tizen::Media namespace.
+ *
+ */
+
+
+#ifndef _FMEDIA_INTERNAL_PLAYER_VIDEO_EVENTARG_H_
+#define _FMEDIA_INTERNAL_PLAYER_VIDEO_EVENTARG_H_
+
+#include <FGrpDimension.h>
+#include <FGrpBitmapCommon.h>
+#include <FOspConfig.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseRtEvent.h>
+#include <FBaseErrorDefine.h>
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FMediaPlayerTypes.h>
+#include "FMedia_PlayerVideoEventTypes.h"
+
+namespace Tizen {namespace Media
+{
+
+class  _PlayerVideoEventTypeArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+
+       _PlayerVideoEventTypeArg(void);
+       virtual ~_PlayerVideoEventTypeArg(void);
+       _PlayerVideoEventType GetVideoEventType(void) const;
+       void SetVideoEventType(_PlayerVideoEventType eType);
+
+private:
+       _PlayerVideoEventTypeArg(const _PlayerVideoEventTypeArg& rhs);
+       _PlayerVideoEventTypeArg& operator =(const _PlayerVideoEventTypeArg& rhs);
+
+       _PlayerVideoEventType __playerVideoEventType;
+
+};
+
+class  _PlayerVideoEventArg
+       : public _PlayerVideoEventTypeArg
+{
+public:
+
+       _PlayerVideoEventArg(void);
+       virtual ~_PlayerVideoEventArg(void);
+
+       byte* GetBuffer(void) const;
+       void SetBuffer(byte* data);
+
+       int GetSizeOfBuffer(void) const;
+       void SetSizeOfBuffer(int size);
+
+       Tizen::Graphics::BitmapPixelFormat GetPixelFormat(void) const;
+       void SetPixelFormat(Tizen::Graphics::BitmapPixelFormat pixelFormat);
+
+       Tizen::Graphics::Dimension GetDim(void) const;
+       void SetDim(Tizen::Graphics::Dimension dim);
+
+       result GetResult(void) const;
+       void SetResult(result r);
+
+private:
+       byte* __pDecodedFrameDataBuffer;
+       int __sizeOfBuffer;
+       Tizen::Graphics::Dimension __dim;
+       Tizen::Graphics::BitmapPixelFormat __pixelFormat;
+       result __result;
+};
+
+}}//Tizen::Media
+#endif
diff --git a/src/FMedia_RecorderCapability.cpp b/src/FMedia_RecorderCapability.cpp
new file mode 100755 (executable)
index 0000000..8644a84
--- /dev/null
@@ -0,0 +1,443 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMedia_RecorderCapability.cpp
+ * @brief              This file contains the implementation of recorder capability header file FMedia_RecorderCapability.h
+ */
+#include <libxml/tree.h>
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBaseColArrayList.h>
+#include <FGrpDimension.h>
+#include <FMediaTypes.h>
+#include "FMedia_RecorderTypes.h"
+#include "FMedia_RecorderCapability.h"
+#include "FMedia_RecorderUtil.h"
+#include "FMedia_RecorderSession.h"
+#include "FMedia_CamPtrUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Media
+{
+
+const _RecorderCapability::keyServiceMap _RecorderCapability::__SERVICE_MAP[] =
+{
+       {
+               _ROP_NONE, _RECORDER_SOURCE_VIDEO, null
+       },
+       {
+               _VROP_FILE_FORMAT, _RECORDER_SOURCE_VIDEO, GetSupportedVideoFileFormatN
+       },
+       {
+               _VROP_AUDIO_ENCODER, _RECORDER_SOURCE_VIDEO, GetSupportedAudioEncoderN
+       },
+       {
+               _VROP_VIDEO_ENCODER, _RECORDER_SOURCE_VIDEO, GetSupportedVideoEncoderN
+       },
+       {
+               _AROP_FILE_FORMAT, _RECORDER_SOURCE_AUDIO, GetSupportedAudioFileFormatN
+       },
+       {
+               _AROP_AUDIO_ENCODER, _RECORDER_SOURCE_AUDIO, GetSupportedAudioEncoderN
+       },
+       {
+               _ROP_MAX, _RECORDER_SOURCE_VIDEO, null
+       },
+};
+
+_RecorderCapability::_RecorderCapability(void)
+{
+}
+
+_RecorderCapability::~_RecorderCapability(void)
+{
+}
+
+Tizen::Base::Collection::ArrayList*
+_RecorderCapability::GetListN(_RecorderOperationType key, _ResultType& itemType)
+{
+       //check key boundary condition
+       SysTryReturn(NID_MEDIA, (key > _ROP_NONE && key < _ROP_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(KEY) is used. KEY :%d", key);
+
+       _RecorderSourceType sourceType = __SERVICE_MAP[key].sourceType;
+       _RecorderQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
+
+       //check service handler for a given key
+       SysTryReturn(NID_MEDIA, serviceRoutine != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The query function is not found.");
+
+       std::unique_ptr<ArrayList, _ListPtrUtil::Remover> pList (null, _ListPtrUtil::remover);
+       Object* pObj = serviceRoutine(sourceType, _QUERY_LIST, itemType);
+       switch (itemType)
+       {
+       case _RESULT_INTEGER_LIST:
+               //fall through
+       case _RESULT_PAIR_INTEGER_LIST:
+               //fall through
+       case _RESULT_DIMENSION_LIST:
+               //fall through
+       case _RESULT_DOUBLE_LIST:
+               //fall through
+       case _RESULT_STRING_LIST:
+               pList.reset(dynamic_cast<ArrayList*>(pObj));
+               SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               SysTryCatch(NID_MEDIA, pList->GetCount() > 0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Empty data returned for key = [%d]", key);
+               SysLog(NID_MEDIA, "Valid data returned for key = %d count = %d", key, pList->GetCount());
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Supported List is not retrieved. key = [%d]", key);
+               goto CATCH;
+               break;
+       }
+       return pList.release();
+
+CATCH:
+       return null;
+}
+
+bool
+_RecorderCapability::IsSupported(_RecorderOperationType key)
+{
+       //check key boundary condition
+       SysTryReturn(NID_MEDIA, (key > _ROP_NONE && key < _ROP_MAX), false, E_INVALID_ARG, "[E_INVALID_ARG] The key:%d is invalid.", key);
+
+       _RecorderSourceType sourceType = __SERVICE_MAP[key].sourceType;
+       _RecorderQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
+       _ResultType itemType = _RESULT_NONE;
+
+       //check service handler for a given key
+       SysTryReturn(NID_MEDIA, serviceRoutine != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       std::unique_ptr<ArrayList, _ListPtrUtil::Remover> pList (null, _ListPtrUtil::remover);
+       Object* pObj = serviceRoutine(sourceType, _QUERY_LIST, itemType);
+       switch (itemType)
+       {
+       case _RESULT_INTEGER_LIST:
+               //fall through
+       case _RESULT_DIMENSION_LIST:
+               //fall through
+       case _RESULT_DOUBLE_LIST:
+               //fall through
+       case _RESULT_STRING_LIST:
+               pList.reset(dynamic_cast<ArrayList*>(pObj));
+               SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               SysTryCatch(NID_MEDIA, pList->GetCount()>0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no valid data in key = [%d].", key);
+               break;
+
+       case _RESULT_PAIR_INTEGER_LIST:
+               pList.reset(dynamic_cast<ArrayList*>(pObj));
+               SysTryCatch(NID_MEDIA, pList.get() != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               {
+                       Integer* pInteger = null;
+                       pInteger = dynamic_cast<Integer*>(pList->GetAt(1));              // Get max value;
+                       SysTryCatch(NID_MEDIA, pInteger != null, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Max value is null for key = [%d].", key);
+                       SysTryCatch(NID_MEDIA, pInteger->ToInt() > 0, , E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Max value is %d for key = [%d].", pInteger->ToInt(), key);
+               }
+               break;
+
+       default:
+               SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               goto CATCH;
+               break;
+       }
+       SysLog(NID_MEDIA, "Valid data returned for key = %d count = %d", key, pList->GetCount());
+
+       return true;
+
+CATCH:
+       return false;
+}
+
+Tizen::Base::Object*
+_RecorderCapability::GetValueN(_RecorderOperationType key, _QueryType queryType, _ResultType& itemType)
+{
+       Tizen::Base::Object* pValue = null;
+
+       //check key boundary condition
+       SysTryReturn(NID_MEDIA, (key > _ROP_NONE && key < _ROP_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] The key:%d is invalid.", key);
+       SysTryReturn(NID_MEDIA, (queryType >= _QUERY_DEFAULT_VALUE && queryType < _QUERY_MAX), null, E_INVALID_ARG, "[E_INVALID_ARG] The query:%d is invalid.", queryType);
+
+       _RecorderSourceType sourceType = __SERVICE_MAP[key].sourceType;
+       _RecorderQueryFunc serviceRoutine = __SERVICE_MAP[key].serviceRoutine;
+
+       //check service handler for a given key
+       SysTryReturn(NID_MEDIA, serviceRoutine != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The query function is not found.");
+
+       Object* pObj = serviceRoutine(sourceType, queryType, itemType);
+
+       switch (itemType)
+       {
+       case _RESULT_INTEGER:
+               pValue = dynamic_cast<Integer*>(pObj);
+               SysTryReturn(NID_MEDIA, null != pValue, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               break;
+
+       case _RESULT_DIMENSION:
+               pValue = dynamic_cast<Dimension*>(pObj);
+               SysTryReturn(NID_MEDIA, null != pValue, null, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] There is no data list in key = [%d].", key);
+               break;
+
+       case _RESULT_INTEGER_LIST:
+               //fall through
+       case _RESULT_PAIR_INTEGER_LIST:
+               //fall through
+       case _RESULT_DIMENSION_LIST:
+               //fall through
+       case _RESULT_DOUBLE_LIST:
+               //fall through
+       case _RESULT_STRING_LIST:
+       default:
+               SysLogException(NID_MEDIA, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Default value cannot be retrived. key = [%d], itemType:%d", key, itemType);
+               goto CATCH;
+               break;
+       }
+       SysLog(NID_MEDIA, "Valid data returned for key = %d", key);
+       return pValue;
+
+CATCH:
+       return null;
+}
+
+
+Tizen::Base::Object*
+_RecorderCapability::GetSupportedVideoFileFormatN(_RecorderSourceType sourceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pfileFormat = null;
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       _RecorderSession recorderSession;
+       r = recorderSession.Construct(sourceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _RecorderHandle recorderHandle = recorderSession.GetHandle();
+       SysTryReturn(NID_MEDIA, recorderHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pfileFormatList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pfileFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = recorder_foreach_supported_file_format(recorderHandle, SupportedRecorderVideoFileFormatCb, pfileFormatList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pfileFormat = pfileFormatList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               itemType = _RESULT_INTEGER;
+       }
+
+       return pfileFormat;
+}
+
+Tizen::Base::Object*
+_RecorderCapability::GetSupportedAudioFileFormatN(_RecorderSourceType sourceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pfileFormat = null;
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       _RecorderSession recorderSession;
+       r = recorderSession.Construct(sourceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _RecorderHandle recorderHandle = recorderSession.GetHandle();
+       SysTryReturn(NID_MEDIA, recorderHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pfileFormatList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pfileFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = recorder_foreach_supported_file_format(recorderHandle, SupportedRecorderAudioFileFormatCb, pfileFormatList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pfileFormat = pfileFormatList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               itemType = _RESULT_INTEGER;
+       }
+
+       return pfileFormat;
+}
+
+
+Tizen::Base::Object*
+_RecorderCapability::GetSupportedAudioEncoderN(_RecorderSourceType sourceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pAudioEncoder = null;
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       _RecorderSession recorderSession;
+       r = recorderSession.Construct(sourceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _RecorderHandle recorderHandle = recorderSession.GetHandle();
+       SysTryReturn(NID_MEDIA, recorderHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pAudioEncoderList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pAudioEncoderList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = recorder_foreach_supported_audio_encoder(recorderHandle, SupportedRecorderAudioEncoderCb, pAudioEncoderList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pAudioEncoder = pAudioEncoderList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               itemType = _RESULT_INTEGER;
+       }
+
+       return pAudioEncoder;
+}
+
+Tizen::Base::Object*
+_RecorderCapability::GetSupportedVideoEncoderN(_RecorderSourceType sourceType, _QueryType queryType, _ResultType& itemType)
+{
+       Object* pVideoEncoder = null;
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       _RecorderSession recorderSession;
+       r = recorderSession.Construct(sourceType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _RecorderHandle recorderHandle = recorderSession.GetHandle();
+       SysTryReturn(NID_MEDIA, recorderHandle != MM_INVALID_HANDLE, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Valid handle is not found.");
+
+       if (queryType == _QUERY_LIST)
+       {
+               std::unique_ptr<_MediaSafeArrayList, _ListPtrUtil::Remover> pVideoEncoderList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
+               SysTryReturn(NID_MEDIA, pVideoEncoderList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               err = recorder_foreach_supported_video_encoder(recorderHandle, SupportedRecorderVideoEncoderCb, pVideoEncoderList.get());
+               SysTryReturn(NID_MEDIA, err == MM_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Getting the capability failed.");
+
+               itemType = _RESULT_INTEGER_LIST;
+               pVideoEncoder = pVideoEncoderList.release();
+       }
+       else if (queryType == _QUERY_DEFAULT_VALUE)
+       {
+               itemType = _RESULT_INTEGER;
+       }
+
+       return pVideoEncoder;
+}
+
+bool
+_RecorderCapability::SupportedRecorderVideoFileFormatCb(recorder_file_format_e format, void *pUserData)
+{
+       result r = E_SUCCESS;
+       MediaContainerType formatValue = (MediaContainerType)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pFormatList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pFormatList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _RecorderUtil::GetOspVideoContainer((recorder_file_format_e)format, formatValue);
+       if (E_SUCCESS == r)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(formatValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pFormatList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return true;
+}
+
+bool
+_RecorderCapability::SupportedRecorderAudioFileFormatCb(recorder_file_format_e format, void *pUserData)
+{
+       result r = E_SUCCESS;
+       MediaContainerType formatValue = (MediaContainerType)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pFormatList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pFormatList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _RecorderUtil::GetOspAudioContainer((recorder_file_format_e)format, formatValue);
+       if (E_SUCCESS == r)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(formatValue));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pFormatList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return true;
+}
+
+bool
+_RecorderCapability::SupportedRecorderAudioEncoderCb(recorder_audio_codec_e codec, void *pUserData)
+{
+       result r = E_SUCCESS;
+       CodecType audioCodecType = (CodecType)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pAudioEncoderList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pAudioEncoderList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _RecorderUtil::GetOspAudioCodec((recorder_audio_codec_e)codec, audioCodecType);
+       if (E_SUCCESS == r)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(audioCodecType));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pAudioEncoderList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return true;
+}
+
+bool
+_RecorderCapability::SupportedRecorderVideoEncoderCb(recorder_video_codec_e codec, void *pUserData)
+{
+       result r = E_SUCCESS;
+       CodecType videoCodecType = (CodecType)MEDIA_INVALID_VALUE;
+
+       _MediaSafeArrayList* pVideoEncoderList = static_cast<_MediaSafeArrayList*>(pUserData);
+       SysTryReturn(NID_MEDIA, pVideoEncoderList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The user list is not found.");
+
+       r = _RecorderUtil::GetOspVideoCodec((recorder_video_codec_e)codec, videoCodecType);
+       if (E_SUCCESS == r)
+       {
+               std::unique_ptr<Object> pInteger (new (std::nothrow) Integer(videoCodecType));
+               SysTryReturn(NID_MEDIA, pInteger.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pVideoEncoderList->AddPtr(std::move(pInteger));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return true;
+}
+
+}}
diff --git a/src/FMedia_RecorderCapability.h b/src/FMedia_RecorderCapability.h
new file mode 100755 (executable)
index 0000000..b3a2e4d
--- /dev/null
@@ -0,0 +1,175 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                        FMedia_RecorderCapability.h
+* @brief               This header file contains the implementation header for Recorder capability.
+*
+*/
+#ifndef _FMEDIA_INTERNAL_RECORDER_CAPABILITY_H_
+#define _FMEDIA_INTERNAL_RECORDER_CAPABILITY_H_
+
+#include <recorder.h>
+#include "FMedia_RecorderTypes.h"
+#include "FMedia_CapabilityTypes.h"
+
+namespace Tizen { namespace Media
+{
+
+typedef Tizen::Base::Object* (*_RecorderQueryFunc)(_RecorderSourceType, _QueryType, _ResultType&);
+
+/**
+* @class       _RecorderCapability
+* @brief       This class is common for recorder capability.
+*
+*/
+class _RecorderCapability
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       * function to get the  for specific key type
+       *
+       * @return               The list which contains the values
+       * @param[in]    key                                             camera operation query key
+       * @param[out]   itemType                                item type of returned IList
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       *  @exception   E_SYSTEM                                A system error has occurred.
+       * @exception    E_UNSUPPORTED_OPERATION   operation not supported
+       */
+       static Tizen::Base::Collection::ArrayList* GetListN(_RecorderOperationType key, _ResultType& itemType);
+
+
+       /**
+       * function to check the feature support
+       *
+       * @return               bool
+       * @param[in]    key                                             camera operation query key
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       * @exception    E_UNSUPPORTED_OPERATION   operation not supported
+       */
+       static bool IsSupported(_RecorderOperationType key);
+
+       /**
+       * function to get the default value for a specific key
+       *
+       * @return               The object which contains the values
+       * @param[in]    key                                             Recorder operation query key
+       * @param[in]    queryType                               parameter to get the list items or default value of an attribute
+       * @param[out]   itemType                                item type of returned IList
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       * @exception    E_UNSUPPORTED_OPERATION   operation not supported
+       */
+       static Tizen::Base::Object* GetValueN(_RecorderOperationType key, _QueryType queryType, _ResultType& itemType);
+
+private:
+       typedef struct
+       {
+               _RecorderOperationType key;
+               _RecorderSourceType sourceType;
+               _RecorderQueryFunc serviceRoutine;
+       }keyServiceMap;
+
+       /**
+       *       The constructor.
+       */
+       _RecorderCapability(void);
+
+       /**
+       *       The destructor.
+       *       Resources are deallocated by this method.
+       */
+       ~_RecorderCapability(void);
+
+       /**
+       * function to get the supported Video file format
+       *
+       * @return               The object which contains the values
+       * @param[in]    sourceType                              camera type [primary/secondary]
+       * @param[in]    queryType                               parameter to get the list items or default value of an attribute
+       * @param[out]   itemType                                item type of returned IList
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedVideoFileFormatN(_RecorderSourceType sourceType, _QueryType queryType, _ResultType& itemType);
+
+
+       /**
+       * function to get the supported Audio file format
+       *
+       * @return               The object which contains the values
+       * @param[in]    sourceType                              camera type [primary/secondary]
+       * @param[in]    queryType                               parameter to get the list items or default value of an attribute
+       * @param[out]   itemType                                item type of returned IList
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedAudioFileFormatN(_RecorderSourceType sourceType, _QueryType queryType, _ResultType& itemType);
+
+
+       /**
+       * function to get the supported Audio Encoder list
+       *
+       * @return               The object which contains the values
+       * @param[in]    sourceType                              camera type [primary/secondary]
+       * @param[in]    queryType                               parameter to get the list items or default value of an attribute
+       * @param[out]   itemType                                item type of returned IList
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedAudioEncoderN(_RecorderSourceType sourceType, _QueryType queryType, _ResultType& itemType);
+
+       /**
+       * function to get the supported Video Encoder list
+       *
+       * @return               The object which contains the values
+       * @param[in]    sourceType                              camera type [primary/secondary]
+       * @param[in]    queryType                               parameter to get the list items or default value of an attribute
+       * @param[out]   itemType                                item type of returned IList
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 system has no memory
+       * @exception    E_OBJ_NOT_FOUND                 invalid key
+       */
+       static Tizen::Base::Object* GetSupportedVideoEncoderN(_RecorderSourceType sourceType, _QueryType queryType, _ResultType& itemType);
+
+       static bool SupportedRecorderVideoFileFormatCb(recorder_file_format_e format, void *pUserData);
+       static bool SupportedRecorderAudioFileFormatCb(recorder_file_format_e format, void *pUserData);
+       static bool SupportedRecorderAudioEncoderCb(recorder_audio_codec_e codec, void *pUserData);
+       static bool SupportedRecorderVideoEncoderCb(recorder_video_codec_e codec, void *pUserData);
+
+       _RecorderCapability(const _RecorderCapability& rhs);
+       _RecorderCapability& operator =(const _RecorderCapability& rhs);
+
+       static const keyServiceMap __SERVICE_MAP[];
+};
+
+}}
+#endif
diff --git a/src/FMedia_RecorderEventArg.cpp b/src/FMedia_RecorderEventArg.cpp
new file mode 100755 (executable)
index 0000000..514888e
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_RecorderEventArg.cpp
+ * @brief                      This file contains the implementation of event processing argument for the Recorder
+ */
+
+#include "FMedia_RecorderEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_RecorderEventArg::_RecorderEventArg(void)
+       : __recorderEventType(_RECORDER_EVENT_NONE)
+       , __pRecordedData(null)
+       , __result(E_SUCCESS)
+       , __error(RECORDER_ERROR_NONE)
+{
+
+}
+
+_RecorderEventArg::~_RecorderEventArg(void)
+{
+       if (__pRecordedData != null)
+       {
+               delete (Tizen::Base::ByteBuffer*) __pRecordedData;
+               __pRecordedData = null;
+       }
+}
+
+void
+_RecorderEventArg::SetEventType(_RecorderEventType eType)
+{
+       __recorderEventType = eType;
+}
+
+_RecorderEventType
+_RecorderEventArg::GetEventType(void) const
+{
+       return __recorderEventType;
+}
+
+void
+_RecorderEventArg::SetData(Tizen::Base::ByteBuffer* data)
+{
+       __pRecordedData = data;
+}
+
+Tizen::Base::ByteBuffer*
+_RecorderEventArg::GetData(void) const
+{
+       return __pRecordedData;
+}
+
+result
+_RecorderEventArg::GetResult(void) const
+{
+       return __result;
+}
+
+void
+_RecorderEventArg::SetResult(result r)
+{
+       __result = r;
+}
+
+RecorderErrorReason
+_RecorderEventArg::GetError(void) const
+{
+       return __error;
+}
+
+void
+_RecorderEventArg::SetError(RecorderErrorReason r)
+{
+       __error = r;
+}
+
+}}// Tizen::Media
diff --git a/src/FMedia_RecorderEventArg.h b/src/FMedia_RecorderEventArg.h
new file mode 100755 (executable)
index 0000000..e3d2081
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_RecorderEventArg.h
+ * @brief                      This file contains the declaration of event processing argument for the Recorder
+ */
+
+#ifndef _FMEDIA_INTERNAL_EVENTARG_H_
+#define _FMEDIA_INTERNAL_EVENTARG_H_
+
+
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseByteBuffer.h>
+#include <FMediaAudioRecorderTypes.h>
+#include "FMedia_RecorderTypes.h"
+
+namespace Tizen {namespace Media
+{
+
+/**
+ *     @class          _RecorderEventArg
+ *     @brief          This class contains the declaration of Recorder's event argument.
+ */
+class _RecorderEventArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+       /**
+       *       Constructor
+       */
+       _RecorderEventArg(void);
+
+       /**
+       *       Destructor
+       */
+       ~_RecorderEventArg(void);
+
+
+       /**
+        *      Get the event type.
+        *
+        *      @return AudioRecorder Event type of this argument.
+        */
+       _RecorderEventType GetEventType(void) const;
+
+       /**
+        *      Set the event type.
+        */
+       void SetEventType(_RecorderEventType eType);
+
+       /**
+       *       Get the data provided by the AudioRecorder
+       *
+       *       @return data defined in AudioRecorder subsystem.
+       */
+       Tizen::Base::ByteBuffer* GetData(void) const;
+
+       /**
+       *       Set the data provided by the AudioRecorder
+       */
+       void SetData(Tizen::Base::ByteBuffer* data);
+
+       /**
+       *       Get the result.
+       *
+       *       @return AudioRecorder result of this argument.
+       */
+       result GetResult(void) const;
+
+       /**
+       *       Set the result.
+       */
+       void SetResult(result r);
+
+       /**
+       *       Get the error.
+       *
+       *       @return AudioRecorder error of this argument.
+       */
+       RecorderErrorReason GetError(void) const;
+
+       /**
+       *       Set the error.
+       */
+       void SetError(RecorderErrorReason r);
+
+private:
+       _RecorderEventArg(const _RecorderEventArg& value);
+       _RecorderEventArg& operator =(const _RecorderEventArg& value);
+
+       _RecorderEventType __recorderEventType;
+       Tizen::Base::ByteBuffer* __pRecordedData;
+       result __result;
+       RecorderErrorReason __error;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_RecorderManager.cpp b/src/FMedia_RecorderManager.cpp
new file mode 100755 (executable)
index 0000000..dfe67fd
--- /dev/null
@@ -0,0 +1,283 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_RecorderManager.cpp
+ * @brief                      This file contains the implementation of the %_RecorderManager class.
+ *
+ */
+
+#include <pthread.h>
+#include <recorder.h>
+#include <FBaseSysLog.h>
+#include "FMedia_CameraManager.h"
+#include "FMedia_RecorderManager.h"
+#include "FMedia_RecorderTypes.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_RecorderManagerSafeHashMapT* _RecorderManager::__pMap = null;
+
+_RecorderManagerSafeHashMapT::_RecorderManagerSafeHashMapT(void)
+{
+}
+
+_RecorderManagerSafeHashMapT::~_RecorderManagerSafeHashMapT(void)
+{
+       RemoveItems();
+       _RecorderManager::__pMap = null;
+}
+
+void
+_RecorderManagerSafeHashMapT::RemoveItems(void)
+{
+       IListT <_RecorderDeviceType>* pList = null;
+       _RecorderManager* pManager = null;
+       result r = E_SUCCESS;
+
+       pList = GetKeysN();
+       SysTryReturn(NID_MEDIA, pList != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
+
+       for (int i = 0; i < GetCount(); i++)
+       {
+               _RecorderDeviceType deviceType = _RECORDER_DEVICE_NONE;
+               r = pList->GetAt(i, deviceType);
+               if (IsFailed(r) && deviceType == _RECORDER_DEVICE_NONE)
+               {
+                       continue;
+               }
+
+               r = GetValue(deviceType, pManager);
+               if (IsFailed(r) && pManager == null)
+               {
+                       continue;
+               }
+               delete pManager;
+       }
+       pList->RemoveAll();
+       delete pList;
+       RemoveAll();
+}
+
+_RecorderManager::_RecorderManager()
+       : __handle(MM_INVALID_HANDLE)
+{
+}
+
+_RecorderManager::~_RecorderManager()
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+
+       err = recorder_destroy(__handle);
+       r = ConvertResult(err);
+       SysLog(NID_MEDIA, "[%s] destroyed.", GetErrorMessage(r));
+}
+
+result
+_RecorderManager::Construct(_CameraDeviceType cameraDevice, _RecorderDeviceType recorderDevice)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. camera device:%d, recorder device:%d", (int)cameraDevice, (int)recorderDevice);
+
+       if (recorderDevice == _RECORDER_DEVICE_AUDIO)
+       {
+               err = recorder_create_audiorecorder(&__handle);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else if (recorderDevice == _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA || recorderDevice == _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA)
+       {
+               _CameraManager* pCameraManager = null;
+               _CameraHandle cameraHandle = 0;
+
+               pCameraManager = _CameraManager::AddInstance(cameraDevice);
+               SysTryCatch(NID_MEDIA, pCameraManager != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraHandle instance is not available.");
+
+               cameraHandle = pCameraManager->GetHandle();
+
+               err = recorder_create_videorecorder(cameraHandle, &__handle);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else
+       {
+               SysLogException(NID_MEDIA, r = E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(cameraDevice, recorderDevice) is used. cameraDevice:%d, recorderDevice:%d is wrong.",
+                       (int)cameraDevice, (int)recorderDevice);
+               goto CATCH;
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+void
+_RecorderManager::InitSafeHashMapInst()
+{
+       static _RecorderManagerSafeHashMapT map;
+       result r = E_SUCCESS;
+
+       r = map.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pMap = &map;
+       return;
+CATCH:
+       __pMap = null;
+}
+
+_RecorderManager*
+_RecorderManager::AddInstance(_RecorderDeviceType recorderDevice)
+{
+       result r = E_SUCCESS;
+       bool out = false;
+       _RecorderManager* pManager = null;
+
+       SysTryReturn(NID_MEDIA, recorderDevice > _RECORDER_DEVICE_NONE && recorderDevice < _RECORDER_DEVICE_MAX,
+                               null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(recorderDevice) is used. recorderDevice:%d.", (int) recorderDevice);
+
+       static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+
+       if (!__pMap)
+       {
+               pthread_once(&once_block, InitSafeHashMapInst);
+               r = GetLastResult();
+               SysTryCatch(NID_MEDIA, __pMap != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       r = __pMap->ContainsKey(recorderDevice, out);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (out)
+       {
+               r = __pMap->GetValue(recorderDevice, pManager);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS && pManager != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else
+       {
+               _CameraDeviceType cameraDevice = _CAMERA_DEVICE_NONE;
+               switch (recorderDevice)
+               {
+               case _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA:
+                       cameraDevice = _CAMERA_DEVICE_PRIMARY;
+                       break;
+               case _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA:
+                       cameraDevice = _CAMERA_DEVICE_SECONDARY;
+                       break;
+               default:
+                       break;
+               }
+
+               pManager = new (std::nothrow) _RecorderManager();
+               SysTryCatch(NID_MEDIA, pManager !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The object is not created.");
+
+               r = pManager->Construct(cameraDevice, recorderDevice);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = __pMap->Add(recorderDevice, pManager);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       pManager->AddRefCount();
+       return pManager;
+
+CATCH:
+       if (pManager != null)
+       {
+               delete pManager;
+       }
+       return null;
+}
+
+void
+_RecorderManager::Release(_RecorderDeviceType recorderDevice)
+{
+       result r = E_SUCCESS;
+
+       if (__pMap != null)
+       {
+               _RecorderManager* pManager = null;
+               r = __pMap->GetValue(recorderDevice, pManager);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               if (pManager->ReleaseRefCount() == 0)
+               {
+                       delete pManager;
+                       r = __pMap->Remove(recorderDevice);
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+}
+
+_RecorderHandle
+_RecorderManager::GetHandle(void) const
+{
+       return __handle;
+}
+
+result
+_RecorderManager::ConvertResult(int err) const
+{
+       result r = E_SYSTEM;
+       if (err != ::RECORDER_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "MM Err:0x%x", err);
+       }
+
+       // Global error
+       if (err == ::RECORDER_ERROR_NONE)
+       {
+               r = E_SUCCESS;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_PARAMETER)
+       {
+               r = E_INVALID_ARG;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_STATE)
+       {
+               r = E_INVALID_STATE;
+       }
+       else if (err == ::RECORDER_ERROR_OUT_OF_MEMORY)
+       {
+               r = E_OUT_OF_MEMORY;
+       }
+       else if (err == ::RECORDER_ERROR_DEVICE)
+       {
+               r = E_DEVICE_FAILED;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_OPERATION
+               || err == ::RECORDER_ERROR_SOUND_POLICY
+               || err == ::RECORDER_ERROR_SECURITY_RESTRICTED)
+       {
+               r = E_SYSTEM;
+       }
+       else
+       {
+               r = E_UNKNOWN;
+       }
+
+       return r;
+}
+
+}}// Tizen::Media
diff --git a/src/FMedia_RecorderManager.h b/src/FMedia_RecorderManager.h
new file mode 100755 (executable)
index 0000000..c7432bc
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_RecorderManager.h
+ * @brief                      This header file contains the declarations of the %_RecorderManager class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_RECORDER_MANAGER_H_
+#define _FMEDIA_INTERNAL_RECORDER_MANAGER_H_
+
+#include <memory>
+#include <FBaseColHashMapT.h>
+#include "FMedia_RecorderTypes.h"
+#include "FMedia_CameraTypes.h"
+#include "FMedia_CameraRefHelper.h"
+
+namespace Tizen { namespace Media
+{
+class _RecorderManagerSafeHashMapT;
+
+/**
+ * @class      _RecorderManager
+ * @brief      This class implements the _RecorderManager class.
+ */
+class _RecorderManager
+       : public _CameraRefHelper
+{
+public:
+       /**
+       * Get the instance of _RecorderManager.
+       *
+       * @return               The _RecorderManager instance
+       * @param[in]    recorderDevice                  The recorder device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       static _RecorderManager* AddInstance(_RecorderDeviceType recorderDevice);
+
+       /**
+       * Release the specific _RecorderManager.
+       *
+       * @param[in]    recorderDevice                  The recorder device type.
+       */
+       static void Release(_RecorderDeviceType recorderDevice);
+
+       /**
+       * Gets the recorder's handle
+       *
+       * @return               The handle of camera
+       */
+       _RecorderHandle GetHandle(void) const;
+
+private:
+       friend class _RecorderManagerSafeHashMapT;
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to
+        * initialize this instance.
+        * @see                 Construct()
+        */
+       _RecorderManager(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread
+        * where the Construct() method is called.
+        *
+        * @see                 Construct()
+        */
+       virtual ~_RecorderManager(void);
+
+       /**
+       * Initializes this instance of _RecorderManager.
+       *
+       * @return               An error code
+       * @param[in]    cameraDevice                    The camera device id.
+       * @param[in]    recorderDevice          The recorder device id.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_DEVICE_UNAVAILABLE    The device is unavailable.
+       */
+       result Construct(_CameraDeviceType cameraDevice, _RecorderDeviceType recorderDevice);
+
+       /**
+       * Converts the error from recorder to Result.
+       *
+       * @return          An error code
+       * @param[in]    err                      recorder error
+       */
+       result ConvertResult(int err) const;
+
+       _RecorderManager(const _RecorderManager& camera);
+       _RecorderManager& operator =(const _RecorderManager& camera);
+
+       static void InitSafeHashMapInst(void);
+
+       _RecorderHandle __handle;
+
+       static _RecorderManagerSafeHashMapT* __pMap;
+};
+
+/**
+* @class       _RecorderManagerSafeHashMapT
+* @brief       This class is for handling safe HashMap.
+*
+*/
+class _RecorderManagerSafeHashMapT
+       : public Tizen::Base::Collection::HashMapT<_RecorderDeviceType, _RecorderManager*>
+       , public virtual Tizen::Base::Collection::ICollectionT <Tizen::Base::Collection::MapEntryT <_RecorderDeviceType, _RecorderManager*> >
+{
+public:
+       _RecorderManagerSafeHashMapT(void);
+       virtual ~_RecorderManagerSafeHashMapT(void);
+       void RemoveItems(void);
+
+private:
+       _RecorderManagerSafeHashMapT(const _RecorderManagerSafeHashMapT& rhs);
+       _RecorderManagerSafeHashMapT& operator =(const _RecorderManagerSafeHashMapT& rhs);
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_RecorderSession.cpp b/src/FMedia_RecorderSession.cpp
new file mode 100755 (executable)
index 0000000..8e0cb15
--- /dev/null
@@ -0,0 +1,204 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_RecorderSession.cpp
+ * @brief                      This file contains the implementation of the %_RecorderSession class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include "FMedia_RecorderManager.h"
+#include "FMedia_RecorderSession.h"
+#include "FMedia_CameraTypes.h"
+#include "FMedia_CameraCoordinator.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Media
+{
+
+_RecorderSession::_RecorderSession(void)
+       : __previousCameraMode(_CAMERA_MODE_NONE)
+       , __recorderDevice(_RECORDER_DEVICE_NONE)
+       , __handle(MM_INVALID_HANDLE)
+       , __pCoordinator(null)
+{
+}
+
+_RecorderSession::~_RecorderSession(void)
+{
+       result r = E_SUCCESS;
+
+       if (__recorderDevice == _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA ||__recorderDevice == _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA)
+       {
+               if (__pCoordinator)
+               {
+                       if (__previousCameraMode == _CAMERA_MODE_IMAGE)
+                       {
+                               r = __pCoordinator->ChangeMode(_CAMERA_MODE_IMAGE, false);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+                       SysLog(NID_MEDIA, "Release the recorder device:%d", __recorderDevice);
+                       _CameraCoordinator::Release(__recorderDevice);
+               }
+       }
+       else if (__recorderDevice == _RECORDER_DEVICE_AUDIO)
+       {
+               SysLog(NID_MEDIA, "Release the audio recorder.");
+               _RecorderManager::Release(__recorderDevice);
+       }
+       return;
+
+CATCH:
+       SysLogException(NID_MEDIA, r, "[%s] Error while deleting recorder session", GetErrorMessage(r));
+}
+
+result
+_RecorderSession::Construct(_RecorderDeviceType recorderDevice)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. recorder device:%d", recorderDevice);
+
+       if (recorderDevice == _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA ||recorderDevice == _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA)
+       {
+               __pCoordinator = _CameraCoordinator::AddInstance(recorderDevice);
+               SysTryCatch(NID_MEDIA, __pCoordinator != null, , E_SYSTEM, "[E_SYSTEM] The camera coordinator is null.");
+
+               if (__pCoordinator->GetMode() == _CAMERA_MODE_IMAGE)
+               {
+                       r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       __previousCameraMode = _CAMERA_MODE_IMAGE;
+               }
+               __handle = __pCoordinator->GetRecorderHandle();
+       }
+       else if (recorderDevice == _RECORDER_DEVICE_AUDIO)
+       {
+               _RecorderManager* pRecorderManager = null;
+
+               pRecorderManager = _RecorderManager::AddInstance(recorderDevice);
+               r = GetLastResult();
+               SysTryCatch(NID_MEDIA, pRecorderManager !=null, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __handle = pRecorderManager->GetHandle();
+       }
+
+       __recorderDevice = recorderDevice;
+       return r;
+
+CATCH:
+       __previousCameraMode = _CAMERA_MODE_NONE;
+       return r;
+}
+
+result
+_RecorderSession::Construct(_RecorderSourceType recorderSource)
+{
+       result r = E_SUCCESS;
+       _CameraDeviceType runningCamera = _CAMERA_DEVICE_NONE;
+       _RecorderDeviceType targetRecorder = _RECORDER_DEVICE_NONE;
+       SysLog(NID_MEDIA, "Enter.");
+
+       if (recorderSource == _RECORDER_SOURCE_VIDEO)
+       {
+               if (_CameraCoordinator::HasInstance(_RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA) != null)
+               {
+                       runningCamera = _CAMERA_DEVICE_PRIMARY;
+               }
+               else if (_CameraCoordinator::HasInstance(_RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA) != null)
+               {
+                       runningCamera = _CAMERA_DEVICE_SECONDARY;
+               }
+               else
+               {
+                       runningCamera = _CAMERA_DEVICE_PRIMARY;
+               }
+               __pCoordinator = _CameraCoordinator::AddInstance(runningCamera);
+               SysTryCatch(NID_MEDIA, __pCoordinator != null, , E_SYSTEM, "[E_SYSTEM] The camera coordinator is null.");
+
+               if (__pCoordinator->GetMode() == _CAMERA_MODE_IMAGE)
+               {
+                       if(__pCoordinator->IsCalmChangeMode(_CAMERA_MODE_VIDEO))
+                       {
+                               targetRecorder = (runningCamera == _CAMERA_DEVICE_PRIMARY ? _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA);
+                               r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                               __previousCameraMode = _CAMERA_MODE_IMAGE;
+                       }
+                       else
+                       {
+                               // If the current coordinator(camera) is not proper state to get the recorder without flickering.
+                               _CameraCoordinator::Release(runningCamera);
+
+                               // Pick the other camera for the recorder
+                               targetRecorder = (runningCamera == _CAMERA_DEVICE_PRIMARY ? _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA : _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA);
+
+                               // Get the other coordinator(camera)
+                               __pCoordinator = _CameraCoordinator::AddInstance(targetRecorder);
+                               SysTryCatch(NID_MEDIA, __pCoordinator != null, , E_SYSTEM, "[E_SYSTEM] The camera coordinator is null.");
+
+                               if(__pCoordinator->IsCalmChangeMode(_CAMERA_MODE_VIDEO))
+                               {
+                                       r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false);
+                                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                       __previousCameraMode = _CAMERA_MODE_IMAGE;
+                               }
+                               else
+                               {
+                                       SysLogException(NID_MEDIA, E_SYSTEM, "[E_SYSTEM] Both cameras' state are not proper to change mode.");
+                                       goto CATCH;
+                               }
+                       }
+               }
+               else if (__pCoordinator->GetMode() == _CAMERA_MODE_VIDEO)
+               {
+                       targetRecorder = (runningCamera == _CAMERA_DEVICE_PRIMARY ? _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA);
+                       __previousCameraMode = _CAMERA_MODE_VIDEO;
+               }
+               else
+               {
+                       SysLogException(NID_MEDIA, E_SYSTEM, "[E_SYSTEM] Camera is not working properly.");
+                       goto CATCH;
+               }
+               __handle = __pCoordinator->GetRecorderHandle();
+               __recorderDevice = targetRecorder;
+       }
+       else if (recorderSource == _RECORDER_SOURCE_AUDIO)
+       {
+               _RecorderManager* pRecorderManager = null;
+
+               pRecorderManager = _RecorderManager::AddInstance(_RECORDER_DEVICE_AUDIO);
+               r = GetLastResult();
+               SysTryCatch(NID_MEDIA, pRecorderManager !=null, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __handle = pRecorderManager->GetHandle();
+               __recorderDevice = _RECORDER_DEVICE_AUDIO;
+       }
+
+       return r;
+CATCH:
+       return r;
+}
+
+_RecorderHandle
+_RecorderSession::GetHandle(void)
+{
+       return __handle;
+}
+
+}}// Tizen::Media
diff --git a/src/FMedia_RecorderSession.h b/src/FMedia_RecorderSession.h
new file mode 100755 (executable)
index 0000000..e66b31e
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_RecorderSession.h
+ * @brief                      This header file contains the declarations of the %_RecorderSession class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_RECORDER_SESSION_H_
+#define _FMEDIA_INTERNAL_RECORDER_SESSION_H_
+
+#include <FBaseObject.h>
+#include "FMedia_RecorderTypes.h"
+
+namespace Tizen { namespace Media
+{
+
+class _CameraCoordinator;
+
+/**
+* @class       _RecorderSession
+* @brief       This class is common for recorder session.
+*
+*/
+class _RecorderSession
+       : public Tizen::Base::Object
+{
+public:
+       _RecorderSession(void);
+       virtual ~_RecorderSession(void);
+
+       result Construct(_RecorderSourceType recorderSource);
+       result Construct(_RecorderDeviceType recorderDevice);
+       _RecorderHandle GetHandle(void);
+
+private:
+       _CameraMode __previousCameraMode;
+       _RecorderDeviceType __recorderDevice;
+       _RecorderHandle __handle;
+       _CameraCoordinator* __pCoordinator;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_RecorderTypes.h b/src/FMedia_RecorderTypes.h
new file mode 100755 (executable)
index 0000000..f270d54
--- /dev/null
@@ -0,0 +1,100 @@
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//     http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+
+/**
+ * @file                       FMedia_RecorderTypes.h
+ * @brief                      This header file contains the types of the recorder.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_RECORDER_TYPES_H_
+#define _FMEDIA_INTERNAL_RECORDER_TYPES_H_
+
+#include <recorder.h>
+
+namespace Tizen { namespace Media
+{
+
+typedef recorder_h _RecorderHandle;\r
+
+#define MM_INVALID_HANDLE 0
+#define MEDIA_INVALID_VALUE -1
+#define MM_SUCCESS 0
+
+//
+// @enum _RecorderEventType\r
+// @ This represents VRecorder's event type.
+//
+enum _RecorderEventType\r
+{
+       _RECORDER_EVENT_NONE,                                                             /**< Event_None */\r
+
+       _RECORDER_EVENT_RECORDING_STARTED,                                       /**< Recorder recording event*/\r
+       _RECORDER_EVENT_STOPPED,                                         /**< Recorder Stopped event */\r
+       _RECORDER_EVENT_CANCELED,                                        /**< Recorder Canceled event */\r
+       _RECORDER_EVENT_ENDOF_FILESIZE,                                  /**< Recorder reached to end of file size event */\r
+       _RECORDER_EVENT_ENDOF_RECTIME,                                   /**< Recorder reached to end of recording time event */\r
+       _RECORDER_EVENT_PAUSED,                                  /**< Recorder Paused event */\r
+       _RECORDER_EVENT_CLOSED,                                  /**< Recorder Closed event */\r
+       _RECORDER_EVENT_INTERRUPTED,                     /**< Interrupted event */\r
+       _RECORDER_EVENT_RELEASED,                               /**< Released event */\r
+
+       _RECORDER_EVENT_ERROR,                     /**< Error event */\r
+};
+
+//
+// @enum _RecorderDeviceType\r
+// Defines the recorder's device type
+//
+enum _RecorderDeviceType\r
+{
+       _RECORDER_DEVICE_NONE,            /**< The recorder none */\r
+       _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA,          /**< The video recorder using primary camera*/\r
+       _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA,                /**< The video recorder using secondary camera*/\r
+       _RECORDER_DEVICE_AUDIO,         /**< The audio recorder */\r
+       _RECORDER_DEVICE_MAX                    /**< The max boundary */\r
+};
+\r
+//\r
+// @enum _RecorderSourceType\r
+// Defines the recorder's source type\r
+//\r
+enum _RecorderSourceType\r
+{\r
+       _RECORDER_SOURCE_NONE,            /**< The recorder source none */\r
+       _RECORDER_SOURCE_AUDIO,           /**< The recorder source audio */\r
+       _RECORDER_SOURCE_VIDEO,           /**< The recorder source video */\r
+       _RECORDER_SOURCE_MAX                    /**< The max boundary */\r
+};\r
+\r
+//
+// @enum _RecorderStateChangeReason\r
+// @ This reason of state changing.
+//
+enum _RecorderStateChangeReason\r
+{
+       _RECORDER_STATE_REASON_NORMAL,\r
+       _RECORDER_STATE_REASON_STOP,\r
+       _RECORDER_STATE_REASON_CANCEL,\r
+       _RECORDER_STATE_REASON_END_SIZE_REACHED,\r
+       _RECORDER_STATE_REASON_END_TIME_REACHED,\r
+       _RECORDER_STATE_REASON_OUT_OF_STORAGE,\r
+};
+
+}}
+
+#endif
diff --git a/src/FMedia_RecorderUtil.cpp b/src/FMedia_RecorderUtil.cpp
new file mode 100755 (executable)
index 0000000..4953a59
--- /dev/null
@@ -0,0 +1,557 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_RecorderUtil.cpp
+ * @brief                      This file contains the utility of camcorder.
+ *
+ */
+
+#include <FIoFile.h>
+#include <FBaseSysLog.h>
+#include "FMedia_RecorderUtil.h"
+
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Media
+{
+
+typedef struct
+{
+       Tizen::Media::CodecType audioCodec;
+       Tizen::Media::CodecType videoCodec;
+       Tizen::Media::MediaContainerType container;
+} _CodecContainerTable;
+
+const static _CodecContainerTable _SUPPORTED_CODEC_CONTAINER[] =
+{
+       //Audio
+       { CODEC_LPCM,           CODEC_NONE,             MEDIA_CONTAINER_WAV},
+       { CODEC_AMR_NB,         CODEC_NONE,             MEDIA_CONTAINER_AMR},
+       { CODEC_AMR_NB,         CODEC_NONE,             MEDIA_CONTAINER_3GP},
+//     { CODEC_AMR_NB,         CODEC_NONE,             MEDIA_CONTAINER_MP4},
+       { CODEC_AAC,            CODEC_NONE,             MEDIA_CONTAINER_AAC},
+       {  CODEC_AAC,           CODEC_NONE,             MEDIA_CONTAINER_3GP},
+       {  CODEC_AAC,           CODEC_NONE,             MEDIA_CONTAINER_MP4},
+
+       // Video
+       { CODEC_AMR_NB,         CODEC_MPEG4,            MEDIA_CONTAINER_3GP},
+       { CODEC_AMR_NB,         CODEC_H263,             MEDIA_CONTAINER_3GP},
+       { CODEC_AMR_NB,         CODEC_H264,             MEDIA_CONTAINER_3GP},
+//     { CODEC_AMR_NB,         CODEC_MPEG4,            MEDIA_CONTAINER_MP4},
+//     { CODEC_AMR_NB,         CODEC_H263,             MEDIA_CONTAINER_MP4},
+//     { CODEC_AMR_NB,         CODEC_H264,             MEDIA_CONTAINER_MP4},
+
+       { CODEC_AAC,    CODEC_MPEG4,            MEDIA_CONTAINER_3GP},
+       { CODEC_AAC,    CODEC_H263,             MEDIA_CONTAINER_3GP},
+       { CODEC_AAC,    CODEC_H264,             MEDIA_CONTAINER_3GP},
+       { CODEC_AAC,    CODEC_MPEG4,            MEDIA_CONTAINER_MP4},
+//     { CODEC_AAC,    CODEC_H263,             MEDIA_CONTAINER_MP4},
+       { CODEC_AAC,    CODEC_H264,             MEDIA_CONTAINER_MP4},
+
+       { CODEC_NONE,   CODEC_MPEG4,            MEDIA_CONTAINER_3GP},
+       { CODEC_NONE,   CODEC_H263,             MEDIA_CONTAINER_3GP},
+       { CODEC_NONE,   CODEC_H264,             MEDIA_CONTAINER_3GP},
+       { CODEC_NONE,   CODEC_MPEG4,            MEDIA_CONTAINER_MP4},
+//     { CODEC_NONE,   CODEC_H263,             MEDIA_CONTAINER_MP4},
+       { CODEC_NONE,   CODEC_H264,             MEDIA_CONTAINER_MP4},
+};
+
+
+typedef struct
+{
+       recorder_audio_codec_e mmAttr;
+       CodecType value;
+}_AudioCodecTable;
+
+static const _AudioCodecTable _AUDIO_CODEC[] =
+{
+       {::RECORDER_AUDIO_CODEC_DISABLE, CODEC_NONE},
+       {::RECORDER_AUDIO_CODEC_AMR, CODEC_AMR_NB},
+       {::RECORDER_AUDIO_CODEC_AAC, CODEC_AAC},
+//     {::RECORDER_AUDIO_CODEC_VORBIS, CODEC_VORBIS},//We do not supported VORBIS CODEC TYPE
+       {::RECORDER_AUDIO_CODEC_PCM, CODEC_LPCM},
+};
+
+result
+_RecorderUtil::GetMmAudioCodec(CodecType value, recorder_audio_codec_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_AUDIO_CODEC)/sizeof(_AUDIO_CODEC[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_AUDIO_CODEC[i].value == value)
+               {
+                       mmAttr = _AUDIO_CODEC[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_RecorderUtil::GetOspAudioCodec(recorder_audio_codec_e mmAttr, CodecType& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_AUDIO_CODEC)/sizeof(_AUDIO_CODEC[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_AUDIO_CODEC[i].mmAttr == mmAttr)
+               {
+                       value = _AUDIO_CODEC[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       recorder_video_codec_e mmAttr;
+       CodecType value;
+}_VideoCodecTable;
+
+static const _VideoCodecTable _VIDEO_CODEC[] =
+{
+       {::RECORDER_VIDEO_CODEC_H263, CODEC_H263},
+       {::RECORDER_VIDEO_CODEC_H264, CODEC_H264},
+       {::RECORDER_VIDEO_CODEC_MPEG4, CODEC_MPEG4},
+//     {::RECORDER_VIDEO_CODEC_THEORA, CODEC_THEORA},
+};
+
+result
+_RecorderUtil::GetMmVideoCodec(CodecType value, recorder_video_codec_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_VIDEO_CODEC)/sizeof(_VIDEO_CODEC[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_VIDEO_CODEC[i].value == value)
+               {
+                       mmAttr = _VIDEO_CODEC[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_RecorderUtil::GetOspVideoCodec(recorder_video_codec_e mmAttr, CodecType& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_VIDEO_CODEC)/sizeof(_VIDEO_CODEC[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_VIDEO_CODEC[i].mmAttr == mmAttr)
+               {
+                       value = _VIDEO_CODEC[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       recorder_file_format_e mmAttr;
+       MediaContainerType value;
+}_ContainerTable;
+
+static const _ContainerTable _CONTAINER[] =
+{
+       {::RECORDER_FILE_FORMAT_3GP, MEDIA_CONTAINER_3GP},
+       {::RECORDER_FILE_FORMAT_MP4, MEDIA_CONTAINER_MP4},
+       {::RECORDER_FILE_FORMAT_AMR, MEDIA_CONTAINER_AMR},
+       {::RECORDER_FILE_FORMAT_ADTS, MEDIA_CONTAINER_AAC},
+       {::RECORDER_FILE_FORMAT_WAV, MEDIA_CONTAINER_WAV},
+};
+
+
+typedef struct
+{
+               recorder_file_format_e mmAttr;
+               MediaContainerType value;
+}_VideoContainerTable;
+
+static const _VideoContainerTable _VIDEO_CONTAINER[] =
+{
+       {::RECORDER_FILE_FORMAT_3GP, MEDIA_CONTAINER_3GP},
+       {::RECORDER_FILE_FORMAT_MP4, MEDIA_CONTAINER_MP4},
+};
+
+typedef struct
+{
+               recorder_file_format_e mmAttr;
+               MediaContainerType value;
+}_ContainerVideoTable;
+
+result
+_RecorderUtil::GetMmFileFormat(MediaContainerType value, recorder_file_format_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_CONTAINER)/sizeof(_CONTAINER[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CONTAINER[i].value == value)
+               {
+                       mmAttr = _CONTAINER[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_RecorderUtil::GetOspVideoContainer(recorder_file_format_e mmAttr, MediaContainerType& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_VIDEO_CONTAINER)/sizeof(_VIDEO_CONTAINER[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_VIDEO_CONTAINER[i].mmAttr == mmAttr)
+               {
+                       value = _VIDEO_CONTAINER[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_RecorderUtil::GetOspAudioContainer(recorder_file_format_e mmAttr, MediaContainerType& value)
+{
+               bool findFlag = false;
+               int size = sizeof(_CONTAINER)/sizeof(_CONTAINER[0]);
+
+               for (int i = 0; i < size; i++)
+               {
+                               if (_CONTAINER[i].mmAttr == mmAttr)
+                               {
+                                               value = _CONTAINER[i].value;
+                                               findFlag = true;
+                                               break;
+                               }
+               }
+               return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       int mmAttrSamplerate;
+       int mmAttrChannel;
+       int mmAttrBitrate;
+       CodecType audioCodec;
+       RecordingQuality quality;
+}_AudioQualityTable;
+
+static const _AudioQualityTable _AUDIO_QUALITY[] =
+{
+       {8000, 1, 256000, CODEC_LPCM, RECORDING_QUALITY_LOW},
+       {22050, 2, 706000, CODEC_LPCM, RECORDING_QUALITY_MEDIUM},
+       {44100, 2, 1411000, CODEC_LPCM, RECORDING_QUALITY_HIGH},
+       {8000, 1, 4750, CODEC_AMR_NB, RECORDING_QUALITY_LOW},
+       {8000, 1, 7950, CODEC_AMR_NB, RECORDING_QUALITY_MEDIUM},
+       {8000, 1, 12200, CODEC_AMR_NB, RECORDING_QUALITY_HIGH},
+       {22050, 2, 120000, CODEC_AAC, RECORDING_QUALITY_LOW},
+       {44100, 2, 220000, CODEC_AAC, RECORDING_QUALITY_MEDIUM},
+       {44100, 2, 320000, CODEC_AAC, RECORDING_QUALITY_HIGH},
+};
+
+result
+_RecorderUtil::GetMmAudioQuality(CodecType audioCodec, RecordingQuality quality, int& mmAttrSamplerate, int& mmAttrChannel, int& mmAttrBitrate)
+{
+       bool findFlag = false;
+       int size = sizeof(_AUDIO_QUALITY)/sizeof(_AUDIO_QUALITY[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_AUDIO_QUALITY[i].audioCodec == audioCodec && _AUDIO_QUALITY[i].quality == quality)
+               {
+                       mmAttrSamplerate = _AUDIO_QUALITY[i].mmAttrSamplerate;
+                       mmAttrChannel = _AUDIO_QUALITY[i].mmAttrChannel;
+                       mmAttrBitrate = _AUDIO_QUALITY[i].mmAttrBitrate;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       int mmAttrBitrate;
+       _ResolutionType resolution;
+       RecordingQuality quality;
+}_VideoQualityTable;
+
+static const _VideoQualityTable _VIDEO_QUALITY[] =
+{
+       {48000, _RES_128X96, RECORDING_QUALITY_LOW},
+       {64000, _RES_128X96, RECORDING_QUALITY_MEDIUM},
+       {80000, _RES_128X96, RECORDING_QUALITY_HIGH},
+       {72000, _RES_160X120, RECORDING_QUALITY_LOW},
+       {97000, _RES_160X120, RECORDING_QUALITY_MEDIUM},
+       {120000, _RES_160X120, RECORDING_QUALITY_HIGH},
+       {96000, _RES_176X144, RECORDING_QUALITY_LOW},
+       {128000, _RES_176X144, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_176X144, RECORDING_QUALITY_HIGH},
+       {96000, _RES_176X176, RECORDING_QUALITY_LOW},
+       {128000, _RES_176X176, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_176X176, RECORDING_QUALITY_HIGH},
+       {96000, _RES_240X320, RECORDING_QUALITY_LOW},
+       {128000, _RES_240X320, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_240X320, RECORDING_QUALITY_HIGH},
+       {96000, _RES_320X240, RECORDING_QUALITY_LOW},
+       {128000, _RES_320X240, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_320X240, RECORDING_QUALITY_HIGH},
+       {96000, _RES_240X400, RECORDING_QUALITY_LOW},
+       {128000, _RES_240X400, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_240X400, RECORDING_QUALITY_HIGH},
+       {96000, _RES_400X240, RECORDING_QUALITY_LOW},
+       {128000, _RES_400X240, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_400X240, RECORDING_QUALITY_HIGH},
+       {96000, _RES_352X288, RECORDING_QUALITY_LOW},
+       {128000, _RES_352X288, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_352X288, RECORDING_QUALITY_HIGH},
+       {96000, _RES_480X360, RECORDING_QUALITY_LOW},
+       {128000, _RES_480X360, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_480X360, RECORDING_QUALITY_HIGH},
+       {96000, _RES_640X360, RECORDING_QUALITY_LOW},
+       {128000, _RES_640X360, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_640X360, RECORDING_QUALITY_HIGH},
+
+       {2000000, _RES_640X480, RECORDING_QUALITY_LOW},
+       {2500000, _RES_640X480, RECORDING_QUALITY_MEDIUM},
+       {3000000, _RES_640X480, RECORDING_QUALITY_HIGH},
+       {2200000, _RES_720X480, RECORDING_QUALITY_LOW},
+       {2800000, _RES_720X480, RECORDING_QUALITY_MEDIUM},
+       {3300000, _RES_720X480, RECORDING_QUALITY_HIGH},
+
+       {96000, _RES_800X480, RECORDING_QUALITY_LOW},
+       {128000, _RES_800X480, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_800X480, RECORDING_QUALITY_HIGH},
+       {96000, _RES_800X600, RECORDING_QUALITY_LOW},
+       {128000, _RES_800X600, RECORDING_QUALITY_MEDIUM},
+       {160000, _RES_800X600, RECORDING_QUALITY_HIGH},
+
+       {2000000, _RES_960X720, RECORDING_QUALITY_LOW},
+       {2500000, _RES_960X720, RECORDING_QUALITY_MEDIUM},
+       {3000000, _RES_960X720, RECORDING_QUALITY_HIGH},
+
+       {2000000, _RES_1280X720, RECORDING_QUALITY_LOW},
+       {2500000, _RES_1280X720, RECORDING_QUALITY_MEDIUM},
+       {3000000, _RES_1280X720, RECORDING_QUALITY_HIGH},
+
+       {2000000, _RES_1280X960, RECORDING_QUALITY_LOW},
+       {2500000, _RES_1280X960, RECORDING_QUALITY_MEDIUM},
+       {3000000, _RES_1280X960, RECORDING_QUALITY_HIGH},
+
+       {2000000, _RES_1392X1392, RECORDING_QUALITY_LOW},
+       {2500000, _RES_1392X1392, RECORDING_QUALITY_MEDIUM},
+       {3000000, _RES_1392X1392, RECORDING_QUALITY_HIGH},
+
+       {2200000, _RES_1600X1200, RECORDING_QUALITY_LOW},
+       {2800000, _RES_1600X1200, RECORDING_QUALITY_MEDIUM},
+       {3300000, _RES_1600X1200, RECORDING_QUALITY_HIGH},
+       {2200000, _RES_1920X1080, RECORDING_QUALITY_LOW},
+       {2800000, _RES_1920X1080, RECORDING_QUALITY_MEDIUM},
+       {3300000, _RES_1920X1080, RECORDING_QUALITY_HIGH},
+};
+
+result
+_RecorderUtil::GetMmVideoQuality(_ResolutionType resolution, RecordingQuality quality, int& mmAttrBitrate)
+{
+       bool findFlag = false;
+       int size = sizeof(_VIDEO_QUALITY)/sizeof(_VIDEO_QUALITY[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_VIDEO_QUALITY[i].resolution == resolution && _VIDEO_QUALITY[i].quality == quality)
+               {
+                       mmAttrBitrate = _VIDEO_QUALITY[i].mmAttrBitrate;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       recorder_rotation_e mmAttr;
+       RecordingRotation value;
+}_RotationTable;
+
+static const _RotationTable _ROTATION[] =
+{
+       {RECORDER_ROTATION_NONE, RECORDING_ROTATION_NONE},
+       {RECORDER_ROTATION_90, RECORDING_ROTATION_90},
+       {RECORDER_ROTATION_180, RECORDING_ROTATION_180},
+       {RECORDER_ROTATION_270, RECORDING_ROTATION_270},
+};
+
+result
+_RecorderUtil::GetMmRotation(RecordingRotation value, recorder_rotation_e& mmAttr)
+{
+       bool findFlag = false;
+       int size = sizeof(_ROTATION)/sizeof(_ROTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_ROTATION[i].value == value)
+               {
+                       mmAttr = _ROTATION[i].mmAttr;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_RecorderUtil::GetOspRotation(recorder_rotation_e mmAttr, RecordingRotation& value)
+{
+       bool findFlag = false;
+       int size = sizeof(_ROTATION)/sizeof(_ROTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_ROTATION[i].mmAttr == mmAttr)
+               {
+                       value = _ROTATION[i].value;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+typedef struct
+{
+       CameraRotation cameraRotation;
+       RecordingRotation recorderRotation;
+}CameraRecorderRotationTable;
+
+static const CameraRecorderRotationTable _CAM_REC_ROTATION[] =
+{
+       {CAMERA_ROTATION_NONE, RECORDING_ROTATION_NONE},
+       {CAMERA_ROTATION_90, RECORDING_ROTATION_90},
+       {CAMERA_ROTATION_180, RECORDING_ROTATION_180},
+       {CAMERA_ROTATION_270, RECORDING_ROTATION_270},
+};
+
+result
+_RecorderUtil::GetRecorderRotation(CameraRotation cameraRotation, RecordingRotation& recorderRotation)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAM_REC_ROTATION)/sizeof(_CAM_REC_ROTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAM_REC_ROTATION[i].cameraRotation == cameraRotation)
+               {
+                       recorderRotation = _CAM_REC_ROTATION[i].recorderRotation;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+result
+_RecorderUtil::GetCameraRotation(RecordingRotation recorderRotation, CameraRotation& cameraRotation)
+{
+       bool findFlag = false;
+       int size = sizeof(_CAM_REC_ROTATION)/sizeof(_CAM_REC_ROTATION[0]);
+
+       for (int i = 0; i < size; i++)
+       {
+               if (_CAM_REC_ROTATION[i].recorderRotation == recorderRotation)
+               {
+                       cameraRotation = _CAM_REC_ROTATION[i].cameraRotation;
+                       findFlag = true;
+                       break;
+               }
+       }
+       return findFlag ? E_SUCCESS : E_UNSUPPORTED_TYPE;
+}
+
+bool
+_RecorderUtil::CheckFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container)
+{
+       bool supported = false;
+       int tableCount = 0;
+       tableCount = sizeof(_SUPPORTED_CODEC_CONTAINER) / sizeof(_SUPPORTED_CODEC_CONTAINER[0]);
+
+       for (int i = 0; i < tableCount; i++)
+       {
+               if (audioCodec == _SUPPORTED_CODEC_CONTAINER[i].audioCodec && videoCodec == _SUPPORTED_CODEC_CONTAINER[i].videoCodec && container == _SUPPORTED_CODEC_CONTAINER[i].container)
+               {
+                       supported = true;
+                       break;
+               }
+       }
+       return supported;
+}
+
+result
+_RecorderUtil::PrepareFile(const Tizen::Base::String& path, bool overwrite)
+{
+       result r = E_SUCCESS;
+
+       if (File::IsFileExist(path))
+       {
+               if (overwrite)
+               {
+                       r = File::Remove(path);
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder remove existing file failed. path:%ls", GetErrorMessage(r), path.GetPointer());
+               }
+               else
+               {
+                       r = E_FILE_ALREADY_EXIST;
+                       SysLogException(NID_MEDIA, r, "[E_FILE_ALREADY_EXIST] The file already exists and overwrite is false. path:%ls", path.GetPointer());
+                       goto CATCH;
+               }
+       }
+       else
+       {
+               File file;
+               r = file.Construct(path, L"w");
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_RESOURCE_UNAVAILABLE, E_RESOURCE_UNAVAILABLE, "[E_RESOURCE_UNAVAILABLE] The file path is not available. path:%ls", path.GetPointer());
+               r = File::Remove(path);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder remove temp file failed. path:%ls", GetErrorMessage(r), path.GetPointer());
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+}}// Tizen::Media
diff --git a/src/FMedia_RecorderUtil.h b/src/FMedia_RecorderUtil.h
new file mode 100755 (executable)
index 0000000..e8563fc
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_RecorderUtil.h
+ * @brief                      This header file contains the declarations of the utility fuctions of recorder.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_RECORDER_UTIL_H_
+#define _FMEDIA_INTERNAL_RECORDER_UTIL_H_
+
+#include <recorder.h>
+#include <FMediaTypes.h>
+#include <FMediaCameraTypes.h>
+#include <FMediaRecorderTypes.h>
+#include "FMedia_CameraTypes.h"
+
+namespace Tizen { namespace Media
+{
+/**
+* @class       _RecorderUtil
+* @brief       This class is utility for recorder functionality.
+*
+*/
+class _RecorderUtil
+       : public Tizen::Base::Object
+{
+public:
+
+       static result GetMmAudioCodec(CodecType value, recorder_audio_codec_e& mmAttr);
+       static result GetOspAudioCodec(recorder_audio_codec_e mmAttr, CodecType& value);
+       static result GetMmVideoCodec(CodecType value, recorder_video_codec_e& mmAttr);
+       static result GetOspVideoCodec(recorder_video_codec_e mmAttr, CodecType& value);
+       static result GetMmFileFormat(MediaContainerType value, recorder_file_format_e& mmAttr);
+       static result GetOspVideoContainer(recorder_file_format_e mmAttr, MediaContainerType& value);
+       static result GetOspAudioContainer(recorder_file_format_e mmAttr, MediaContainerType& value);
+
+       static result GetMmAudioQuality(CodecType audioCodec, RecordingQuality quality, int& mmAttrSamplerate, int& mmAttrChannel, int& mmAttrBitrate);
+       static result GetMmVideoQuality(_ResolutionType resolution, RecordingQuality quality, int& mmAttrBitrate);
+
+       static result GetMmRotation(RecordingRotation value, recorder_rotation_e& mmAttr);
+       static result GetOspRotation(recorder_rotation_e mmAttr, RecordingRotation& value);
+
+       static result GetRecorderRotation(CameraRotation cameraRotation, RecordingRotation& recorderRotation);
+       static result GetCameraRotation(RecordingRotation recorderRotation, CameraRotation& cameraRotation);
+
+       static bool CheckFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container);
+       static result PrepareFile(const Tizen::Base::String &path, bool overwrite);
+
+private:
+       _RecorderUtil(void);
+       ~_RecorderUtil(void);
+
+       _RecorderUtil(const _RecorderUtil& rhs);
+       _RecorderUtil& operator =(const _RecorderUtil& rhs);
+};
+
+}}
+
+#endif
diff --git a/src/FMedia_ToneGenerator.cpp b/src/FMedia_ToneGenerator.cpp
new file mode 100644 (file)
index 0000000..f214d10
--- /dev/null
@@ -0,0 +1,65 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <math.h>
+#include <FMediaToneTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_ToneGenerator.h"
+
+using namespace Tizen::Base;
+namespace Tizen {namespace Media
+{
+
+_ToneGenerator::_ToneGenerator(void)
+{
+}
+
+_ToneGenerator::~_ToneGenerator(void)
+{
+}
+
+bool
+_ToneGenerator::GenerateTone(Tizen::Base::ByteBuffer& toneBuffer, const int& firstFrequency, const int& secondFrequency,
+                                                        long startSample, long endSample,
+                                                        int volume)
+{
+       result r = E_SUCCESS;
+       short tempTone = 0;
+       float first = 2 * M_PI * firstFrequency / (float) SAMPLING_RATE;
+       float second = 2 * M_PI * secondFrequency / (float) SAMPLING_RATE;
+       int j = toneBuffer.GetPosition();
+
+       //Gives the number of samples
+       j = j / _BYTES_PER_SAMPLE;
+
+       // Generate tone for the given samples
+       for (long i = startSample; i < endSample; i++, j++)
+       {
+               tempTone = ((sin(first * i) + sin(second * i)) * ((_MAX_TONE_PLAYER_VOLUME_VALUE * volume) / 100));
+               r = toneBuffer.SetShort(_BYTES_PER_SAMPLE * j, tempTone);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS , false, false, "[%s] Propagating", GetErrorMessage(r));
+
+       }
+
+       r = toneBuffer.SetPosition((j) * _BYTES_PER_SAMPLE);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS , false, false, "[%s] Propagating", GetErrorMessage(r));
+
+       return true;
+}
+
+};
+};
diff --git a/src/FMedia_ToneGenerator.h b/src/FMedia_ToneGenerator.h
new file mode 100644 (file)
index 0000000..965a858
--- /dev/null
@@ -0,0 +1,45 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_TonePlayerGenerator.h
+// @brief                      This header file contains the declaration related to TonePlayer class
+//
+//
+
+#ifndef _FMEDIA_INTERNAL_TONE_GENERATOR_
+#define _FMEDIA_INTERNAL_TONE_GENERATOR_
+
+
+namespace Tizen { namespace Media
+{
+static const int _MAX_TONE_PLAYER_VOLUME_VALUE = 16383;
+static const int _BYTES_PER_SAMPLE = 2;
+
+class _ToneGenerator
+       : public Tizen::Base::Object
+{
+public:
+       _ToneGenerator(void);
+       ~_ToneGenerator(void);
+       static bool GenerateTone(Tizen::Base::ByteBuffer& toneBuffer, const int& firstFrequency, const int& secondFrequency, long startSample, long endSample, int volume);
+
+};     //_ToneGenerator
+
+}} //Tizen::Media
+
+#endif
diff --git a/src/FMedia_TonePlayerEvent.cpp b/src/FMedia_TonePlayerEvent.cpp
new file mode 100644 (file)
index 0000000..a8d3844
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FBaseSysLog.h>
+#include "FMedia_TonePlayerEvent.h"
+#include "FMedia_TonePlayerEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Media
+{
+
+_TonePlayerEvent::_TonePlayerEvent(void)
+{
+       __pListener = null;
+       __pTonePlayerSrc = null;
+}
+
+_TonePlayerEvent::~_TonePlayerEvent(void)
+{
+       __pListener = null;
+       __pTonePlayerSrc = null;
+}
+
+result
+_TonePlayerEvent::Construct(const TonePlayer& src)
+{
+       result r = E_SUCCESS;
+       __pTonePlayerSrc = &(const_cast <TonePlayer&>(src));
+       r = _Event::Initialize();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+}
+
+void
+_TonePlayerEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       ITonePlayerEventListener* pTonePlayerEventListener = dynamic_cast<ITonePlayerEventListener*> (&listener);
+       SysTryReturn(NID_MEDIA, pTonePlayerEventListener != null, , E_SYSTEM,
+                                               "[E_SYSTEM] A system error has been occurred. pTonePlayerEventListener is null.");
+
+       __pListener = pTonePlayerEventListener;
+       const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
+       _TonePlayerEventTypeArg* pArg = (_TonePlayerEventTypeArg*) pTempArg;
+       SysTryReturn(NID_MEDIA, pArg, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pArg is null.");
+       switch (pArg->GetEventType())
+       {
+       case _TONEPLAYER_EVENT_END_OF_PLAY_REACHED:
+               __pListener->OnTonePlayerEndOfTone(*__pTonePlayerSrc);
+               break;
+       case _TONEPLAYER_EVENT_INTERRUPTED:
+               pTonePlayerEventListener->OnTonePlayerInterrupted(*__pTonePlayerSrc);
+               break;
+       case _TONEPLAYER_EVENT_RELEASED:
+               pTonePlayerEventListener->OnTonePlayerReleased(*__pTonePlayerSrc);
+               break;
+       case _TONEPLAYER_EVENT_AUDIO_FOCUS_CHAGNED:
+               pTonePlayerEventListener->OnTonePlayerAudioFocusChanged(*__pTonePlayerSrc);
+               break;
+       case _TONEPLAYER_EVENT_ERROR:
+               {
+                       _TonePlayerErrorArg *pTonePlayerErrorArg = null;
+                       pTonePlayerErrorArg = dynamic_cast<_TonePlayerErrorArg *>(pArg);
+                       if (pTonePlayerErrorArg)
+                       {
+                               pTonePlayerEventListener->OnTonePlayerErrorOccurred(*__pTonePlayerSrc,pTonePlayerErrorArg->GetError());
+                       }
+                       break;
+               }
+       default:
+               break;
+       }
+}
+
+};
+};
diff --git a/src/FMedia_TonePlayerEvent.h b/src/FMedia_TonePlayerEvent.h
new file mode 100644 (file)
index 0000000..738eb9e
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_TonePlayerEvent.h
+// @brief                      This header file contains the declaration related to TonePlayer class
+//
+//
+
+#ifndef _FMEDIA_INTERNAL_TONEPLAYER_EVENT_H_
+#define _FMEDIA_INTERNAL_TONEPLAYER_EVENT_H_
+
+#include <FBaseRt_Event.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaTonePlayer.h>
+
+namespace Tizen {namespace Media
+{
+class _TonePlayerEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       _TonePlayerEvent(void);
+       ~_TonePlayerEvent(void);
+       result Construct(const TonePlayer& Src);
+protected:
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+private:
+       TonePlayer* __pTonePlayerSrc;
+       ITonePlayerEventListener* __pListener;
+};     // end of _TonePlayerEvent
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/FMedia_TonePlayerEventArg.cpp b/src/FMedia_TonePlayerEventArg.cpp
new file mode 100644 (file)
index 0000000..64876a5
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMedia_TonePlayerEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+_TonePlayerEventTypeArg::_TonePlayerEventTypeArg(void)
+       : __eventType(_TONEPLAYER_EVENT_NONE)
+{
+
+}
+
+_TonePlayerEventTypeArg::~_TonePlayerEventTypeArg(void)
+{
+
+}
+
+void
+_TonePlayerEventTypeArg::SetEventType(_TonePlayerEventType eType)
+{
+       __eventType = eType;
+}
+
+_TonePlayerEventType
+_TonePlayerEventTypeArg::GetEventType(void) const
+{
+       return __eventType;
+}
+
+_TonePlayerEventArg::_TonePlayerEventArg(void)
+       : __boolFlag(false)
+       , __result(E_SUCCESS)
+{
+
+}
+
+_TonePlayerEventArg::~_TonePlayerEventArg(void)
+{
+
+}
+
+void
+_TonePlayerEventArg::SetBoolFlag(bool boolFlag)
+{
+       __boolFlag = boolFlag;
+}
+
+bool
+_TonePlayerEventArg::GetBoolFlag(void) const
+{
+       return __boolFlag;
+}
+
+_TonePlayerErrorArg::_TonePlayerErrorArg(void)
+       : __result(E_UNKNOWN)
+{
+
+}
+
+_TonePlayerErrorArg::~_TonePlayerErrorArg(void)
+{
+
+}
+
+void
+_TonePlayerErrorArg::SetError(result r)
+{
+       __result = r;
+}
+
+result
+_TonePlayerErrorArg::GetError(void) const
+{
+       return __result;
+}
+
+};
+};   // Tizen::Media
diff --git a/src/FMedia_TonePlayerEventArg.h b/src/FMedia_TonePlayerEventArg.h
new file mode 100644 (file)
index 0000000..24b7ee3
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_TonePlayerEventArg.h
+// @brief                      This header file contains the declaration related to TonePlayer class.
+//
+
+#ifndef _FMEDIA_INTERNAL_TONEPLAYER_EVENTARG_H_
+#define _FMEDIA_INTERNAL_TONEPLAYER_EVENTARG_H_
+
+#include <FBaseObject.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseRtIEventArg.h>
+#include <FMediaToneTypes.h>
+
+namespace Tizen {namespace Media
+{
+
+class _TonePlayerImpl;
+
+enum _TonePlayerEventType
+{
+       _TONEPLAYER_EVENT_NONE,
+       _TONEPLAYER_EVENT_END_OF_PLAY_REACHED,
+       _TONEPLAYER_EVENT_INTERRUPTED,
+       _TONEPLAYER_EVENT_RELEASED,
+       _TONEPLAYER_EVENT_AUDIO_FOCUS_CHAGNED,
+       _TONEPLAYER_EVENT_ERROR
+};
+
+class _TonePlayerEventTypeArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+       _TonePlayerEventTypeArg(void);
+       virtual ~_TonePlayerEventTypeArg(void);
+       _TonePlayerEventType GetEventType(void) const;
+       void SetEventType(_TonePlayerEventType eType);
+
+private:
+       _TonePlayerEventTypeArg(const _TonePlayerEventTypeArg& rhs);
+       _TonePlayerEventTypeArg& operator =(const _TonePlayerEventTypeArg& rhs);
+
+       _TonePlayerEventType __eventType;
+
+};
+
+class _TonePlayerEventArg
+       : public _TonePlayerEventTypeArg
+{
+public:
+       _TonePlayerEventArg(void);
+       ~_TonePlayerEventArg(void);
+       Tizen::Base::ByteBuffer* GetData(void) const;
+       void SetData(Tizen::Base::ByteBuffer* data);
+       bool GetBoolFlag(void) const;
+       void SetBoolFlag(bool boolFlag);
+       result GetResult(void) const;
+       void SetResult(result r);
+
+private:
+       bool __boolFlag;
+       result __result;
+
+};
+
+class _TonePlayerErrorArg
+       : public _TonePlayerEventTypeArg
+{
+public:
+       _TonePlayerErrorArg(void);
+       ~_TonePlayerErrorArg(void);
+       result GetError(void) const;
+       void SetError(result r);
+
+private:
+       result __result;
+
+};
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/FMedia_TonePlayerImpl.cpp b/src/FMedia_TonePlayerImpl.cpp
new file mode 100644 (file)
index 0000000..2118cd7
--- /dev/null
@@ -0,0 +1,960 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <FMediaToneTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_TonePlayerImpl.h"
+#include "FMedia_ToneGenerator.h"
+#include "FMedia_TonePlayerEvent.h"
+#include "FMedia_TonePlayerEventArg.h"
+#include "FMedia_AudioManagerConvert.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Media
+{
+
+std::unique_ptr<Tizen::Base::Runtime::Mutex> _TonePlayerImpl::__pMutex;
+bool _TonePlayerImpl::__isInstanceMutexInitialized = false;
+int _TonePlayerImpl::__instanceCount = 0;
+
+#define MAX_TONE_PLAYER_VOLUME 100
+#define TONE_PLAYER_FEED_BUFFER_SIZE 1024
+
+_TonePlayerImpl::_TonePlayerImpl(void)
+       : __pTonePlayerEventListener(null)
+       , __endOftoneReached(false)
+       , __tonePlayerOptimalBufferSize(0)
+       , __stop(false)
+       , __audioStreamtype(AUDIO_STREAM_TYPE_MEDIA)
+       ,       __interruptFlag(false)
+{
+       __repeatCount = 0;
+       __tempRepeatCount = 0;
+       __toneListIndex = 0;
+       __volume = DEFAULT_TONE_PLAYER_VOLUME;
+       __minBufferSize = 0;
+       __tonePlayerState = TONE_PLAYER_STATE_IDLE;
+       __duration = 0;
+       __tobePlayedBuffCount = 0;
+       __sampleNumber = 0;
+       __endOftoneReached = false;
+       __endOftoneReachedArr[0] = false;
+       __endOftoneReachedArr[1] = false;
+       __audioOutHandle = null;
+
+       __sampleNumberArr[0] = 0;
+       __sampleNumberArr[1] = 0;
+
+       __tempRepeatCountArr[0] = 0;
+       __tempRepeatCountArr[1] = 0;
+
+       __toneListIndexArr[0] = 0;
+       __toneListIndexArr[1] = 0;
+
+       __pToneBuffer = null;
+}
+
+
+_TonePlayerImpl::~_TonePlayerImpl(void)
+{
+       if ((__tonePlayerState == TONE_PLAYER_STATE_PLAYING) ||
+               (__tonePlayerState == TONE_PLAYER_STATE_STOPPED) ||
+               (__tonePlayerState == TONE_PLAYER_STATE_PAUSED) ||
+               (__tonePlayerState == TONE_PLAYER_STATE_OPENED))
+       {
+               Stop();
+               Close();
+       }
+       else if (__tonePlayerState == TONE_PLAYER_STATE_ERROR)
+       {
+               if (__audioOutHandle)
+               {
+                       int ret = AUDIO_IO_ERROR_NONE;
+                       ret = audio_out_unset_interrupted_cb(__audioOutHandle);
+                       SysTryLog(NID_MEDIA, ret == AUDIO_IO_ERROR_NONE, "Failed to perform audio_out_unset_interrupted_cb operation with %x", ret);
+
+                       ret = audio_out_destroy(__audioOutHandle);
+                       __audioOutHandle = null;
+                       SysTryLog(NID_MEDIA, ret == AUDIO_IO_ERROR_NONE, "Failed to perform audio_out_destroy operation with %0x%x", ret);
+               }
+       }
+
+       if (__pToneList.get())
+       {
+               __pToneList->RemoveAll(true);
+       }
+
+       if (__tonePlayerState != TONE_PLAYER_STATE_IDLE)
+       {
+               __pMutex->Acquire();
+               __instanceCount--;
+               __pMutex->Release();
+       }
+       __tonePlayerState = TONE_PLAYER_STATE_IDLE;
+}
+
+void
+_TonePlayerImpl::InitInstanceMutex(void)
+{
+       result r = E_SUCCESS;
+       __pMutex.reset(new (std::nothrow) Tizen::Base::Runtime::Mutex);
+       SysTryReturn(NID_MEDIA, __pMutex.get() != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] no memory to create instance Mutex");
+       r = __pMutex->Create("FMEDIA_TONEPLAYER");
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Mutex::Create failed.");
+       __isInstanceMutexInitialized  = true;
+}
+
+_TonePlayerImpl*
+_TonePlayerImpl::GetInstance(TonePlayer* pTonePlayer)
+{
+       if (pTonePlayer != null)
+       {
+               return pTonePlayer->__pTonePlayerImpl;
+       }
+
+       return null;
+}
+
+const _TonePlayerImpl*
+_TonePlayerImpl::GetInstance(const TonePlayer* pTonePlayer)
+{
+       if (pTonePlayer != null)
+       {
+               return pTonePlayer->__pTonePlayerImpl;
+       }
+
+       return null;
+}
+
+result
+_TonePlayerImpl::Construct(const Tizen::Media::ITonePlayerEventListener& listener, const Tizen::Media::TonePlayer& tonePlayerInstance)
+{
+       result r = E_SUCCESS;
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (!__isInstanceMutexInitialized)
+       {
+               pthread_once(&onceBlock, InitInstanceMutex);
+       }
+       SysTryCatch(NID_MEDIA, __isInstanceMutexInitialized == true, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation for Instance Mutex failed");
+
+       SysTryCatch(NID_MEDIA, __tonePlayerState == TONE_PLAYER_STATE_IDLE ,
+                                                                                       r = E_INVALID_STATE, E_INVALID_STATE, " [E_INVALID_STATE] TonePlayer state is in an invalid state.");
+       SysTryCatch(NID_MEDIA, __instanceCount <= MAX_TONE_PLAYER_OUT_CAPACITY, r = E_RESOURCE_UNAVAILABLE, E_RESOURCE_UNAVAILABLE,
+                                                                                       "[E_RESOURCE_UNAVAILABLE] TonePlayer Exceeds the number of Instance available");
+
+       //Create TonePlayerEvent
+       __pTonePlayerEvent.reset(new (std::nothrow) _TonePlayerEvent);
+       SysTryCatch(NID_MEDIA, __pTonePlayerEvent.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, " [E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = __pTonePlayerEvent->Construct(tonePlayerInstance);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct _TonePlayerEvent.", GetErrorMessage(r));
+       r = __pTonePlayerEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pTonePlayerWorker.reset(new (std::nothrow) _TonePlayerWorker);
+       SysTryCatch(NID_MEDIA, __pTonePlayerWorker.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, " [E_OUT_OF_MEMORY] Memory allocation failed.");
+       __pTonePlayerWorker->Initialize(this);
+
+       __pMutex->Acquire();
+       __instanceCount++;
+       __pMutex->Release();
+
+       //Set State
+       __tonePlayerState = TONE_PLAYER_STATE_INITIALIZED;
+       return E_SUCCESS;
+CATCH:
+       return r;
+}
+
+result
+_TonePlayerImpl::SetAudioStreamType(AudioStreamType type)
+{
+       SysTryReturnResult(NID_MEDIA, (__tonePlayerState == TONE_PLAYER_STATE_INITIALIZED ) || (__tonePlayerState == TONE_PLAYER_STATE_CLOSED ),
+                                                                                               E_INVALID_STATE, "TonePlayer instance is in an invalid state. State is %d", __tonePlayerState);
+
+       SysTryReturnResult(NID_MEDIA, (type != AUDIO_STREAM_TYPE_NO_SOUND )
+                                       , E_INVALID_ARG, "Invalid argument is used. AudioStream type = %d", type);
+
+       __audioStreamtype = type;
+       return E_SUCCESS;
+}
+
+result
+_TonePlayerImpl::Open(const Tizen::Base::Collection::IList& toneList, int repeatCount)
+{
+       result r = E_SUCCESS;
+       int firstFrequency = 0;
+       int secondFrequency = 0;
+       int duration = 0;
+       int  toneListCount = 0;
+       const Tone* pToneTemp = null;
+       Tone* pTone = null;
+       int ret = AUDIO_IO_ERROR_NONE;
+
+       SysTryReturnResult(NID_MEDIA, (__tonePlayerState == TONE_PLAYER_STATE_INITIALIZED ) || (__tonePlayerState == TONE_PLAYER_STATE_CLOSED ),
+                                                                               E_INVALID_STATE, "TonePlayer instance is in an invalid state. State is %d", __tonePlayerState);
+
+       SysTryReturnResult(NID_MEDIA, (repeatCount >= 1), E_OUT_OF_RANGE, "repeatCount is out of range should be greater than or equal to 1");
+
+       toneListCount = toneList.GetCount();
+
+       SysTryReturnResult(NID_MEDIA, (toneListCount >= 1), E_OBJ_NOT_FOUND, "Tone instance is not available.");
+
+       if (__pToneList.get())
+       {
+               __pToneList->RemoveAll(true);
+       }
+       __pToneList.reset(new (std::nothrow) Tizen::Base::Collection::ArrayList);
+       SysTryReturnResult(NID_MEDIA, __pToneList.get() != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pToneList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct __pToneList..", GetErrorMessage(r));
+
+       for (int i = 0; i < toneListCount; i++)
+       {
+               pToneTemp = dynamic_cast<const Tone*>(toneList.GetAt(i));
+               SysTryCatch(NID_MEDIA, (pToneTemp != null), r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Tone instance is not available");
+
+               r = pToneTemp->GetFrequency(firstFrequency, secondFrequency);
+               SysTryCatch(NID_MEDIA, ((firstFrequency >= MIN_FREQUENCY) && (firstFrequency <= MAX_FREQUENCY)
+               && (secondFrequency >= MIN_FREQUENCY) && (secondFrequency <= MAX_FREQUENCY)), r = E_OUT_OF_RANGE , E_OUT_OF_RANGE,
+               "[E_OUT_OF_RANGE] firstFrequency and secondFrequency are out of range. firstFrequency = %d secondFrequency = %d.", firstFrequency, secondFrequency);
+
+               duration = pToneTemp->GetDuration();
+
+               // Adding parameters checker
+
+               SysTryCatch(NID_MEDIA, (duration >= MIN_DURATION), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Duration is out of range - %d should be greater than or equal to %d", duration, MIN_DURATION);
+
+               pTone = new (std::nothrow) Tone(firstFrequency, secondFrequency, duration);
+               SysTryCatch(NID_MEDIA, pTone, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(r));
+
+               r = __pToneList->Add(*pTone);
+               if (E_SUCCESS != r)
+               {
+                       delete pTone;
+               }
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       __repeatCount = repeatCount;
+
+       //Initilaize audio_out Device for raw audio out playback
+       ret = audio_out_create(SAMPLING_RATE, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, _AudioManagerConvert::ConvertAudioStreamType2SoundType(__audioStreamtype), &__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS , , r, "[%s] Failed to perform audio_out_create operation with 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_set_interrupted_cb(__audioOutHandle, AudioIoInterrupted, this);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_set_interrupted_cb operation with 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_get_buffer_size(__audioOutHandle, &__tonePlayerOptimalBufferSize);
+       if (ret == AUDIO_IO_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "Optimal Buffer size is %d", __tonePlayerOptimalBufferSize);
+       }
+       else
+       {
+               r = MapExceptionToResult(ret);
+               SysLogException(NID_MEDIA, r, "[%s] Failed to perform audio_out_get_buffer_size operation with 0x%x",GetErrorMessage(r), ret);
+       }
+
+       __tonePlayerOptimalBufferSize = TONE_PLAYER_FEED_BUFFER_SIZE;
+
+       __pToneBuffer.reset(new (std::nothrow) ByteBuffer);
+       SysTryCatch(NID_MEDIA, __pToneBuffer.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = __pToneBuffer->Construct(__tonePlayerOptimalBufferSize);
+       SysTryCatch(NID_MEDIA, (r == E_SUCCESS), , r, "[%s] Failed to construct __pToneBuffer.", GetErrorMessage(r));
+
+       __tonePlayerState = TONE_PLAYER_STATE_OPENED;
+       return r;
+CATCH:
+       //Clean Up audio-out Device
+       if (__audioOutHandle)
+       {
+               ret = audio_out_unset_interrupted_cb(__audioOutHandle);
+               r = MapExceptionToResult(ret);
+               SysTryReturnResult(NID_MEDIA, r == E_SUCCESS, r, "Failed to perform audio_out_unset_interrupted_cb operation with %x", ret);
+
+               ret = audio_out_destroy(__audioOutHandle);
+               __audioOutHandle = null;
+               r = MapExceptionToResult(ret);
+               SysTryReturnResult(NID_MEDIA, r == E_SUCCESS, r, "Failed to perform audio_out_destroy operation with %0x%x", ret);
+       }
+
+       //Clean up Tones
+       if (__pToneList.get())
+       {
+               __pToneList->RemoveAll(true);
+       }
+       return r;
+}
+
+result
+_TonePlayerImpl::Open(const Tizen::Media::Tone& tone, int repeatCount)
+{
+       result r = E_SUCCESS;
+       int firstFrequency = 0;
+       int secondFrequency = 0;
+       int duration = 0;
+       int ret = AUDIO_IO_ERROR_NONE;
+
+       SysTryReturnResult(NID_MEDIA, (__tonePlayerState == TONE_PLAYER_STATE_INITIALIZED ) || (__tonePlayerState == TONE_PLAYER_STATE_CLOSED ), E_INVALID_STATE, "TonePlayer is in invalid state");
+
+       SysTryReturnResult(NID_MEDIA, (repeatCount >= 1), E_OUT_OF_RANGE, "repeatCount is out of range. repeatCount = %d.", repeatCount);
+
+       r = tone.GetFrequency(firstFrequency, secondFrequency);
+       SysTryReturnResult(NID_MEDIA, ((firstFrequency >= MIN_FREQUENCY) && (firstFrequency <= MAX_FREQUENCY)
+       && (secondFrequency >= MIN_FREQUENCY) && (secondFrequency <= MAX_FREQUENCY)) , E_OUT_OF_RANGE,
+       "firstFrequency and secondFrequency are out of range. firstFrequency = %d secondFrequency = %d.", firstFrequency, secondFrequency);
+
+       duration = tone.GetDuration();
+
+       // Adding parameters checker
+       SysTryCatch(NID_MEDIA, (duration >= MIN_DURATION), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Duration is out of range");
+
+
+       __pTone.reset(new (std::nothrow) Tone(firstFrequency, secondFrequency, duration));
+       SysTryReturnResult(NID_MEDIA, __pTone.get() != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __repeatCount = repeatCount;
+       //Initlaize audio-out Device for raw audio out playback
+       ret = audio_out_create(SAMPLING_RATE, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, _AudioManagerConvert::ConvertAudioStreamType2SoundType(__audioStreamtype), &__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS , , r, "[%s] Failed to perform audio_out_create operation with 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_set_interrupted_cb(__audioOutHandle, AudioIoInterrupted, this);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_set_interrupted_cb operation with 0x%x", GetErrorMessage(r), ret);
+
+       ret = audio_out_get_buffer_size(__audioOutHandle, &__tonePlayerOptimalBufferSize);
+       if (ret == AUDIO_IO_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "Optimal Buffer size is %d", __tonePlayerOptimalBufferSize);
+       }
+       else
+       {
+               r = MapExceptionToResult(ret);
+               SysLogException(NID_MEDIA, r, "[%s] Failed to perform audio_out_get_buffer_size operation with 0x%x", GetErrorMessage(r), ret);
+       }
+
+       __tonePlayerOptimalBufferSize = TONE_PLAYER_FEED_BUFFER_SIZE;
+
+       __pToneBuffer.reset(new (std::nothrow) ByteBuffer);
+       SysTryCatch(NID_MEDIA, __pToneBuffer.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       r = __pToneBuffer->Construct(__tonePlayerOptimalBufferSize);
+       SysTryCatch(NID_MEDIA, (r == E_SUCCESS), , r, "[%s] Failed to construct __pToneBuffer.", GetErrorMessage(r));
+
+       __tonePlayerState = TONE_PLAYER_STATE_OPENED;
+       return r;
+
+CATCH:
+       if (__audioOutHandle)
+       {
+               ret = audio_out_unset_interrupted_cb(__audioOutHandle);
+               r = MapExceptionToResult(ret);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform audio_out_unset_interrupted_cb operation with %x", GetErrorMessage(r), ret);
+
+               ret = audio_out_destroy(__audioOutHandle);
+               r = MapExceptionToResult(ret);
+               SysTryReturnResult(NID_MEDIA, r == E_SUCCESS, r, "Failed to perform audio_out_destroy operation with 0x%x", ret);
+
+               __audioOutHandle = null;
+       }
+       return r;
+}
+
+
+result
+_TonePlayerImpl::Play(void)
+{
+       result r = E_SUCCESS;
+       int ret = AUDIO_IO_ERROR_NONE;
+       SysTryReturnResult(NID_MEDIA, (__tonePlayerState == TONE_PLAYER_STATE_PAUSED ) ||
+                                         (__tonePlayerState == TONE_PLAYER_STATE_OPENED) ||
+                                         (__tonePlayerState == TONE_PLAYER_STATE_STOPPED ), E_INVALID_STATE, "TonePlayer is in an invalid state - %d", __tonePlayerState);
+
+       if ((__tonePlayerState == TONE_PLAYER_STATE_OPENED ) || (__tonePlayerState == TONE_PLAYER_STATE_STOPPED ))
+       {
+               __tempRepeatCount = __repeatCount;
+               __tempRepeatCountArr[0] = __tempRepeatCount;
+               __tempRepeatCountArr[1] = __tempRepeatCount;
+
+               __tobePlayedBuffCount = 0;
+
+               __sampleNumber = 0;
+               __sampleNumberArr[0] = __sampleNumber;
+               __sampleNumberArr[1] = __sampleNumber;
+
+               __endOftoneReached = false;
+               __endOftoneReachedArr[0] = __endOftoneReached;
+               __endOftoneReachedArr[1] = __endOftoneReached;
+
+               if (__pToneList.get())
+               {
+                       __toneListIndex = __pToneList->GetCount();
+                       __toneListIndexArr[0] = __toneListIndex;
+                       __toneListIndexArr[1] = __toneListIndex;
+               }
+               __stop = false;
+
+               ret = audio_out_prepare(__audioOutHandle);
+               r = MapExceptionToResult(ret);
+               SysTryReturnResult(NID_MEDIA, r != E_DEVICE_BUSY, r, "TonePlayer cannot Start, higher priority task at work.");
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS , , r, "[%s] Failed to perform audio_out_prepare operation with 0x%x", GetErrorMessage(r), ret);
+
+               __pWorkerThread.reset(new (std::nothrow) Thread);
+               SysTryCatch(NID_MEDIA, __pWorkerThread.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               r = __pWorkerThread->Construct(*(__pTonePlayerWorker.get()));
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct __pWorkerThread.", GetErrorMessage(r));
+               r = __pWorkerThread->Start();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       }
+       else if ((__tonePlayerState == TONE_PLAYER_STATE_PAUSED ))
+       {
+               __tempRepeatCount = __tempRepeatCountArr[0];
+               __sampleNumber = __sampleNumberArr[0];
+               __endOftoneReached = __endOftoneReachedArr[0];
+
+               if (__pToneList.get())
+               {
+                       __toneListIndex = __toneListIndexArr[0];
+               }
+               __stop = false;
+
+               ret = audio_out_prepare(__audioOutHandle);
+               r = MapExceptionToResult(ret);
+               SysTryReturnResult(NID_MEDIA, r != E_DEVICE_BUSY, r, "TonePlayer cannot Start, higher priority task at work.");
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS , , r, "[%s] Failed to perform audio_out_prepare operation with 0x%x", GetErrorMessage(r), ret);
+
+               __pWorkerThread.reset(new (std::nothrow) Thread);
+               SysTryCatch(NID_MEDIA, __pWorkerThread.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               r = __pWorkerThread->Construct(*(__pTonePlayerWorker.get()));
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to construct __pWorkerThread..", GetErrorMessage(r));
+               r = __pWorkerThread->Start();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       //Set the State
+       __tonePlayerState = TONE_PLAYER_STATE_PLAYING;
+       return r;
+
+CATCH:
+       __tonePlayerState = TONE_PLAYER_STATE_ERROR;
+       return r;
+}
+
+
+result
+_TonePlayerImpl::Stop(void)
+{
+       SysTryReturnResult(NID_MEDIA, (__tonePlayerState == TONE_PLAYER_STATE_PAUSED ) ||
+                                         (__tonePlayerState == TONE_PLAYER_STATE_PLAYING ), E_INVALID_STATE, "TonePlayer is in an invalid state");
+       result r = E_SUCCESS;
+       int ret = AUDIO_IO_ERROR_NONE;
+       __stop = true;
+       if (__pWorkerThread.get())
+       {
+               __pWorkerThread->Join();
+       }
+
+       if (__tonePlayerState == TONE_PLAYER_STATE_PLAYING)
+       {
+               ret = audio_out_unprepare(__audioOutHandle);
+               r = MapExceptionToResult(ret);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform audio_out_unprepare operation with 0x%x", GetErrorMessage(r), ret);
+       }
+       __tonePlayerState = TONE_PLAYER_STATE_STOPPED;
+
+       return r;
+}
+
+result
+_TonePlayerImpl::Pause(void)
+{
+       result r = E_SUCCESS;
+       int ret = AUDIO_IO_ERROR_NONE;
+       SysTryReturnResult(NID_MEDIA, (__tonePlayerState == TONE_PLAYER_STATE_PLAYING ), E_INVALID_STATE,
+                                       "TonePlayer instance is in an invalid state. State is %d", __tonePlayerState);
+       __stop = true;
+
+       if (__pWorkerThread.get())
+       {
+               __pWorkerThread->Join();
+       }
+
+       ret = audio_out_unprepare(__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform audio_out_unprepare operation with 0x%x", GetErrorMessage(r), ret);
+
+       __tonePlayerState = TONE_PLAYER_STATE_PAUSED;
+       return r;
+}
+
+
+result
+_TonePlayerImpl::Close(void)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_MEDIA, (__tonePlayerState == TONE_PLAYER_STATE_OPENED ) || (__tonePlayerState == TONE_PLAYER_STATE_STOPPED ) ||
+                                               (__tonePlayerState == TONE_PLAYER_STATE_END_OF_TONE ), E_INVALID_STATE, "TonePlayer is in an invalid state");
+
+       if (__tonePlayerState == TONE_PLAYER_STATE_END_OF_TONE)
+       {
+               __stop = true;
+               if (__pWorkerThread.get())
+               {
+                       SysLog(NID_MEDIA, "Join is starting.");
+                       __pWorkerThread->Join();
+               }
+       }
+       __tonePlayerState = TONE_PLAYER_STATE_CLOSED;
+
+       if (__audioOutHandle)
+       {
+               int ret = AUDIO_IO_ERROR_NONE;
+               ret = audio_out_unset_interrupted_cb(__audioOutHandle);
+               r = MapExceptionToResult(ret);
+               SysTryLog(NID_MEDIA, r == E_SUCCESS,"[%s] Failed to perform audio_out_unset_interrupted_cb operation with %x", GetErrorMessage(r), ret);
+
+               ret = audio_out_destroy(__audioOutHandle);
+               __audioOutHandle = null;
+               r = MapExceptionToResult(ret);
+               SysTryLog(NID_MEDIA, r == E_SUCCESS , "[%s] Failed to perform audio_out_destroy operation with %0x%x", GetErrorMessage(r), ret);
+       }
+
+       if (__pToneList.get() != null)
+       {
+               __pToneList->RemoveAll(true);
+       }
+       return r;
+}
+
+result
+_TonePlayerImpl::SetVolume(int& volume)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_MEDIA, (0 <= volume) && (volume <= MAX_TONE_PLAYER_VOLUME), E_OUT_OF_RANGE,
+                                                                                                               "volume is out of range. volume = %d", volume);
+       __volume = volume;
+       return r;
+}
+
+int
+_TonePlayerImpl::GetVolume(void) const
+{
+       SetLastResult(E_SUCCESS);
+       return __volume;
+}
+
+
+TonePlayerState
+_TonePlayerImpl::GetState(void) const
+{
+       SetLastResult(E_SUCCESS);
+       return __tonePlayerState;
+}
+
+void
+_TonePlayerImpl::Feed(void)
+{
+       int buffer_size = 0;
+       unsigned char* pData = NULL;
+       result r = E_SUCCESS;
+       int ret = AUDIO_IO_ERROR_NONE;
+       bool isSuccesful = true;
+       while (!__stop)
+       {
+               if (isSuccesful)
+               {
+                       __pToneBuffer->Clear();
+                       if (!GetBuffer(*__pToneBuffer.get()))
+                       {
+                               __tonePlayerState = TONE_PLAYER_STATE_END_OF_TONE;
+                               r = SendEndOfTone();
+                               SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+                               return;
+                       }
+                       isSuccesful = false;
+               }
+               buffer_size = __pToneBuffer->GetLimit();
+               pData = (unsigned char*) __pToneBuffer->GetPointer();
+               SysTryCatch(NID_MEDIA, pData, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Data Sent to TonePlayer is null");
+               if (!__stop)
+               {
+                       ret = audio_out_write(__audioOutHandle, (void*) pData, buffer_size);
+                       if (ret != buffer_size)
+                       {
+                               //wrong;
+                               SysLog(NID_MEDIA, "Audio Device could only put %d data to device", ret);
+                       }
+                       else
+                       {
+                               isSuccesful = true;
+                       }
+               }
+       }
+       return;
+CATCH:
+       SendError(r);
+       return;
+}
+
+void
+_TonePlayerImpl::AudioIoInterrupted(audio_io_interrupted_code_e code, void *pUserData)
+{
+       SysTryReturn(NID_MEDIA, pUserData, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pUserData is null.");
+       _TonePlayerImpl *pTonePlayerImpl = (_TonePlayerImpl *)pUserData;
+
+       switch(code)
+       {
+       case AUDIO_IO_INTERRUPTED_COMPLETED:
+               if (pTonePlayerImpl->__tonePlayerState == TONE_PLAYER_STATE_PAUSED || pTonePlayerImpl->__tonePlayerState == TONE_PLAYER_STATE_STOPPED)
+               {
+                       if (!(pTonePlayerImpl->__interruptFlag))
+                       {
+                               pTonePlayerImpl->SendReleased();
+                       }
+                       pTonePlayerImpl->__interruptFlag = false;
+               }
+               break;
+       case AUDIO_IO_INTERRUPTED_BY_CALL:
+               pTonePlayerImpl->__interruptFlag = true;
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_EARJACK_UNPLUG:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_MEDIA:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_RESOURCE_CONFLICT:
+               if (pTonePlayerImpl->__tonePlayerState == TONE_PLAYER_STATE_PLAYING)
+               {
+                       pTonePlayerImpl->SendAudioFocusChanged();
+               }
+               break;
+       case AUDIO_IO_INTERRUPTED_BY_ALARM:
+               //Intentional Fall through
+       case AUDIO_IO_INTERRUPTED_BY_EMERGENCY:
+               if (pTonePlayerImpl->__tonePlayerState == TONE_PLAYER_STATE_PLAYING)
+               {
+                       pTonePlayerImpl->SendInterrupted();
+               }
+               break;
+       default:
+               SysLog(NID_MEDIA, "Audio I/O Interrupt is not set.");
+               break;
+       }
+}
+
+bool
+_TonePlayerImpl::GetBuffer(Tizen::Base::ByteBuffer& toneBuffer)
+{
+       int bufferTobeFilledSize = __tonePlayerOptimalBufferSize;
+       int firstFrequency = 0;
+       int secondFrequency = 0;
+       long startSample = 0;
+       long endSample = 0;
+
+       toneBuffer.Clear();
+
+       __sampleNumberArr[0] = __sampleNumberArr[1];
+       __sampleNumberArr[1] = __sampleNumber;
+
+       __tempRepeatCountArr[0] = __tempRepeatCountArr[1];
+       __tempRepeatCountArr[1] = __tempRepeatCount;
+
+       __toneListIndexArr[0] = __toneListIndexArr[1];
+       __toneListIndexArr[1] = __toneListIndex;
+
+       __endOftoneReachedArr[0] = __endOftoneReachedArr[1];
+       __endOftoneReachedArr[1] = __endOftoneReached;
+
+       // If already end of tone is reached generate silent buffer and return
+       if (__endOftoneReached)
+       {
+               bufferTobeFilledSize = __tonePlayerOptimalBufferSize - toneBuffer.GetPosition(); //buffer size to be filled is total size - already filled buffer size
+               firstFrequency = 0;
+               secondFrequency = 0;
+               _ToneGenerator::GenerateTone(toneBuffer, firstFrequency, secondFrequency, 0, bufferTobeFilledSize / _BYTES_PER_SAMPLE, __volume); //fill silent buffer
+               return false;
+       }
+
+       while (1)
+       {
+               // Get the details of the buffer to be generated
+               if (!GetNextToneBufferDetails(bufferTobeFilledSize, firstFrequency, secondFrequency, startSample, endSample))
+               {
+                       __endOftoneReached = true;
+                       _ToneGenerator::GenerateTone(toneBuffer, firstFrequency, secondFrequency, startSample, endSample, __volume);
+                       bufferTobeFilledSize = __tonePlayerOptimalBufferSize - toneBuffer.GetPosition();
+                       firstFrequency = 0;
+                       secondFrequency = 0;
+                       _ToneGenerator::GenerateTone(toneBuffer, firstFrequency, secondFrequency, 0, bufferTobeFilledSize / _BYTES_PER_SAMPLE, __volume); //fill silent buffer
+                       return false;
+               }
+               _ToneGenerator::GenerateTone(toneBuffer, firstFrequency, secondFrequency, startSample, endSample, __volume);
+               bufferTobeFilledSize = __tonePlayerOptimalBufferSize - toneBuffer.GetPosition();
+
+               // keep trying till the buffer gets filled
+               if (0 >= bufferTobeFilledSize)
+               {
+                       return true;
+               }
+
+       }
+       return true;
+}
+
+bool
+_TonePlayerImpl::GetNextToneBufferDetails(int bufferTobeFilledSize, int& firstFrequency, int& secondFrequency, long& startSample, long& endSample)
+{
+       bufferTobeFilledSize /= _BYTES_PER_SAMPLE;
+
+       // This case is for construct with just Tone
+       if (__pToneList.get() == null)
+       {
+               __pTone->GetFrequency(firstFrequency, secondFrequency);
+               __duration = __pTone->GetDuration();
+
+               if ((__sampleNumber + bufferTobeFilledSize) <= (int) (SAMPLING_RATE / 1000.0 * __duration)) //(SAMPLING_RATE/1000.0*__duration)) gives the total samples for the duration
+               {
+                       startSample = __sampleNumber;
+                       __sampleNumber += bufferTobeFilledSize; // if current sample number is less than total sample return samples to be generated
+                       endSample = __sampleNumber;
+                       return true;
+               }
+               else
+               {
+                       startSample = __sampleNumber;
+                       endSample = (int) (SAMPLING_RATE / 1000.0 * __duration);
+                       __tempRepeatCount--;
+                       __sampleNumber = 0;
+                       if (0 >= __tempRepeatCount)
+                       {
+                               return false;
+                       }
+                       else
+                       {
+                               return true;
+                       }
+               }
+       }
+       else        // Construct with Tone List
+       {
+               Tone* pTone = dynamic_cast<Tone*>(__pToneList->GetAt(__pToneList->GetCount() - __toneListIndex));
+
+               if (pTone == null)
+               {
+                       SysLog(NID_MEDIA, "pTone is null");
+                       return false;
+               }
+
+               pTone->GetFrequency(firstFrequency, secondFrequency);
+               __duration = pTone->GetDuration();
+
+               if ((__sampleNumber + bufferTobeFilledSize) <= (int) (SAMPLING_RATE / 1000.0 * __duration))
+               {
+                       startSample = __sampleNumber;
+                       __sampleNumber += bufferTobeFilledSize;
+                       endSample = __sampleNumber;
+                       return true;
+               }
+               else
+               {
+                       startSample = __sampleNumber;
+                       endSample = (int) (SAMPLING_RATE / 1000.0 * __duration);
+                       __toneListIndex--;
+                       __sampleNumber = 0;
+                       if (0 >= __toneListIndex)
+                       {
+                               __tempRepeatCount--;
+                               if (0 >= __tempRepeatCount)
+                               {
+                                       return false;
+                               }
+                               else
+                               {
+                                       __toneListIndex = __pToneList->GetCount();
+                                       return true;
+                               }
+                       }
+                       else
+                       {
+                               return true;
+                       }
+               }
+       }
+       return false;
+}
+
+result
+_TonePlayerImpl::SendEndOfTone(void)
+{
+       result r = E_SUCCESS;
+       int ret = AUDIO_IO_ERROR_NONE;
+
+       ret = audio_out_unprepare(__audioOutHandle);
+       r = MapExceptionToResult(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Failed to perform audio_out_unprepare operation with 0x%x", GetErrorMessage(r), ret);
+
+       _TonePlayerEventArg* pTonePlayerEventArg = null;
+       pTonePlayerEventArg = new (std::nothrow) _TonePlayerEventArg;
+       SysTryReturnResult(NID_MEDIA, pTonePlayerEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       pTonePlayerEventArg->SetEventType(_TONEPLAYER_EVENT_END_OF_PLAY_REACHED);
+       r = __pTonePlayerEvent->FireAsync(*pTonePlayerEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pTonePlayerEventArg;
+       pTonePlayerEventArg = null;
+
+       return r;
+}
+
+result
+_TonePlayerImpl::SendInterrupted(void)
+{
+       result r = E_SUCCESS;
+       _TonePlayerEventArg* pTonePlayerEventArg = null;
+       pTonePlayerEventArg = new (std::nothrow) _TonePlayerEventArg;
+       SysTryReturnResult(NID_MEDIA, pTonePlayerEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       this->Pause();
+       pTonePlayerEventArg->SetEventType(_TONEPLAYER_EVENT_INTERRUPTED);
+       r = __pTonePlayerEvent->FireAsync(*pTonePlayerEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pTonePlayerEventArg;
+       pTonePlayerEventArg = null;
+
+       return r;
+}
+
+result
+_TonePlayerImpl::SendAudioFocusChanged(void)
+{
+       result r = E_SUCCESS;
+       _TonePlayerEventArg* pTonePlayerEventArg = null;
+       pTonePlayerEventArg = new (std::nothrow) _TonePlayerEventArg;
+       SysTryReturnResult(NID_MEDIA, pTonePlayerEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       this->Pause();
+       pTonePlayerEventArg->SetEventType(_TONEPLAYER_EVENT_AUDIO_FOCUS_CHAGNED);
+       r = __pTonePlayerEvent->FireAsync(*pTonePlayerEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pTonePlayerEventArg;
+       pTonePlayerEventArg = null;
+
+       return r;
+}
+
+result
+_TonePlayerImpl::SendReleased(void)
+{
+       result r = E_SUCCESS;
+       _TonePlayerEventArg* pTonePlayerEventArg = null;
+       pTonePlayerEventArg = new (std::nothrow) _TonePlayerEventArg;
+       SysTryReturnResult(NID_MEDIA, pTonePlayerEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       pTonePlayerEventArg->SetEventType(_TONEPLAYER_EVENT_RELEASED);
+       r = __pTonePlayerEvent->FireAsync(*pTonePlayerEventArg);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       return r;
+CATCH:
+       delete pTonePlayerEventArg;
+       pTonePlayerEventArg = null;
+
+       return r;
+}
+
+result
+_TonePlayerImpl::SendError(result reason)
+{
+       result r = E_SUCCESS;
+       __tonePlayerState = TONE_PLAYER_STATE_ERROR;
+       _TonePlayerErrorArg* pTonePlayerErrorArg = NULL;
+
+       pTonePlayerErrorArg = new (std::nothrow) _TonePlayerErrorArg;
+       if (pTonePlayerErrorArg == null)
+       {
+               r = E_OUT_OF_MEMORY;
+               goto CATCH_;
+       }
+       pTonePlayerErrorArg->SetEventType(_TONEPLAYER_EVENT_ERROR);
+       pTonePlayerErrorArg->SetError(reason);
+       r = __pTonePlayerEvent->FireAsync(*pTonePlayerErrorArg);
+       if (IsFailed(r))
+       {
+               goto CATCH_;
+       }
+       return r;
+
+CATCH_:
+       if (pTonePlayerErrorArg != null)
+       {
+               delete pTonePlayerErrorArg;
+       }
+       return r;
+}
+
+result
+_TonePlayerImpl::MapExceptionToResult(int reason)
+{
+       //All the fall through are intentional
+       switch (reason)
+       {
+       //Successful
+       case AUDIO_IO_ERROR_NONE:
+               return E_SUCCESS;
+               break;
+       //Out of memory
+       case AUDIO_IO_ERROR_OUT_OF_MEMORY:
+               return E_OUT_OF_MEMORY;
+               break;
+       //Invalid parameter
+       case AUDIO_IO_ERROR_INVALID_PARAMETER:
+               return E_INVALID_ARG;
+               break;
+       //Invalid operation
+       case AUDIO_IO_ERROR_INVALID_OPERATION:
+               return E_INVALID_OPERATION;
+               break;
+       //device not opened
+       case AUDIO_IO_ERROR_DEVICE_NOT_OPENED:
+               return E_INVALID_STATE;
+               break;
+       //invalid buffer
+       case AUDIO_IO_ERROR_INVALID_BUFFER:
+               return E_INVALID_ARG;
+               break;
+       //device not closed
+       case AUDIO_IO_ERROR_DEVICE_NOT_CLOSED:
+               return E_INVALID_STATE;
+               break;
+       //Sound policy error
+       case AUDIO_IO_ERROR_SOUND_POLICY:
+               return E_DEVICE_BUSY;
+               break;
+       default:
+               return E_SYSTEM;
+               break;
+       }
+}
+
+};
+};   //Tizen::Media
diff --git a/src/FMedia_TonePlayerImpl.h b/src/FMedia_TonePlayerImpl.h
new file mode 100644 (file)
index 0000000..e88e9c0
--- /dev/null
@@ -0,0 +1,147 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_TonePlayerImpl.h
+// @brief                      This header file contains the declaration related to TonePlayer class
+//
+//
+
+#ifndef _FMEDIA_INTERNAL_TONEPLAYER_IMPL_H_
+#define _FMEDIA_INTERNAL_TONEPLAYER_IMPL_H_
+#include <memory>
+#include <audio_io.h>
+#include <unique_ptr.h>
+#include <FBaseColIList.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseColArrayList.h>
+#include <FBaseRtThread.h>
+#include <FBaseObject.h>
+#include <FBaseRtMutex.h>
+#include <FBaseRtIRunnable.h>
+#include <FMediaTone.h>
+#include <FMediaAudioManagerTypes.h>
+
+#define MAX_TONE_PLAYER_OUT_CAPACITY 16
+
+namespace Tizen { namespace Media
+{
+class TonePlayer;
+class ITonePlayerEventListener;
+class _TonePlayerWorker;
+class _TonePlayerEvent;
+
+class _TonePlayerImpl
+       : public virtual Tizen::Base::Object
+{
+public:
+       _TonePlayerImpl(void);
+       virtual ~_TonePlayerImpl(void);
+
+       result Construct(const Tizen::Media::ITonePlayerEventListener& listener, const Tizen::Media::TonePlayer& tonePlayerInstance);
+       result Open(const Tizen::Base::Collection::IList& toneList, int repeatCount = 1);
+       result Open(const Tizen::Media::Tone& tone, int repeatCount = 1);
+       result Play(void);
+       result Stop(void);
+       result Pause(void);
+       result SetVolume(int& volume);
+       int GetVolume(void) const;
+       result Close(void);
+       TonePlayerState GetState(void) const;
+       result SetAudioStreamType(AudioStreamType type);
+       void Feed(void);
+       static void AudioIoInterrupted(audio_io_interrupted_code_e code, void *pUserData);
+private:
+       _TonePlayerImpl(const _TonePlayerImpl& rhs);
+       _TonePlayerImpl& operator =(const _TonePlayerImpl& rhs);
+
+       bool GetBuffer(Tizen::Base::ByteBuffer& toneBuffer);
+       bool GetNextToneBufferDetails(int bufferTobeFilledSize, int& firstFrequency, int& secondFrequency, long& startSample, long& endSample);
+       result SendEndOfTone(void);
+       result SendInterrupted(void);
+       result SendReleased(void);
+       result SendAudioFocusChanged();
+       result SendError(result r);
+       result MapExceptionToResult(int reason);
+
+       static _TonePlayerImpl* GetInstance(TonePlayer* pTonePlayer);
+       static const _TonePlayerImpl* GetInstance(const TonePlayer* pTonePlayer);
+       static void InitInstanceMutex(void);
+       static int __noOfInstances;
+       static int __instanceCount;
+       std::unique_ptr<Tizen::Base::ByteBuffer> __pToneBuffer;
+       std::unique_ptr<Tizen::Base::Collection::ArrayList> __pToneList;
+       std::unique_ptr<_TonePlayerEvent> __pTonePlayerEvent;
+       std::unique_ptr<Tizen::Base::Runtime::Thread> __pWorkerThread;
+       std::unique_ptr<_TonePlayerWorker> __pTonePlayerWorker;
+       std::unique_ptr<Tone> __pTone;
+       static std::unique_ptr<Tizen::Base::Runtime::Mutex> __pMutex;
+       static bool __isInstanceMutexInitialized;
+
+       Tizen::Media::ITonePlayerEventListener* __pTonePlayerEventListener;
+       int __repeatCount;
+       int __tempRepeatCount;
+       int __toneListIndex;
+       int __volume;
+       int __minBufferSize;
+       long __duration;
+       long __sampleNumber;
+       TonePlayerState __tonePlayerState;
+       int __tobePlayedBuffCount;
+       bool __endOftoneReached;
+
+       long __sampleNumberArr[2];
+       int __tempRepeatCountArr[2];
+       int __toneListIndexArr[2];
+       bool __endOftoneReachedArr[2];
+       audio_out_h __audioOutHandle;
+       int __tonePlayerOptimalBufferSize;
+       bool __stop;
+       AudioStreamType __audioStreamtype;
+       bool __interruptFlag;
+
+};     //end of _TonePlayerImp
+
+
+class _TonePlayerWorker
+       : public virtual Tizen::Base::Object
+       , public virtual Tizen::Base::Runtime::IRunnable
+{
+public:
+       _TonePlayerWorker(void)
+       {
+               _pTonePlayerImpl = null;
+       }
+       void Initialize(_TonePlayerImpl* pTonePlayerImpl)
+       {
+               _pTonePlayerImpl = pTonePlayerImpl;
+       }
+       virtual Tizen::Base::Object* Run(void)
+       {
+               if (_pTonePlayerImpl)
+               {
+                       _pTonePlayerImpl->Feed();
+               }
+               return this;
+       }
+protected:
+       _TonePlayerImpl* _pTonePlayerImpl;
+};     //end of _TonePlayerWorker
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/FMedia_UlawDecoder.cpp b/src/FMedia_UlawDecoder.cpp
new file mode 100644 (file)
index 0000000..46bcb82
--- /dev/null
@@ -0,0 +1,402 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <stdio.h>
+#include <unique_ptr.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FBaseInteger.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_Ffmpeg.h"
+#include "FMedia_FfmpegUtil.h"
+#include "FMedia_IAudioDecoder.h"
+#include "FMedia_UlawDecoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_IAudioDecoder*
+_UlawDecoder_CreateInstance(void)
+{
+       return new (std::nothrow) _UlawDecoder();
+}
+
+_UlawDecoder::_UlawDecoder(void)
+{
+       __pCodecCtx = null;
+       __pCodec = null;
+       __decodeCalled = false;
+       __pOutBuf = null;
+       __decoderConfigured = false;
+
+}
+
+_UlawDecoder::~_UlawDecoder(void)
+{
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+       }
+}
+
+result
+_UlawDecoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       Integer* pKey = null;
+       Integer* pValue = null;
+       int key = -1;
+       int value = -1;
+
+       SysAssertf((__pCodecCtx == null && __pCodec == null), " Already Constructed .");
+       SysTryReturnResult(NID_MEDIA, pOption != null, E_INVALID_ARG, "pOtion is null");
+
+       avcodec_register_all();
+
+       __pCodecCtx = avcodec_alloc_context();
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_SYSTEM, E_SYSTEM,
+                           "[%s] AVCODEC Context Allcoation Failed",GetErrorMessage(E_SYSTEM));
+       __pCodec = avcodec_find_decoder(CODEC_ID_PCM_MULAW);
+       SysTryCatch(NID_MEDIA, __pCodec != null, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Find Decoder Failed for CODEC_ID_PCM_MULAW",GetErrorMessage(E_SYSTEM));
+
+       if (pOption != null)
+       {
+               // The initialization values are given in the Hashmap
+               std::unique_ptr<IMapEnumerator> pMapEnum(pOption->GetMapEnumeratorN());
+               if (pMapEnum.get() != null)
+               {
+                       while (pMapEnum.get()->MoveNext() == E_SUCCESS)
+                       {
+                               pKey = static_cast<Integer*>(pMapEnum.get()->GetKey());
+                               pValue = static_cast<Integer*>(pMapEnum.get()->GetValue());
+                               if (pKey && pValue)
+                               {
+                                       key = pKey->ToInt();
+                                       value = pValue->ToInt();
+                                       switch (key)
+                                       {
+                                       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+                                               SysTryCatch(NID_MEDIA, (value == 0 || value == 1 || value == 2), r = E_OUT_OF_RANGE,
+                                                                  E_OUT_OF_RANGE, "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->channels = value;
+                                               __decoderConfigured = true;
+                                               break;
+
+                                       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+                                               SysTryCatch(NID_MEDIA, !(value < 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->sample_rate = value;
+                                               break;
+
+                                       case MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE:
+                                               SysTryCatch(NID_MEDIA, !(value < 0), r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+                                                                  "[%s] Invalid argument is used. The value is out of range",GetErrorMessage(E_OUT_OF_RANGE));
+                                               __pCodecCtx->sample_fmt = _FfmpegUtil::ToAvSampleFormat((AudioSampleType)value);
+                                               break;
+
+                                       default:
+                                               break;
+                                       }
+                               }
+                       } // while
+               }
+       }
+
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx->channels != 0, E_INVALID_ARG, "Channel is not set");
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx->sample_rate != 0, E_INVALID_ARG, "Sample rate is not set");
+       SysTryReturnResult(NID_MEDIA, __pCodecCtx->sample_fmt != AV_SAMPLE_FMT_NONE, E_INVALID_ARG, "Sample type is not set");
+
+       res = avcodec_open(__pCodecCtx, __pCodec);
+       SysTryCatch(NID_MEDIA, res >= 0, r = E_SYSTEM, E_SYSTEM,
+                          "[%s] AVCODEC Codec Open Failed for CODEC_ID_PCM_MULAW",GetErrorMessage(E_SYSTEM));
+
+       // AVCodecContext parameters
+       if (__pCodec->capabilities & CODEC_CAP_TRUNCATED)
+       {
+               __pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
+       }
+
+       __pCodecCtx->debug_mv = 0; //set by user
+       __pCodecCtx->debug = 0; //set by user
+       __pCodecCtx->workaround_bugs = 1; //set by user
+       __pCodecCtx->lowres = 0; //set by user
+
+       __pOutBuf = new (std::nothrow) byte[OUT_BUFFER_SIZE];
+       SysTryCatch(NID_MEDIA, __pOutBuf != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return r;
+
+CATCH:
+
+       if (__pCodecCtx != null)
+       {
+               avcodec_close(__pCodecCtx);
+               av_free(__pCodecCtx);
+               __pCodecCtx = null;
+               __pCodec = null;
+       }
+       if (__pOutBuf != null)
+       {
+               delete[] __pOutBuf;
+               __pOutBuf = null;
+       }
+       return r;
+}
+
+result
+_UlawDecoder::Decode(const byte* pSrcBuf, int srcBufSize, int& srcBufUsed,
+                                       byte* pDstBuf, int dstBufSize, int& dstBufUsed)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       AVPacket inputPacket;
+       int outBufSize = 0;
+       byte* pOutBuf = null;
+       int offSet = 0;
+
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, pSrcBuf != null && pDstBuf != null && srcBufSize > 0 && dstBufSize > 0,
+                          r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+#if 0
+       // This blocks reads the input data format , i.e channel count and format type is read.
+       // No error checkin id done here as we are trying to get the channel count if user wont specify
+       if (__decoderConfigured == false)
+       {
+
+               _WavFormatInfo wavFormatInfo;
+               _RiffFileHeader riffHdr;
+               _RiffChunkHeader chunkHdr;
+
+               if ( srcBufSize > _MIN_WAVE_HEADER_SIZE )
+               {
+                       memcpy(&riffHdr, pSrcBuf, sizeof(riffHdr)); // file header of 12 bytes
+                       offSet += sizeof(riffHdr);
+                       memcpy(&chunkHdr, pSrcBuf + offSet, sizeof(chunkHdr)); // format sub chunk  header of 8 bytes
+                       offSet += sizeof(chunkHdr);
+                       memcpy(&wavFormatInfo, pSrcBuf + offSet, sizeof(wavFormatInfo)); // format sub chunk consists of wave info 16 bytes
+                       offSet += sizeof(wavFormatInfo);
+                       // assign to codec context if it is mono or stereo
+                       if ( riffHdr.chunkId == _RIFF_CHUNK_ID && riffHdr.format== _RIFF_FORMAT_WAVE )
+                       {
+                               __pCodecCtx->channels = wavFormatInfo.channels;
+                               __decoderConfigured = true;
+                               // Data starts in next sub chunk
+                               memcpy(&chunkHdr, pSrcBuf + offSet, sizeof(chunkHdr)); // data sub chunk  header of 8 bytes
+                               offSet += sizeof(chunkHdr); // offset is now at data start
+                       }
+                       else
+                       {
+                               offSet = 0; // Header info is not available
+                       }
+
+               }
+
+       }
+#endif
+       av_init_packet(&inputPacket);
+
+       inputPacket.size = srcBufSize -offSet;
+       inputPacket.data = (uint8_t*)pSrcBuf + offSet;
+
+       if (dstBufSize >= OUT_BUFFER_SIZE)
+       {
+               pOutBuf = pDstBuf;
+               outBufSize = dstBufSize;
+       }
+       else
+       {
+               pOutBuf = __pOutBuf;
+               outBufSize = OUT_BUFFER_SIZE;
+       }
+
+       SysTryCatch(NID_MEDIA, __decoderConfigured == true, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));
+       res = avcodec_decode_audio3(__pCodecCtx, (int16_t*)pOutBuf, &outBufSize, &inputPacket);
+       SysTryCatch(NID_MEDIA, (res > 0 && outBufSize > 0), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                         "[%s] The input data format is not supported ",GetErrorMessage(E_UNSUPPORTED_FORMAT));
+
+       SysTryCatch(NID_MEDIA, dstBufSize >= outBufSize, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+
+       dstBufUsed = outBufSize; // the decoded audio data size
+       srcBufUsed = res + offSet; // input bytes used + offset header that is skipped
+       if (pOutBuf != pDstBuf)
+       {
+               memcpy(pDstBuf, pOutBuf, outBufSize);
+       }
+       __decodeCalled = true;
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_UlawDecoder::Probe(const byte* pSrcBuf, const int srcBufSize,
+                                  AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate)
+{
+       result r = E_SUCCESS;
+       int dstBufUsed = 0;
+       int srcBufUsed = 0;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, pSrcBuf != null && srcBufSize > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+
+       r = Decode(pSrcBuf, srcBufSize, srcBufUsed, __pOutBuf, OUT_BUFFER_SIZE, dstBufUsed);
+
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Decode failed", GetErrorMessage(r));
+
+       channelType = _FfmpegUtil::ToAudioChannelType(__pCodecCtx->channels);
+       sampleType = _FfmpegUtil::ToAudioSampleType(__pCodecCtx->sample_fmt);
+       sampleRate = __pCodecCtx->sample_rate;
+
+       SetLastResult(E_SUCCESS);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_UlawDecoder::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       avcodec_flush_buffers(__pCodecCtx);
+
+       __decodeCalled = false;
+       SetLastResult(E_SUCCESS);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_UlawDecoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, __decodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+               value = _FfmpegUtil::ToAudioChannelType(__pCodecCtx->channels);
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE:
+               value = _FfmpegUtil::ToAudioSampleType(__pCodecCtx->sample_fmt);
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+               value = __pCodecCtx->sample_rate;
+       break;
+
+       default:
+               r = E_OBJ_NOT_FOUND;
+       break;
+       }
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_UlawDecoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, type > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, __decodeCalled, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_UlawDecoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+       pList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE);
+       pList->Add(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE);
+       pList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE);
+       SetLastResult(r);
+       return pList;
+
+CATCH:
+       return null;
+}
+
+bool
+_UlawDecoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, __pCodecCtx != null, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, type == MEDIA_PROPERTY_AUDIO_SAMPLE_RATE ||
+                          type == MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE ||
+                          type == MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+} } // Tizen::Media
diff --git a/src/FMedia_UlawDecoder.h b/src/FMedia_UlawDecoder.h
new file mode 100644 (file)
index 0000000..c0b70c6
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMedia_UlawDecoder.h
+ * @brief  This is the header file for the Tizen::Media::_UlawDecoder.
+ *
+ * This header file contains the declarations of the Tizen::Media::_UlawDecoder.
+ */
+#ifndef _FMEDIA_INTERNAL_UlawDecoder_H_
+#define _FMEDIA_INTERNAL_UlawDecoder_H_
+
+
+namespace Tizen { namespace Media
+{
+
+// Generally fiel header + format sub chunk is  36  byte + data chunk header 8 bytes;
+static const int _MIN_WAVE_HEADER_SIZE = 44;
+static const unsigned int _RIFF_CHUNK_ID = 0x46464952; // 'RIFF'
+static const unsigned int _RIFF_FORMAT_WAVE = 0x45564157; // 'WAVE'
+static const unsigned int _WAVE_FORMAT_CHUNK_ID = 0x20746d66; // 'fmt '
+static const unsigned int _WAVE_DATA_CHUNK_ID = 0x61746164; // 'data'
+
+struct _WavFormatInfo
+{
+       unsigned short formatTag;
+       unsigned short channels;
+       unsigned int samplesPerSec;
+       unsigned int avgBytesPerSec;
+       unsigned short blockAlign;
+       unsigned short bitsPerSample;
+};
+
+struct _RiffFileHeader
+{
+       unsigned int chunkId;
+       unsigned int size;
+       unsigned int format;
+};
+
+struct _RiffChunkHeader
+{
+       unsigned int chunkId;
+       unsigned int size;
+};
+
+class _UlawDecoder
+       : public _IAudioDecoder
+{
+public:
+       _UlawDecoder(void);
+
+       virtual ~_UlawDecoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* srcBuf, const int length,
+                                                AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate);
+
+       virtual result Decode(const byte* srcBuf, int srcBufSize, int &srcBufUsed,
+                                                 byte* dstBuf, int dstBufSize, int &dstBufUsed);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+private:
+       _UlawDecoder(const _UlawDecoder&);
+
+       _UlawDecoder& operator =(const _UlawDecoder&);
+
+private:
+       static const int OUT_BUFFER_SIZE = AVCODEC_MAX_AUDIO_FRAME_SIZE; // ffmpeg mandates this size as it checks with this size
+       static const int INPUT_BUFFER_PADDING_SIZE = 8;
+       static const int MONO_CHANNEL = 1;
+       static const int STEREO_CHANNEL = 2;
+
+       AVCodecContext* __pCodecCtx;
+       AVCodec* __pCodec;
+       bool __decodeCalled;
+       byte* __pOutBuf;
+       bool __decoderConfigured;
+};
+
+} } // Tizen::Media
+
+#endif // _FMEDIA_INTERNAL_UlawDecoder_H_
diff --git a/src/FMedia_VideoDecoderImpl.cpp b/src/FMedia_VideoDecoderImpl.cpp
new file mode 100644 (file)
index 0000000..99fac40
--- /dev/null
@@ -0,0 +1,249 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <stdio.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColHashMapT.h>
+#include <FMediaTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_IVideoDecoder.h"
+#include "FMedia_VideoDecoderImpl.h"
+#include "FMedia_CodecFactory.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_VideoDecoderImpl::_VideoDecoderImpl(void)
+{
+       __pDec = null;
+}
+
+_VideoDecoderImpl::~_VideoDecoderImpl(void)
+{
+       if (__pDec != null)
+       {
+               delete __pDec;
+       }
+}
+
+result
+_VideoDecoderImpl::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
+{
+       _IVideoDecoder* pVideoDecoder = null;
+       _CodecFactory* pCodecFactory = null;
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, !__pDec, E_INVALID_STATE, "already constructed");
+       pCodecFactory = _CodecFactory::GetInstance();
+       SysTryCatch(NID_MEDIA, null != pCodecFactory, r = E_SYSTEM, E_SYSTEM,
+                          "Construct Failed ");
+       r = pCodecFactory->CreateCodecInstance(type, pVideoDecoder);
+       SysTryCatch(NID_MEDIA, pVideoDecoder != null, , r, "Construct Failed ");
+       __pDec = pVideoDecoder;
+       r = __pDec->Construct(pOption);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "Construct Failed ");
+       return r;
+
+CATCH:
+       if (__pDec != null)
+       {
+               delete __pDec;
+               __pDec = null;
+       }
+       return r;
+}
+
+result
+_VideoDecoderImpl::Probe(const Tizen::Base::ByteBuffer& srcBuf, int& width, int& height, MediaPixelFormat& pixelFormat)
+{
+       result r = E_SUCCESS;
+       const byte* pSrcByteBuf = null;
+       int srcByteBufSize = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pDec, E_INVALID_STATE, "not constructed");
+       pSrcByteBuf = srcBuf.GetPointer() + srcBuf.GetPosition();
+       SysTryCatch(NID_MEDIA, null != pSrcByteBuf, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Probe Failed ");
+       srcByteBufSize = srcBuf.GetRemaining();
+
+       SysTryCatch(NID_MEDIA, srcByteBufSize > 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Probe Failed ");
+       r = __pDec->Probe(pSrcByteBuf, srcByteBufSize, width, height, pixelFormat);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "Probe Failed ");
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoDecoderImpl::Probe(const byte* pSrcBuf, int srcBugLength, int& width, int& height, MediaPixelFormat& pixelFormat)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pDec, E_INVALID_STATE, "not constructed");
+       r = __pDec->Probe(pSrcBuf, srcBugLength, width, height, pixelFormat);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "Probe Failed ");
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoDecoderImpl::Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf, bool& gotFrame)
+{
+       result r = E_INVALID_STATE;
+       const byte* pSrcByte = null;
+       byte* pDstByte = null;
+       int srcByteSize = 0;
+       int dstByteSize = 0;
+       int offset = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pDec, E_INVALID_STATE, "not constructed");
+       pSrcByte = srcBuf.GetPointer() + srcBuf.GetPosition();
+       pDstByte = (byte*) dstBuf.GetPointer() + dstBuf.GetPosition();
+       SysTryCatch(NID_MEDIA, (null != pDstByte && null != pSrcByte), r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Decode Failed ");
+       srcByteSize = srcBuf.GetRemaining();
+       dstByteSize = dstBuf.GetRemaining();
+       SysTryCatch(NID_MEDIA, (srcByteSize > 0 && dstByteSize > 0), r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Decode Failed ");
+
+       r = __pDec->Decode(pSrcByte, srcByteSize, pDstByte, dstByteSize, gotFrame);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                          "Decode Failed ");
+
+       offset = srcBuf.GetPosition();
+       if (offset + srcByteSize > srcBuf.GetLimit())
+       {
+               srcBuf.SetPosition(srcBuf.GetLimit());
+       }
+       else
+       {
+               srcBuf.SetPosition(offset + srcByteSize);
+       }
+
+       offset = dstBuf.GetPosition();
+       if (offset + dstByteSize > dstBuf.GetLimit())
+       {
+               dstBuf.SetPosition(dstBuf.GetLimit());
+       }
+       else
+       {
+               dstBuf.SetPosition(offset + dstByteSize);
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoDecoderImpl::Decode(const byte* pSrcBuf, int& srcBufLength, byte* pDstBuf, int& dstBufLength, bool& gotFrame)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pDec, E_INVALID_STATE, "not constructed");
+       r = __pDec->Decode(pSrcBuf, srcBufLength, pDstBuf, dstBufLength, gotFrame);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Decode Failed", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoDecoderImpl::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pDec, E_INVALID_STATE, "not constructed");
+
+       r = __pDec->Reset();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Reset Failed", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoDecoderImpl::GetValue(MediaPropertyType key, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pDec, E_INVALID_STATE, "not constructed");
+       r = __pDec->GetValue(key, value);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "Probe Failed ");
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoDecoderImpl::GetValue(MediaPropertyType key, float& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pDec, E_INVALID_STATE, "not constructed");
+       r = __pDec->GetValue(key, value);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] GetValue Failed", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_VideoDecoderImpl::GetSupportedPropertyListN(void) const
+{
+       SysTryReturn(NID_MEDIA, __pDec, null, E_INVALID_STATE, "[E_INVALID_STATE] not constructed");
+
+       return __pDec->GetSupportedPropertyListN();
+}
+
+bool
+_VideoDecoderImpl::IsPropertySupported(MediaPropertyType key) const
+{
+       SysTryReturn(NID_MEDIA, __pDec, false, E_INVALID_STATE, "[E_INVALID_STATE] not constructed");
+       return __pDec->IsPropertySupported(key);
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+_VideoDecoderImpl::GetSupportedCodecListN(void)
+{
+       _CodecFactory* pFactory = null;
+       Tizen::Base::Collection::IListT<CodecType>* pList = null;
+
+       pFactory = _CodecFactory::GetInstance();
+       SysTryReturn(NID_MEDIA, pFactory != null, null, E_OUT_OF_MEMORY, "[%s] Propagated.",
+                               GetErrorMessage(GetLastResult()));
+       pList = pFactory->GetSupportedVideoDecoderListN();
+       SysTryReturn(NID_MEDIA, pList != null, null, E_OUT_OF_MEMORY, "[%s] Propagated.",
+                               GetErrorMessage(GetLastResult()));
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_VideoDecoderImpl.h b/src/FMedia_VideoDecoderImpl.h
new file mode 100644 (file)
index 0000000..1ef49b0
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_VideoDecoderImpl.h
+ *  @brief  This is the header file for the _VideoDecoderImpl class.
+ *
+ *  This header file contains the declarations of the _VideoDecoderImpl class.
+ */
+
+       /**
+        *      Probes whether the video data can be decoded and sets the width, height, and pixel format of the video data.
+        *
+        *      @return  An error code
+        *      @param[in]      srcBuf                                  The source buffer that stores the compressed video data
+        *      @param[in]      srcBufLength                    The length of the source buffer
+        *      @param[out]     width                                   The width of the decoded video frame
+        *      @param[out]     height                                  The height of the decoded video frame
+        *      @param[out]     pixelFormat                             The pixel format of the decoded video frame
+        *
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_STATE          This method is invalid for the current state of this instance.
+        *      @exception      E_INVALID_ARG                   The specified @srcBuf is invalid.
+        *      @exception      E_UNSUPPORTED_FORMAT    The input data is not in a supported format.
+        *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
+        *      @exception  E_SYSTEM                            A system error has occurred.
+        *      @remarks        The method resets the internal state of the video decoder.
+        */
+
+       /**
+        *      Decodes the video data from the source buffer and stores the decoded data into the destination buffer.
+        *
+        *      @return  An error code
+        *
+        *      @param[in]              srcBuf                                  The source buffer that stores the compressed video data
+        *      @param[in/out]  srcBufLength                    The size of the source buffer
+        *      @param[out]             dstBuf                                  The destination buffer that stores the decoded video data
+        *      @param[in/out]  dstBufLength                    The size of the destination buffer
+        *      @param[out]             gotFrame                                @c true when a frame is decoded, @n
+        *                                                                                else @c false
+        *
+        *      @exception      E_SUCCESS                               The method is successful.
+        *      @exception      E_INVALID_STATE          This method is invalid for the current state of this instance.
+        *      @exception      E_INVALID_ARG                   The specified @c srcBuf or @c dstBuf is invalid.
+        *      @exception      E_UNSUPPORTED_FORMAT    The input data is not in a supported format.
+        *      @exception      E_OUT_OF_MEMORY                 The destination buffer has insufficient memory.
+        *  @exception  E_DIMENSION_CHANGED      The dimension of video stream has changed.
+        *      @exception  E_SYSTEM                            A system error has occurred.
+        *      @remarks        The destination buffer must have sufficient free space to store the decoded frame data.
+        *      @remarks        The decoder starts the decoding of the frame from the start of the  the source buffer,
+        *                              till the size mentioned in the srcBufSize. The consumed bytes is updated in the srcBufLength
+        *                              The decoder also fills the destination buffer with the decoded frame from the start of the destination buffer,
+        *                              and updated the data filled in dstBufLength
+        *  @remarks    When the first decoding begins, the E_DIMENSION_CHANGED exception can occur.
+        *                         An exception can also occur when the dimension of the video frame in the bitstream has changed.
+        *                         An application should increase the size of @c dstBuf if the @c dstBuf cannot hold the video frame with new dimensions.
+        *                         The video frame can be received even if the result is E_DIMENSION_CHANGED.
+        *                         The application should check the @c position of the destination buffer and the value of @c gotFrame
+        *                         when the result is E_DIMENSION_CHANGED.
+        *      @remarks        The H.264 video decoder returns data with the width and height in multiples of 16.
+        *                      The application should detect the width and height of the frame and crop the decoder's output data if the original dimension is not a multiple of 16.
+        *      @see Probe()
+        */
+#ifndef FMEDIA_INTERNAL_VIDEODECODERIMPL_H_
+#define FMEDIA_INTERNAL_VIDEODECODERIMPL_H_
+
+namespace Tizen { namespace Media
+{
+
+class _VideoDecoderImpl
+       : public Tizen::Base::Object
+{
+public:
+       _VideoDecoderImpl(void);
+
+       virtual ~_VideoDecoderImpl(void);
+
+       result Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption = null);
+
+       result Probe(const Tizen::Base::ByteBuffer& srcBuf, int& width, int& height, MediaPixelFormat& pixelFormat);
+
+       result Probe(const byte* pSrcBuf, int srcBugLength, int& width, int& height, MediaPixelFormat& pixelFormat);
+
+       result Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf, bool& gotFrame);
+
+       result Decode(const byte* pSrcBuf, int& srcBufLength, byte* pDstBuf, int& dstBufLength, bool& gotFrame);
+
+       result Reset(void);
+
+       result GetValue(MediaPropertyType key, int& value) const;
+
+       result GetValue(MediaPropertyType key, float& value) const;
+
+       Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       bool IsPropertySupported(MediaPropertyType key) const;
+
+       /**
+        * @see VideoDecder::GetSupportedCodecListN()
+        */
+       static Tizen::Base::Collection::IListT<CodecType>* GetSupportedCodecListN(void);
+
+private:
+       _VideoDecoderImpl(const _VideoDecoderImpl& dec);
+       _VideoDecoderImpl& operator =(const _VideoDecoderImpl& dec);
+
+       class _IVideoDecoder* __pDec;
+};
+
+};
+};
+
+
+#endif // FMEDIA_INTERNAL_VIDEODECODERIMPL_H_
diff --git a/src/FMedia_VideoEncoderImpl.cpp b/src/FMedia_VideoEncoderImpl.cpp
new file mode 100644 (file)
index 0000000..7fc3bc3
--- /dev/null
@@ -0,0 +1,223 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <stdio.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColHashMapT.h>
+#include <FMediaTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_IVideoEncoder.h"
+#include "FMedia_CodecFactory.h"
+#include "FMedia_VideoEncoderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+_VideoEncoderImpl::_VideoEncoderImpl(void)
+{
+       __pEnc = null;
+}
+
+_VideoEncoderImpl::~_VideoEncoderImpl(void)
+{
+       if (__pEnc != null)
+       {
+               delete __pEnc;
+       }
+}
+
+result
+_VideoEncoderImpl::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
+{
+       _IVideoEncoder* pVideoEncoder = null;
+       _CodecFactory* pCodecFactory = null;
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc == null, E_INVALID_STATE, "already constructed");
+
+       pCodecFactory = _CodecFactory::GetInstance();
+       SysTryCatch(NID_MEDIA, pCodecFactory != null, r = E_SYSTEM, E_SYSTEM,
+                          "Construct Failed ");
+       r = pCodecFactory->CreateCodecInstance(type, pVideoEncoder);
+       SysTryCatch(NID_MEDIA, pVideoEncoder != null, , r, "Construct Failed:%d", type);
+       __pEnc = pVideoEncoder;
+       r = __pEnc->Construct(pOption);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s]Construct Failed ", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       if (__pEnc != null)
+       {
+               delete __pEnc;
+               __pEnc = null;
+       }
+       return r;
+}
+
+result
+_VideoEncoderImpl::Encode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf)
+{
+       result r = E_INVALID_STATE;
+       const byte* pSrcByte = null;
+       byte* pDstByte = null;
+       int srcByteSize = 0;
+       int dstByteSize = 0;
+       int offset = 0;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+
+       pSrcByte = srcBuf.GetPointer() + srcBuf.GetPosition();
+       pDstByte = (byte*) dstBuf.GetPointer() + dstBuf.GetPosition();
+       SysTryCatch(NID_MEDIA, (null != pDstByte && null != pSrcByte), r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Encode Failed ");
+       srcByteSize = srcBuf.GetRemaining();
+       dstByteSize = dstBuf.GetRemaining();
+       SysTryCatch(NID_MEDIA, (srcByteSize > 0 && dstByteSize > 0), r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[E_INVALID_ARG] Encode Failed ");
+
+       r = __pEnc->Encode(pSrcByte, srcByteSize, pDstByte, dstByteSize);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                          "[%s] Encode Failed", GetErrorMessage(r));
+
+       offset = srcBuf.GetPosition();
+       if (offset + srcByteSize > srcBuf.GetLimit())
+       {
+               srcBuf.SetPosition(srcBuf.GetLimit());
+       }
+       else
+       {
+               srcBuf.SetPosition(offset + srcByteSize);
+       }
+
+       offset = dstBuf.GetPosition();
+       if (offset + dstByteSize > dstBuf.GetLimit())
+       {
+               dstBuf.SetPosition(dstBuf.GetLimit());
+       }
+       else
+       {
+               dstBuf.SetPosition(offset + dstByteSize);
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoEncoderImpl::Encode(const byte* srcBuf, int& srcBufLength, byte* dstBuf, int& dstBufLength)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+
+       r = __pEnc->Encode(srcBuf, srcBufLength, dstBuf, dstBufLength);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                          "[%s] Encode Failed", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoEncoderImpl::Reset(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+
+       r = __pEnc->Reset();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Reset Failed", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoEncoderImpl::SetValue(MediaPropertyType key, int value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+
+       r = __pEnc->SetValue(key, value);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] SetValue Failed", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoEncoderImpl::SetValue(MediaPropertyType key, bool value)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+
+       r = __pEnc->SetValue(key, value);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] SetValue Failed", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_VideoEncoderImpl::GetSupportedPropertyListN(void) const
+{
+       SysTryReturn(NID_MEDIA, __pEnc, null, E_INVALID_STATE, "[E_INVALID_STATE] not constructed");
+
+       return __pEnc->GetSupportedPropertyListN();
+}
+
+bool
+_VideoEncoderImpl::IsPropertySupported(MediaPropertyType key) const
+{
+       SysTryReturnResult(NID_MEDIA, __pEnc, E_INVALID_STATE, "not constructed");
+
+       return __pEnc->IsPropertySupported(key);
+}
+
+Tizen::Base::Collection::IListT<CodecType>*
+_VideoEncoderImpl::GetSupportedCodecListN(void)
+{
+       _CodecFactory* pFactory = null;
+       Tizen::Base::Collection::IListT<CodecType>* pList = null;
+
+       pFactory = _CodecFactory::GetInstance();
+       SysTryReturn(NID_MEDIA, pFactory != null, null, E_OUT_OF_MEMORY, "[%s] Propagated.",
+                               GetErrorMessage(GetLastResult()));
+       pList = pFactory->GetSupportedVideoEncoderListN();
+       SysTryReturn(NID_MEDIA, pList != null, null, E_OUT_OF_MEMORY, "[%s] Propagated.",
+                               GetErrorMessage(GetLastResult()));
+       SetLastResult(E_SUCCESS);
+       return pList;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_VideoEncoderImpl.h b/src/FMedia_VideoEncoderImpl.h
new file mode 100644 (file)
index 0000000..7792755
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_VideoEncoderImpl.h
+ *  @brief  This is the header file for _VideoEncoderImpl class.
+ *
+ *  This header file contains the declarations of _VideoEncoderImpl class.
+ */
+#ifndef FMEDIA_INTERNAL_VIDEOENCODERIMPL_H_
+#define FMEDIA_INTERNAL_VIDEOENCODERIMPL_H_
+
+
+namespace Tizen { namespace Media
+{
+
+class _VideoEncoderImpl
+       : public Tizen::Base::Object
+{
+public:
+       _VideoEncoderImpl(void);
+
+       virtual ~_VideoEncoderImpl(void);
+
+       result Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption = null);
+
+       result Encode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf);
+
+       result Encode(const byte* srcBuf, int& srcBufLength, byte* dstBuf, int& dstBufLength);
+
+       result Reset(void);
+
+       result SetValue(MediaPropertyType key, int value);
+
+       result SetValue(MediaPropertyType key, bool value);
+
+       Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       bool IsPropertySupported(MediaPropertyType key) const;
+
+       /**
+        * @see VideoEncoder::GetSupportedCodecListN()
+        */
+       static Tizen::Base::Collection::IListT<CodecType>* GetSupportedCodecListN(void);
+
+private:
+       _VideoEncoderImpl(const _VideoEncoderImpl& dec);
+       _VideoEncoderImpl& operator =(const _VideoEncoderImpl& dec);
+
+       class _IVideoEncoder* __pEnc;
+};
+
+};
+};
+#endif // FMEDIA_INTERNAL_VIDEOENCODERIMPL_H_
diff --git a/src/FMedia_VideoFrameExtractorImpl.cpp b/src/FMedia_VideoFrameExtractorImpl.cpp
new file mode 100644 (file)
index 0000000..1d68af2
--- /dev/null
@@ -0,0 +1,265 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMedia_VideoFrameExtractorImpl.cpp
+ * @brief  This file contains the implementation of VideoFrameExtractor's impl layer.
+ */
+
+#include <memory>
+#include <unique_ptr.h>
+#include <FMediaImageUtil.h>
+#include <FBaseSysLog.h>
+#include <metadata_extractor.h>
+#include "FMedia_VideoFrameExtractorImpl.h"
+#include "FMedia_ColorConverter.h"
+#include <FIo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media {
+
+_VideoFrameExtractorImpl::_VideoFrameExtractorImpl(void)
+       : __extractor(null)
+       , __pixelFormat(MEDIA_PIXEL_FORMAT_NONE)
+       , __width(0)
+       , __height(0)
+       , __duration(0)
+{
+}
+
+_VideoFrameExtractorImpl::~_VideoFrameExtractorImpl(void)
+{
+       if (__extractor != null)
+       {
+               metadata_extractor_destroy(__extractor);
+               __extractor = null;
+       }
+}
+
+
+_VideoFrameExtractorImpl*
+_VideoFrameExtractorImpl::GetInstance(VideoFrameExtractor *pVideoFrameExtractor)
+{
+       if (pVideoFrameExtractor != null)
+       {
+               return pVideoFrameExtractor->__pImpl;
+       }
+       return null;
+}
+
+const _VideoFrameExtractorImpl*
+_VideoFrameExtractorImpl::GetInstance(const VideoFrameExtractor *pVideoFrameExtractor)
+{
+       if (pVideoFrameExtractor != null)
+       {
+               return pVideoFrameExtractor->__pImpl;
+       }
+       return null;
+}
+
+result
+_VideoFrameExtractorImpl::Construct(const Tizen::Base::String &filePath, MediaPixelFormat pixelFormat)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+       std::unique_ptr<char[]> pPath;
+       int length = 0;
+
+       SysAssertf(__extractor == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       ret = metadata_extractor_create(&__extractor);
+       TryCatch(ret == METADATA_EXTRACTOR_ERROR_NONE, r = ToResult(ret), "metadata_extractor_create:%d", ret);
+
+       SysTryReturn(NID_MEDIA, !filePath.IsEmpty(), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+                       "[E_FILE_NOT_FOUND] path is empty");
+
+       SysTryReturn(NID_MEDIA, Tizen::Io::File::IsFileExist(filePath), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+                       "[E_FILE_NOT_FOUND] File is not Found: %ls",filePath.GetPointer());
+
+       SysTryReturn(NID_MEDIA, pixelFormat > MEDIA_PIXEL_FORMAT_NONE && pixelFormat < MEDIA_PIXEL_FORMAT_GRAY,
+               E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Pixel format (%d) is invalid.", pixelFormat);
+
+       __pixelFormat = pixelFormat;
+
+       length = filePath.GetLength();
+       pPath.reset(new (std::nothrow) char[length + 2]);
+
+       SysTryReturn(NID_MEDIA, pPath.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+               "[%s] Propagating. ", GetErrorMessage(GetLastResult()));
+
+       snprintf(pPath.get(), length+2, "%ls", filePath.GetPointer());
+
+       ret = metadata_extractor_set_path(__extractor, pPath.get());
+       TryCatch(ret == METADATA_EXTRACTOR_ERROR_NONE, r = ToResult(ret), "metadata_extractor_set_path:%d", ret);
+
+       r = GetMetaDataValue(__extractor, METADATA_VIDEO_WIDTH, __width);
+       TryCatch(r == E_SUCCESS, , "[%s] Propagating.", GetErrorMessage(r));
+
+       r = GetMetaDataValue(__extractor, METADATA_VIDEO_HEIGHT, __height);
+       TryCatch(r == E_SUCCESS, , "[%s] Propagating.", GetErrorMessage(r));
+
+       {
+               int val = 0;
+               r = GetMetaDataValue(__extractor, METADATA_DURATION, val);
+               TryCatch(r == E_SUCCESS, , "[%s] Propagating.", GetErrorMessage(r));
+               __duration = val;
+       }
+
+CATCH:
+       return r;
+}
+
+int
+_VideoFrameExtractorImpl::GetWidth(void) const
+{
+       return __width;
+}
+
+int
+_VideoFrameExtractorImpl::GetHeight(void) const
+{
+       return __height;
+}
+
+long
+_VideoFrameExtractorImpl::GetDuration(void) const
+{
+       return __duration;
+}
+
+ImageBuffer*
+_VideoFrameExtractorImpl::GetFrameN(long timestamp)
+{
+       result r = E_SUCCESS;
+       int ret = 0;
+       void* pFrame = null;
+       int frameSize = 0;
+       std::unique_ptr <byte[]> pBuf;
+       int bufLength = 0;
+       ByteBuffer srcBuf;
+       ByteBuffer dstBuf;
+       ImageBuffer* pImgBuf = null;
+       _ColorConverter cvt;
+
+       TryCatch(timestamp < __duration, r = E_OUT_OF_RANGE,
+                       "[%s] Propagating.",GetErrorMessage(E_OUT_OF_RANGE));
+
+       ret = metadata_extractor_get_frame_at_time(__extractor, timestamp, false, &pFrame, &frameSize );
+
+       TryCatch(ret == METADATA_EXTRACTOR_ERROR_NONE, r = ToResult(ret),
+                       "[%s] Propagating.",GetErrorMessage(ToResult(ret)));
+
+       TryCatch(pFrame != null && frameSize > 0, r = E_OPERATION_FAILED,
+                       "[%s] Propagating.",GetErrorMessage(E_OPERATION_FAILED));
+
+       pImgBuf = new (std::nothrow) ImageBuffer();
+       TryCatch(pImgBuf != null, r = E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = cvt.Construct(MEDIA_PIXEL_FORMAT_RGB888, __width, __height, __pixelFormat, __width, __height);
+       TryCatch(r == E_SUCCESS, delete pImgBuf; pImgBuf = null, "[%s] Color conversion failed.", GetErrorMessage(r));
+
+       pBuf.reset(cvt.ConvertN((byte*)pFrame, frameSize, bufLength));
+       r = GetLastResult();
+       TryCatch((r == E_SUCCESS) && (pBuf.get() != null) && (bufLength > 0), delete pImgBuf; pImgBuf = null,
+               "[%s] Color conversion failed.", GetErrorMessage(r));
+
+       r = pImgBuf->Construct(__width, __height, __pixelFormat, pBuf.get(), bufLength);
+       TryCatch(r == E_SUCCESS, delete pImgBuf; pImgBuf = null,
+               "[%s] Color conversion failed.", GetErrorMessage(r));
+
+       r = E_SUCCESS;
+
+CATCH:
+       if (pFrame != null)
+       {
+               free(pFrame);
+               pFrame = null;
+       }
+       SetLastResult(r);
+       return pImgBuf;
+}
+
+ImageBuffer*
+_VideoFrameExtractorImpl::GetFrameN(const Tizen::Base::String& filePath, MediaPixelFormat pixelFormat, long timestamp)
+{
+       result r = E_SUCCESS;
+       ImageBuffer* pImgBuf = null;
+
+       std::unique_ptr <_VideoFrameExtractorImpl> pImpl(new _VideoFrameExtractorImpl());
+       TryCatch(pImpl.get() != null, r = E_OUT_OF_MEMORY,
+               "[%s] Propagating. ", GetErrorMessage(GetLastResult()));
+
+       r = (pImpl.get())->Construct(filePath, pixelFormat);
+       TryCatch(r == E_SUCCESS, , "[%s] Failed to  Construct pImpl", GetErrorMessage(r));
+
+       pImgBuf = (pImpl.get())->GetFrameN(timestamp);
+       TryCatch(pImgBuf != null, r = GetLastResult(), "[%s] Propagating", GetErrorMessage(r));
+
+CATCH:
+       SetLastResult(r);
+       return pImgBuf;
+}
+
+result
+_VideoFrameExtractorImpl::ToResult(int ret)
+{
+       static struct
+       {
+               int slpError;
+               result ospError;
+       } errorMap[] = {
+               { METADATA_EXTRACTOR_ERROR_NONE, E_SUCCESS },
+               { METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER, E_INVALID_ARG },
+               { METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY },
+               { METADATA_EXTRACTOR_ERROR_FILE_EXISTS, E_FILE_NOT_FOUND },
+               { METADATA_EXTRACTOR_ERROR_OPERATION_FAILED, E_UNSUPPORTED_FORMAT },
+       };
+
+       for (unsigned int index = 0; index < sizeof(errorMap) / sizeof(errorMap[0]); index++)
+       {
+               if (errorMap[index].slpError == ret)
+               {
+                       return errorMap[index].ospError;
+               }
+       }
+
+       return E_UNKNOWN;
+}
+
+result
+_VideoFrameExtractorImpl::GetMetaDataValue(struct metadata_extractor_s*& extractor,int key, int &value)
+{
+       char* pOutStr = null;
+       result r = E_SUCCESS;
+       int ret = -1;
+
+       ret = metadata_extractor_get_metadata(extractor, (metadata_extractor_attr_e)key, &pOutStr);
+       TryCatch(ret == METADATA_EXTRACTOR_ERROR_NONE, r = ToResult(ret), "[%s] Propagating .", GetErrorMessage(ToResult(ret)));
+
+       value = atoi(pOutStr);
+       free(pOutStr);
+       pOutStr = null;
+
+CATCH:
+       return r;
+}
+
+}} // Tizen::Media
+
diff --git a/src/FMedia_VideoFrameExtractorImpl.h b/src/FMedia_VideoFrameExtractorImpl.h
new file mode 100644 (file)
index 0000000..89a4fc4
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMedia_VideoFrameExtractorImpl.h
+ * @brief  This is the header file for the %_VideoFrameExtractorImpl Implementation class.
+ *
+ * This header file contains the declarations of the %_VideoFrameExtractorImpl implementation class.
+ */
+
+#ifndef _FMEDIA_VIDEO_FRAME_EXTRACTOR_IMPL_H_
+#define _FMEDIA_VIDEO_FRAME_EXTRACTOR_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FMediaImageBuffer.h>
+#include <FMediaVideoFrameExtractor.h>
+
+namespace Tizen { namespace Media {
+
+class _VideoFrameExtractorImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * @see  VideoFrameExtractor::VideoFrameExtractor()
+        */
+
+       _VideoFrameExtractorImpl(void);
+
+       /**
+        * @see  VideoFrameExtractor::~VideoFrameExtractor()
+        */
+       virtual ~_VideoFrameExtractorImpl(void);
+
+       /**
+        * @see  VideoFrameExtractor::Construct()
+        */
+       result Construct(const Tizen::Base::String &filePath, MediaPixelFormat pixelFormat);
+
+       /**
+        * @see  VideoFrameExtractor::GetWidth()
+        */
+       int GetWidth(void) const;
+
+       /**
+        * @see  VideoFrameExtractor::GetHeight()
+        */
+       int GetHeight(void) const;
+
+       /**
+        * @see  VideoFrameExtractor::GetDuration()
+        */
+       long GetDuration(void) const;
+
+       /**
+        * @see  VideoFrameExtractor::GetFrameN()
+        */
+       ImageBuffer* GetFrameN(long timestamp);
+
+       /**
+        * @see  VideoFrameExtractor::GetFrameN()
+        */
+       static ImageBuffer* GetFrameN(const Tizen::Base::String& path, MediaPixelFormat pixelFormat, long timestamp);
+
+       static _VideoFrameExtractorImpl* GetInstance(VideoFrameExtractor *pVideoFrameExtractor);
+       static const _VideoFrameExtractorImpl* GetInstance(const VideoFrameExtractor *pVideoFrameExtractor);
+
+       static  result ToResult(int ret);
+       static  result GetMetaDataValue(struct metadata_extractor_s*& extractor,int key, int &value);
+
+private:
+
+       struct metadata_extractor_s* __extractor;
+       MediaPixelFormat __pixelFormat;
+       int __width;
+       int __height;
+       long __duration;
+};
+
+
+}} // Tizen::Media
+
+#endif //_FMEDIA_VIDEO_FRAME_EXTRACTOR_IMPL_H_
+
diff --git a/src/FMedia_VideoRecorderEvent.cpp b/src/FMedia_VideoRecorderEvent.cpp
new file mode 100755 (executable)
index 0000000..928aa24
--- /dev/null
@@ -0,0 +1,130 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_VideoRecorderEvent.cpp
+ * @brief                      This is the implementation file for the %_VideoRecorderEvent class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include "FMediaIVideoRecorderEventListener.h"
+#include "FMedia_VideoRecorderEvent.h"
+#include "FMedia_RecorderEventArg.h"
+#include "FMedia_VideoRecorderImpl.h"
+
+namespace Tizen { namespace Media
+{
+
+_VideoRecorderEvent::_VideoRecorderEvent(void)
+:__pVideoRecorderImpl(null)
+{
+
+}
+
+_VideoRecorderEvent::~_VideoRecorderEvent(void)
+{
+
+}
+
+result
+_VideoRecorderEvent::Construct(_VideoRecorderImpl& videoRecorderImpl)
+{
+       result r = E_SUCCESS;
+       __pVideoRecorderImpl = &videoRecorderImpl;
+       r = _Event::Initialize();
+       return r;
+}
+
+result
+_VideoRecorderEvent::SendEvent(_RecorderEventType event, RecorderErrorReason err, result res)
+{
+       result r = E_SUCCESS;
+       std::unique_ptr <_RecorderEventArg> pRecorderEventArg (new (std::nothrow) _RecorderEventArg());
+       SysTryReturn(NID_MEDIA, pRecorderEventArg.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       pRecorderEventArg->SetEventType(event);
+       pRecorderEventArg->SetResult(res);
+       pRecorderEventArg->SetError(err);
+       r = FireAsync(*(pRecorderEventArg.get()));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       // In case of success, event argument should be released for Base::Event to use the argument continuously.
+       pRecorderEventArg.release();
+       return r;
+}
+
+void
+_VideoRecorderEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       IVideoRecorderEventListener* pVideoRecorderEventListener = dynamic_cast <IVideoRecorderEventListener*>(&listener);
+       SysTryReturn(NID_MEDIA, pVideoRecorderEventListener != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
+
+       Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <Tizen::Base::Runtime::IEventArg*>(&arg);
+       _RecorderEventArg* pArg = dynamic_cast <_RecorderEventArg*>(pTempArg);
+       SysTryReturn(NID_MEDIA, pArg != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
+
+       switch (pArg->GetEventType())
+       {
+       case _RECORDER_EVENT_ERROR:
+               __pVideoRecorderImpl->SetState(RECORDER_STATE_ERROR);
+               pVideoRecorderEventListener->OnVideoRecorderErrorOccurred(pArg->GetError());
+               break;
+
+       case _RECORDER_EVENT_RECORDING_STARTED:
+               __pVideoRecorderImpl->SetState(RECORDER_STATE_RECORDING);
+               pVideoRecorderEventListener->OnVideoRecorderStarted(pArg->GetResult());
+               break;
+
+       case _RECORDER_EVENT_STOPPED:
+               __pVideoRecorderImpl->SetState(RECORDER_STATE_STOPPED);
+               pVideoRecorderEventListener->OnVideoRecorderStopped(pArg->GetResult());
+               break;
+
+       case _RECORDER_EVENT_CANCELED:
+               __pVideoRecorderImpl->SetState(RECORDER_STATE_STOPPED);
+               pVideoRecorderEventListener->OnVideoRecorderCanceled(pArg->GetResult());
+               break;
+
+       case _RECORDER_EVENT_ENDOF_FILESIZE:
+               __pVideoRecorderImpl->SetState(RECORDER_STATE_ENDOF_FILE);
+               pVideoRecorderEventListener->OnVideoRecorderEndReached(RECORDING_ENDOF_MAX_SIZE);
+               break;
+
+       case _RECORDER_EVENT_ENDOF_RECTIME:
+               __pVideoRecorderImpl->SetState(RECORDER_STATE_ENDOF_FILE);
+               pVideoRecorderEventListener->OnVideoRecorderEndReached(RECORDING_ENDOF_MAX_TIME);
+               break;
+
+       case _RECORDER_EVENT_PAUSED:
+               __pVideoRecorderImpl->SetState(RECORDER_STATE_PAUSED);
+               pVideoRecorderEventListener->OnVideoRecorderPaused(pArg->GetResult());
+               break;
+
+       case _RECORDER_EVENT_CLOSED:
+               __pVideoRecorderImpl->SetState(RECORDER_STATE_CLOSED);
+               pVideoRecorderEventListener->OnVideoRecorderClosed(pArg->GetResult());
+               break;
+
+       default:
+               break;
+
+       }
+}
+
+}}
+
diff --git a/src/FMedia_VideoRecorderEvent.h b/src/FMedia_VideoRecorderEvent.h
new file mode 100755 (executable)
index 0000000..71f426c
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_VideoRecorderEvent.h
+ * @brief                      This is the header file for the %_VideoRecorderEvent class.
+*/
+
+#ifndef _FMEDIA_INTERNAL_VIDEORECORDER_EVENT_H_
+#define _FMEDIA_INTERNAL_VIDEORECORDER_EVENT_H_
+
+#include <FBaseRt_Event.h>
+#include <FMediaRecorderTypes.h>
+#include "FMedia_RecorderTypes.h"
+
+namespace Tizen { namespace Media
+{
+class _VideoRecorderImpl;
+
+/**
+ *     This class provides the Recorder event.
+ *
+ *     This class is the Recorder event, which can notify to the listeners which derives IVideoRecorderEventListener.
+ *     This event is fired upon receipt of notification from subsystem.
+ *     For instances, when the presentation of playback reaches the end of media file, IVideoRecorderEventListener::OnEndOfFileSize is invoked.
+ *
+ *     @see    VideoRecorder, __VideoRecorderEventArg, IVideoRecorderEventListener
+ */
+class _VideoRecorderEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       /**
+       *       The constructor.
+       */
+       _VideoRecorderEvent(void);
+
+       /**
+        *      The destructor.
+        */
+       ~_VideoRecorderEvent(void);
+
+       /**
+        * Initializes a new instance of this class
+        *      @param[in]      videoRecorderImpl       The _VideoRecorderImpl object
+        *
+        */
+       result Construct(_VideoRecorderImpl& videoRecorderImpl);
+
+       /**
+            *  Sends event synchronously.
+            *
+            *  @return         The error code.
+            *  @param[in]      event                                   The event type.
+            *  @param[in]      err                                             The error reason
+            *  @param[in]      res                                             The result of the event
+            *  @exception      E_SUCCESS                                                    - This method is successful.
+            *  @exception      E_OUT_OF_MEMORY                                  - Failed to allocate the required/requested memory.
+            *  @exception      E_INVALID_STATE                 - The current state of the camera is inappropriate or invalid for this method.
+            *  @exception      E_INVALID_ARG                                - The argument passed to a method contains an invalid value.
+            */
+       result SendEvent(_RecorderEventType event, RecorderErrorReason err, result res);
+
+protected:
+       /**
+        *      Finds out and invokes the method of listener corresponding to the specified event argument.
+        *
+        * @param[in]   listener                                               An event listener to be invoked. This must be an instance of ICameraEventListener.
+        * @param[in]   arg                                                           An argument to be fired.
+        *      @exception      E_SUCCESS                                                    - This method is successful.
+        *      @exception      E_OUT_OF_MEMORY                                  - Failed to allocate the required/requested memory.
+        *      @exception      E_INVALID_STATE                 - The current state of the camera is inappropriate or invalid for this method.
+        *      @exception      E_INVALID_ARG                                - The argument passed to a method contains an invalid value.
+        */
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+       _VideoRecorderEvent(const _VideoRecorderEvent& rhs);
+       _VideoRecorderEvent& operator =(const _VideoRecorderEvent& rhs);
+
+       _VideoRecorderImpl* __pVideoRecorderImpl;
+};
+
+}}
+
+#endif
diff --git a/src/FMedia_VideoRecorderImpl.cpp b/src/FMedia_VideoRecorderImpl.cpp
new file mode 100755 (executable)
index 0000000..184d09e
--- /dev/null
@@ -0,0 +1,1709 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                FMedia_VideoRecorderImpl.cpp
+* @brief               This is the implementation file for the %_VideoRecorderImpl class.
+*/
+
+#include <unique_ptr.h>
+#include <camera.h>
+#include <recorder.h>
+#include <FBaseInteger.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FMediaVideoRecorder.h>
+#include "FMedia_CameraImpl.h"
+#include "FMedia_CapabilityImpl.h"
+#include "FMedia_CameraCoordinator.h"
+#include "FMedia_VideoRecorderImpl.h"
+#include "FMedia_VideoRecorderEvent.h"
+#include "FMedia_VideoSourceAdapter.h"
+#include "FMedia_CameraUtil.h"
+#include "FMedia_RecorderUtil.h"
+#include "FMedia_RecorderCapability.h"
+#include "FMedia_CamPtrUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media
+{
+static const int _RELOAD_FORMAT = 0x1;
+static const int _RELOAD_QUALITY = 0x1 << 1;
+static const int _RELOAD_MAX_TIME = 0x1 << 2;
+static const int _RELOAD_RECORD_RESOLUTION = 0x1 << 3;
+static const int _RELOAD_FILE_PATH = 0x1 << 4;
+static const int _RELOAD_INIT = 0x1 << 5;
+static const int _RELOAD_CALLBACK = 0x1 << 6;
+static const int _RELOAD_MUTE = 0x1 << 7;
+static const int _RELOAD_ROTATION = 0x1 << 8;
+
+typedef int (*_VideoRecorderFunc)(_RecorderHandle mmHandle);
+
+typedef struct
+{
+       recorder_state_e preState;
+       recorder_state_e postState;
+       _RecorderStateChangeReason reason;
+       _VideoRecorderFunc pFunc;
+       RecorderState state;
+}_VideoCommandStateTable;
+
+static const _VideoCommandStateTable _VIDEO_COMMAND_STATE[] =
+{
+       {::RECORDER_STATE_CREATED, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, recorder_prepare, (RecorderState)-1 },
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL, recorder_start, RECORDER_STATE_STARTING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_PAUSED, _RECORDER_STATE_REASON_NORMAL, recorder_pause, RECORDER_STATE_PAUSING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, recorder_commit, RECORDER_STATE_STOPPING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_CANCEL, recorder_cancel, RECORDER_STATE_STOPPING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_SIZE_REACHED, recorder_commit, RECORDER_STATE_RECORDING },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_TIME_REACHED, recorder_commit, RECORDER_STATE_RECORDING },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL, recorder_start, RECORDER_STATE_STARTING },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, recorder_commit, RECORDER_STATE_STOPPING },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_CANCEL, recorder_cancel, RECORDER_STATE_STOPPING },
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_CREATED, _RECORDER_STATE_REASON_NORMAL, recorder_unprepare, RECORDER_STATE_CLOSING },
+};
+
+typedef struct
+{
+       recorder_state_e prevState;
+       recorder_state_e postState;
+       _RecorderStateChangeReason reason;
+       _RecorderEventType event;
+       RecorderErrorReason error;
+}_VideoCallbackEventTable;
+
+static const _VideoCallbackEventTable _VIDEO_CALLBACK_EVENT[] =
+{
+       {::RECORDER_STATE_READY, ::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_RECORDING_STARTED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_PAUSED, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_PAUSED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_STOPPED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_CANCEL, _RECORDER_EVENT_CANCELED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_SIZE_REACHED, _RECORDER_EVENT_ENDOF_FILESIZE, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_TIME_REACHED, _RECORDER_EVENT_ENDOF_RECTIME, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_RECORDING, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_OUT_OF_STORAGE, _RECORDER_EVENT_ERROR, RECORDER_ERROR_OUT_OF_STORAGE },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_RECORDING, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_RECORDING_STARTED, RECORDER_ERROR_NONE },
+       {::RECORDER_STATE_PAUSED, ::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_STOPPED, RECORDER_ERROR_NONE },
+//     {::RECORDER_STATE_READY, ::RECORDER_STATE_CREATED, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_CLOSED, RECORDER_ERROR_NONE },
+};
+
+typedef struct
+{
+       const char* pCodecName;
+       CodecType audioCodec;
+       CodecType videoCodec;
+       MediaContainerType container;
+}_CodecValTable;
+
+static const _CodecValTable _CODEC_VAL_TABLE[] =
+{
+       {"VIDEO_CODEC_NONE",            CODEC_NONE,     CODEC_NONE,     MEDIA_CONTAINER_NONE},
+       {"VIDEO_CODEC_H263",            CODEC_AMR_NB, CODEC_H263,       MEDIA_CONTAINER_3GP},           //TODO bug reported
+//     {"VIDEO_CODEC_H263",            CODEC_AAC,      CODEC_H263,     MEDIA_CONTAINER_3GP},
+       {"VIDEO_CODEC_MPEG4SP",         CODEC_AAC,      CODEC_MPEG4,    MEDIA_CONTAINER_MP4},
+       {"VIDEO_CODEC_H264",            CODEC_AAC,      CODEC_H264,     MEDIA_CONTAINER_MP4},
+       {null,                                          CODEC_NONE,     CODEC_NONE,     MEDIA_CONTAINER_NONE}
+};
+
+bool _VideoRecorderImpl::__isUsed = false;
+
+_VideoRecorderImpl::_VideoRecorderImpl(void)
+       : __pCoordinator(null)
+       , __pVideoRecorderEvent(null)
+       , __pVideoRecorderEventListener(null)
+       , __pVideoSourceAdapter(null)
+       , __isConstructed(false)
+       , __state(RECORDER_STATE_INITIALIZED)
+       , __recTime(-1)
+       , __recSize(-1)
+       , __maxTime(DEFAULT_VIDEORECORDING_TIME)
+       , __format(VIDEORECORDING_FORMAT_DEFAULT)
+       , __audioCodec(CODEC_AAC)               // TODO
+       , __videoCodec(CODEC_MPEG4)
+       , __container(MEDIA_CONTAINER_MP4)
+       , __mode(VIDEORECORDER_MODE_VIDEO_WITH_AUDIO)
+       , __quality(RECORDING_QUALITY_MEDIUM)
+       , __mute(false)
+       , __rotation(RECORDING_ROTATION_NONE)
+       , __handle(MM_INVALID_HANDLE)
+       ,__deviceType(_RECORDER_DEVICE_NONE)
+       ,__mmSourceFormat(CAMERA_PIXEL_FORMAT_INVALID)
+       ,__stateChangeReason(_RECORDER_STATE_REASON_NORMAL)
+{
+       __recordingResolution.width = 0;
+       __recordingResolution.height = 0;
+
+}
+
+_VideoRecorderImpl::~_VideoRecorderImpl(void)
+{
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               int err = ::RECORDER_ERROR_NONE;
+               err = recorder_unset_state_changed_cb(__handle);
+               err = recorder_unset_recording_limit_reached_cb(__handle);
+               err = recorder_unset_error_cb(__handle);
+               err = recorder_unset_recording_status_cb(__handle);
+               err = recorder_unset_interrupted_cb(__handle);
+               __handle = MM_INVALID_HANDLE;
+       }
+       if (__pCoordinator != null)
+       {
+               __pCoordinator->ChangeMode(_CAMERA_MODE_IMAGE, false);
+               __pCoordinator->RemoveCameraCoordinatorListener(*this);
+
+               _CameraCoordinator::Release(__deviceType);
+       }
+
+       if (__pVideoSourceAdapter != null)
+       {
+               delete __pVideoSourceAdapter;
+       }
+
+       if (__pVideoRecorderEvent != null)
+       {
+               delete __pVideoRecorderEvent;
+       }
+
+       if ( __isConstructed )
+       {
+               __isUsed = false;
+       }
+
+       SysLog(NID_MEDIA, "video recorder Destroyed");
+}
+
+result
+_VideoRecorderImpl::Construct(IVideoRecorderEventListener& listener, const Camera& camera)
+{
+       result r = E_SUCCESS;
+       Tizen::Media::Camera* pCamera = null;
+       Tizen::Media::_CameraImpl* pCamImpl = null;
+       _CameraHandle cameraHandle = MM_INVALID_HANDLE;
+       int err = MM_SUCCESS;
+
+       SysTryReturn(NID_MEDIA, !__isUsed, E_DEVICE_BUSY, E_DEVICE_BUSY, "[E_DEVICE_BUSY] _VideoRecorderImpl is now being used.");
+       SysTryReturn(NID_MEDIA, !__isConstructed, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state. A device is already constructed.");
+       SysLog(NID_MEDIA, "video recorder construct");
+
+       pCamera = const_cast<Tizen::Media::Camera*>(&camera);
+       pCamImpl = _CameraImpl::GetInstance(pCamera);
+
+       // Source Adapter
+       __pVideoSourceAdapter = new (std::nothrow) _VideoSourceAdapter(*pCamImpl);
+       SysTryCatch(NID_MEDIA, __pVideoSourceAdapter != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       // Create Event
+       __pVideoRecorderEvent = new (std::nothrow) _VideoRecorderEvent();
+       SysTryCatch(NID_MEDIA, __pVideoRecorderEvent != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = __pVideoRecorderEvent->Construct(*this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = __pVideoRecorderEvent->AddListener(listener);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pVideoRecorderEventListener = &listener;
+
+       __deviceType = (pCamImpl->GetSelection() == CAMERA_PRIMARY ? _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA
+               : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA);
+
+       __pCoordinator = _CameraCoordinator::AddInstance(__deviceType);
+       r = GetLastResult();
+       SysTryCatch(NID_MEDIA, __pCoordinator != null, , r, "[E_OBJ_NOT_FOUND] _CameraCoordinator instance is not available.");
+
+       r = __pCoordinator->AddCameraCoordinatorListener(*this);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       //If the reload flag is true, the __handle will be updated in the OnCameraCoordinatorModeChangePrepared(), otherwise the __handle should be updated manually.
+       r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false);              // Do not reload. The __mmSourceFormat is not set yet.
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder Mode change failed.", GetErrorMessage(r));
+
+       __handle = __pCoordinator->GetRecorderHandle();
+       cameraHandle = __pCoordinator->GetCameraHandle();
+       r = __pVideoSourceAdapter->SetRecommendPreviewFormat(cameraHandle);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video adapter SetRecommendPreviewFormat failed.", GetErrorMessage(r));
+
+       err = recorder_set_state_changed_cb(__handle, StateChangedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set message callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_recording_limit_reached_cb(__handle, LimitReachedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_recording_status_cb(__handle, RecordingStatusCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set recording status callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_error_cb(__handle, ErrorCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_interrupted_cb(__handle, InterruptedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       r = LoadDefaultConfiguration(_RELOAD_RECORD_RESOLUTION);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       SetState(RECORDER_STATE_INITIALIZED);
+       __isConstructed = true;
+       __isUsed = true;
+
+       return r;
+
+CATCH:
+       if (__handle)
+       {
+               err = recorder_unset_state_changed_cb(__handle);
+               err = recorder_unset_recording_limit_reached_cb(__handle);
+               err = recorder_unset_error_cb(__handle);
+               err = recorder_unset_recording_status_cb(__handle);
+               err = recorder_unset_interrupted_cb(__handle);
+               __handle = MM_INVALID_HANDLE;
+       }
+
+       if (__pCoordinator != null)
+       {
+               __pCoordinator->RemoveCameraCoordinatorListener(*this);
+       }
+
+       if (__pVideoSourceAdapter != null)
+       {
+               delete __pVideoSourceAdapter;
+               __pVideoSourceAdapter = null;
+       }
+
+       if (__pVideoRecorderEventListener != null)
+       {
+               __pVideoRecorderEvent->RemoveListener(*__pVideoRecorderEventListener);
+               __pVideoRecorderEventListener = null;
+       }
+
+       if (__pVideoRecorderEvent != null)
+       {
+               delete __pVideoRecorderEvent;
+               __pVideoRecorderEvent = null;
+       }
+
+       return r;
+}
+
+result
+_VideoRecorderImpl::CreateVideoFile(const Tizen::Base::String& mediaLocalPath, bool overwrite)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "video recorder create video file");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED || state == RECORDER_STATE_CLOSED,
+                               E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state.");
+
+       std::unique_ptr<char[]> pFileName (_StringConverter::CopyToCharArrayN(mediaLocalPath));
+       SysTryCatch(NID_MEDIA, pFileName.get() != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(mediaLocalPath) is used.  File name is null.");
+       SysLog(NID_MEDIA, "File Path : %s\n, overwrite:%d", pFileName.get(), overwrite);
+
+       r = _RecorderUtil::PrepareFile(mediaLocalPath, overwrite);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder prepare file failed. mediaLocalPath:%s, overwirte:%d",
+                          GetErrorMessage(r), pFileName.get(), overwrite);
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               err = recorder_set_filename(__handle, pFileName.get());
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       SetState(RECORDER_STATE_OPENED);
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               // re-configuration for new recorder handle
+               r = ReloadConfiguration(_RELOAD_FORMAT | _RELOAD_QUALITY | _RELOAD_MAX_TIME | _RELOAD_INIT | _RELOAD_ROTATION);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration failed", GetErrorMessage(r));
+       }
+
+       __filePath = mediaLocalPath;
+       return r;
+
+CATCH:
+       SetState(state);
+       return r;
+}
+
+result
+_VideoRecorderImpl::Close(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "video recorder close");
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_OPENED || state == RECORDER_STATE_STOPPED
+               || state == RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_ERROR
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d", state);
+
+       // Just send closed event
+       r = GetEvent()->SendEvent(_RECORDER_EVENT_CLOSED, RECORDER_ERROR_NONE, E_SUCCESS);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::Record(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       recorder_state_e mmState = ::RECORDER_STATE_NONE;
+       SysLog(NID_MEDIA, "video recorder record");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_OPENED || state == RECORDER_STATE_PAUSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d",     state);
+
+       if (__pVideoSourceAdapter->HasRecordingResolutionRestriction())
+       {
+               SysTryReturn(NID_MEDIA, __recordingResolution == __pVideoSourceAdapter->GetSourceResolution()
+                       , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  __recordingResolution(%d,%d) is not same VideoSourceResolution.", __recordingResolution.width, __recordingResolution.height);
+       }
+
+       std::unique_ptr<IListT<camera_pixel_format_e>, _ListPtrUtil::Remover> pSupportedMmSourceFormatList (__pVideoSourceAdapter->GetSupportedRecordingFormatListN(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pSupportedMmSourceFormatList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Source's supported recording format is empty");
+
+       // In case of the preview format is not supported to the Video Recorder, regardless of the current mode,
+       // the recorder should be reset and the preview format should be changed for recording supported one.
+       if ( !pSupportedMmSourceFormatList->Contains(__pCoordinator->GetCameraSourceFormat()))
+       {
+               SysLog(NID_MEDIA, "Current coordinaotr's mm format(%d) is not supported to record.", __pCoordinator->GetCameraSourceFormat());
+               r = pSupportedMmSourceFormatList->GetAt(0, __mmSourceFormat);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Camera mode change failed.", GetErrorMessage(r));
+
+               // If the preview data format is changed, the properties should be set again.
+               r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, true);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder Mode change failed.", GetErrorMessage(r));
+       }
+       else if ( __pCoordinator->GetMode() != _CAMERA_MODE_VIDEO )
+       {
+               SysLog(NID_MEDIA, "Current mode is IMAGE. It should be moved to VIDEO mode.");
+
+               __mmSourceFormat = __pCoordinator->GetCameraSourceFormat();
+               r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, true);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder Mode change failed.", GetErrorMessage(r));
+       }
+
+       mmState = GetMmState();
+       switch (mmState)
+       {
+       case ::RECORDER_STATE_CREATED:
+               r = ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder init failed.", GetErrorMessage(r));
+
+               r = __pCoordinator->StartRecord();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder start failed.", GetErrorMessage(r));
+               __stateChangeReason = _RECORDER_STATE_REASON_NORMAL;
+               SetState(RECORDER_STATE_STARTING);
+               break;
+
+       case ::RECORDER_STATE_READY:
+               r = __pCoordinator->StartRecord();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder start failed.", GetErrorMessage(r));
+               __stateChangeReason = _RECORDER_STATE_REASON_NORMAL;
+               SetState(RECORDER_STATE_STARTING);
+               break;
+
+       case ::RECORDER_STATE_PAUSED:
+               r = __pCoordinator->StartRecord();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder resume failed.", GetErrorMessage(r));
+               __stateChangeReason = _RECORDER_STATE_REASON_NORMAL;
+               SetState(RECORDER_STATE_STARTING);
+               break;
+
+       default:
+               break;
+       }
+
+
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::Stop(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter.");
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_RECORDING || state == RECORDER_STATE_PAUSING || state == RECORDER_STATE_PAUSED
+               || state == RECORDER_STATE_STARTING
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d",
+               state);
+
+       r = ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_NORMAL);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder record stop failed.", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::Pause(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter.");
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_RECORDING, E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d",
+                               state);
+
+       r = ChangeStateTo(::RECORDER_STATE_PAUSED, _RECORDER_STATE_REASON_NORMAL);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder pause failed.", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::Cancel(void)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter.");
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_RECORDING || state == RECORDER_STATE_PAUSING || state == RECORDER_STATE_PAUSED
+               || state == RECORDER_STATE_STARTING, E_INVALID_STATE, E_INVALID_STATE,
+               "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d", state);
+
+       r = ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_CANCEL);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder cancel failed.", GetErrorMessage(r));
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+RecorderState
+_VideoRecorderImpl::GetState(void) const
+{
+       return __state;
+}
+
+long
+_VideoRecorderImpl::GetRecordingTime(void) const
+{
+       return __recTime;
+}
+
+long
+_VideoRecorderImpl::GetRecordingSize(void) const
+{
+       return __recSize;
+}
+
+result
+_VideoRecorderImpl::SetMaxRecordingTime(long msTime)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter. msTime:%d", msTime);
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.",
+               state);
+
+       SysTryReturn(NID_MEDIA, msTime > 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] msTime is out of range. msTime:%d must be greater than 0.",
+                               msTime);
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               r = SetMaxRecordingTimeAttr(msTime);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder set max recording time failed. msTime:%ls", GetErrorMessage(r), msTime);
+       }
+       // For reload and Get the exact value
+       __maxTime = msTime;
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+long
+_VideoRecorderImpl::GetMaxRecordingTime(void) const
+{
+       return __maxTime;
+}
+
+result
+_VideoRecorderImpl::SetCodec(const Tizen::Base::String& codec)
+{
+       result r = E_SUCCESS;
+       CodecType audioCodec = CODEC_NONE;
+       CodecType videoCodec = CODEC_NONE;
+       MediaContainerType container = MEDIA_CONTAINER_NONE;
+       SysLog(NID_MEDIA, "Enter. codec:%ls", codec.GetPointer());
+       SysTryReturn(NID_MEDIA, !codec.IsEmpty(), E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC, "[E_UNSUPPORTED_CODEC] The codec is empty.\n");
+
+       RecorderState state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE
+                               || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d", state);
+
+       std::unique_ptr<IList, _ListPtrUtil::Remover> pList (GetSupportedCodecListN(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryCatch(NID_MEDIA, pList->Contains(codec), r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC, "[E_UNSUPPORTED_CODEC]. This codec(%ls) is not supported in the device.\n", codec.GetPointer());
+
+       GetMediaType(codec, audioCodec, videoCodec, container);
+       SysTryCatch(NID_MEDIA, audioCodec != CODEC_NONE && videoCodec != CODEC_NONE, r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC
+               , "[E_UNSUPPORTED_CODEC]. This codec(%ls) is not supported in the device.\n", codec.GetPointer());
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               r = SetFormatAttr(audioCodec, videoCodec, container);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set  failed. audioCodec:0x%x videoCodec:0x%x  container:0x%x",
+                               GetErrorMessage(r), audioCodec, videoCodec, videoCodec);
+       }
+       __audioCodec = audioCodec;
+       __videoCodec = videoCodec;
+       __container = container;
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               // Call the dependency function.
+               r = ReloadConfiguration(_RELOAD_QUALITY);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
+       }
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::String
+_VideoRecorderImpl::GetCodec(void) const
+{
+       String codec;
+       GetCodecString(__videoCodec, codec);
+       return codec;
+}
+
+Tizen::Base::Collection::IList*
+_VideoRecorderImpl::GetSupportedCodecListN(void) const
+{
+       _CapabilityImpl *pCapImpl = null;
+       result r = E_SUCCESS;
+
+       pCapImpl = _CapabilityImpl::GetInstance();
+       SysTryReturn(NID_MEDIA, pCapImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Get capability information failed.");
+
+       std::unique_ptr<ArrayList, _ListPtrUtil::Remover> pCodecList (new (std::nothrow) Tizen::Base::Collection::ArrayList(), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pCodecList.get() !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pCodecList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder get attribute failed.", GetErrorMessage(r));
+
+       r = pCapImpl->GetValueN(VIDEORECORDER_CODEC, *(pCodecList.get()));
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Converted from '%s'.", GetErrorMessage(r));
+       SysTryCatch(NID_MEDIA, pCodecList.get() != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryCatch(NID_MEDIA, pCodecList->GetCount() > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       return pCodecList.release();
+
+CATCH:
+       return null;
+}
+
+result
+_VideoRecorderImpl::SetFormat(VideoRecordingFormat format)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       CodecType audioCodec = CODEC_NONE;
+       CodecType videoCodec = CODEC_NONE;
+       MediaContainerType container = MEDIA_CONTAINER_NONE;
+       SysLog(NID_MEDIA, "Enter. format:%d", format);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE
+                               || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.", state);
+
+       SysTryReturn(NID_MEDIA, format >= VIDEORECORDING_FORMAT_DEFAULT && format <= VIDEORECORDING_FORMAT_3GP
+                          , E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] The format(%d) is not supported.\n",
+                               format);
+
+       GetMediaType(format, audioCodec, videoCodec, container);
+       SysTryCatch(NID_MEDIA, audioCodec != CODEC_NONE && videoCodec != CODEC_NONE, r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC
+               , "[E_UNSUPPORTED_CODEC]. This format(%d) is not supported in the device.\n", format);
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               r = SetFormatAttr(audioCodec, videoCodec, container);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set  failed. audioCodec:0x%x videoCodec:0x%x  container:0x%x",
+                               GetErrorMessage(r), audioCodec, videoCodec, videoCodec);
+       }
+       __format = format;
+       __audioCodec = audioCodec;
+       __videoCodec = videoCodec;
+       __container = container;
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               // Call the dependency function.
+               r = ReloadConfiguration(_RELOAD_QUALITY);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+VideoRecordingFormat
+_VideoRecorderImpl::GetFormat(void) const
+{
+       return __format;
+}
+
+result
+_VideoRecorderImpl::SetFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       bool supported = false;
+       SysLog(NID_MEDIA, "Enter. audioCodec:0x%x, videoCodec:0x%x, container:0x%x", audioCodec, videoCodec, container);
+
+       state = GetState();
+       SysTryReturn(
+               NID_MEDIA, state == RECORDER_STATE_INITIALIZED || state == RECORDER_STATE_OPENED || state ==
+               RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.",
+               state);
+
+       std::unique_ptr<ArrayListT<CodecType>, _ListPtrUtil::Remover> pAudioCodecListT (GetSupportedAudioCodecListN(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pAudioCodecListT.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryReturn(NID_MEDIA, pAudioCodecListT->Contains(audioCodec) || audioCodec == CODEC_NONE, E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC,
+               "[E_UNSUPPORTED_CODEC]This AudioCodec(%d) is not supported in the device.\n", audioCodec);
+
+       std::unique_ptr<ArrayListT<CodecType>, _ListPtrUtil::Remover> pVideoCodecListT (GetSupportedVideoCodecListN(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pVideoCodecListT.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryReturn(NID_MEDIA, pVideoCodecListT->Contains(videoCodec), E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC,
+               "[E_UNSUPPORTED_CODEC]This VideoCodec(%d) is not supported in the device.\n", videoCodec);
+
+       std::unique_ptr<ArrayListT<MediaContainerType>, _ListPtrUtil::Remover> pContainerCodecListT (GetSupportedContainerListN(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pContainerCodecListT.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryReturn(NID_MEDIA, pContainerCodecListT->Contains(container), E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+               "[E_UNSUPPORTED_FORMAT]This Container(%d) is not supported in the device.\n", container);
+
+       supported = _RecorderUtil::CheckFormat(audioCodec, videoCodec, container);
+       SysTryCatch(NID_MEDIA, supported, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                          "[E_UNSUPPORTED_FORMAT] camcorder check foramt failed. audioCodec:0x%x, videoCodec:0x%x, container:0x%x",
+                          audioCodec, videoCodec,
+                          container);
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               r = SetFormatAttr(audioCodec, videoCodec, container);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set  failed. audioCodec:0x%x videoCodec:0x%x  container:0x%x",
+                               GetErrorMessage(r), audioCodec, videoCodec, videoCodec);
+       }
+       __audioCodec = audioCodec;
+       __videoCodec = videoCodec;
+       __container = container;
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               // Call the dependency function.
+               r = ReloadConfiguration(_RELOAD_QUALITY);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
+       }
+
+CATCH:
+       return r;
+}
+
+void
+_VideoRecorderImpl::GetFormat(CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const
+{
+       audioCodec = __audioCodec;
+       videoCodec = __videoCodec;
+       container = __container;
+}
+
+Tizen::Base::Collection::ArrayListT <CodecType>*
+_VideoRecorderImpl::GetSupportedAudioCodecListN(void) const
+{
+       result r = E_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+
+       std::unique_ptr<IList, _ListPtrUtil::Remover> pIntegerList (_RecorderCapability::GetListN(_VROP_AUDIO_ENCODER, itemType), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       std::unique_ptr<ArrayListT<CodecType>, _ListPtrUtil::Remover> pAudioCodecList (new (std::nothrow) ArrayListT<CodecType>(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pAudioCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pAudioCodecList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. %d item is not found.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's format is invalid.", i);
+
+               r = pAudioCodecList->Add((CodecType)pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "Pixel format : %d was added.", pInteger->ToInt());
+       }
+
+       return pAudioCodecList.release();
+
+CATCH:
+       return null;
+}
+
+Tizen::Base::Collection::ArrayListT<CodecType>*
+_VideoRecorderImpl::GetSupportedVideoCodecListN(void) const
+{
+       result r = E_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+
+       std::unique_ptr<IList, _ListPtrUtil::Remover> pIntegerList (_RecorderCapability::GetListN(_VROP_VIDEO_ENCODER, itemType), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       std::unique_ptr<ArrayListT<CodecType>, _ListPtrUtil::Remover> pVideoCodecList (new (std::nothrow) ArrayListT<CodecType>(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pVideoCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pVideoCodecList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. %d item is not found.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's format is invalid.", i);
+
+               r = pVideoCodecList->Add((CodecType)pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "Pixel format : %d was added.", pInteger->ToInt());
+       }
+
+       return pVideoCodecList.release();
+
+CATCH:
+       return null;
+}
+
+
+Tizen::Base::Collection::ArrayListT<MediaContainerType>*
+_VideoRecorderImpl::GetSupportedContainerListN(void) const
+{
+       result r = E_SUCCESS;
+       _ResultType itemType = _RESULT_INTEGER_LIST;
+
+       std::unique_ptr<IList, _ListPtrUtil::Remover> pIntegerList (_RecorderCapability::GetListN(_VROP_FILE_FORMAT, itemType), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pIntegerList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       std::unique_ptr<ArrayListT<MediaContainerType>, _ListPtrUtil::Remover> pContainerList (new (std::nothrow) ArrayListT<MediaContainerType>(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pContainerList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+       r = pContainerList->Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       for (int i = 0; i < pIntegerList->GetCount(); i++)
+       {
+               Object* pObj = null;
+               Integer* pInteger = null;
+               pObj = pIntegerList->GetAt(i);
+               SysTryCatch(NID_MEDIA, pObj != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Object instance is not available. %d item is not found.", i);
+
+               pInteger = dynamic_cast<Integer*>(pObj);
+               SysTryCatch(NID_MEDIA, pInteger != null, r = E_INVALID_FORMAT, E_INVALID_FORMAT, "[E_INVALID_FORMAT] %d item's format is invalid.", i);
+
+               r = pContainerList->Add((MediaContainerType)pInteger->ToInt());
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysLog(NID_MEDIA, "Pixel format : %d was added.", pInteger->ToInt());
+       }
+
+       return pContainerList.release();
+
+CATCH:
+       return null;
+}
+
+
+result
+_VideoRecorderImpl::SetMode(VideoRecorderMode mode)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+
+       SysLog(NID_MEDIA, "Enter. mode:%d", mode);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE
+                               || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.");
+
+       SysTryReturn(NID_MEDIA, mode >= VIDEORECORDER_MODE_VIDEO_WITH_AUDIO && mode <= VIDEORECORDER_MODE_VIDEO_ONLY
+                          , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(mode) is used. mode=%d.", mode);
+
+       r = SetMute(mode == VIDEORECORDER_MODE_VIDEO_ONLY ? true : false);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. mode:%d", GetErrorMessage(r), mode);
+
+       __mode = mode;
+
+       return r;
+}
+
+VideoRecorderMode
+_VideoRecorderImpl::GetMode(void) const
+{
+       return __mode;
+}
+
+result
+_VideoRecorderImpl::SetQuality(RecordingQuality quality)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       CodecType audioCodec = CODEC_NONE;
+       CodecType videoCodec = CODEC_NONE;
+       MediaContainerType container = MEDIA_CONTAINER_NONE;
+       SysLog(NID_MEDIA, "Enter. quality:%d", quality);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, r, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.", state);
+
+       SysTryReturn(NID_MEDIA, (quality >= RECORDING_QUALITY_LOW && quality <= RECORDING_QUALITY_HIGH)
+                          , E_INVALID_ARG, r, "[E_INVALID_ARG] Invalid argument(quality) is used. The quality=%d.", quality);
+
+       GetFormat(audioCodec, videoCodec, container);
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               r = SetQualityAttr(quality, audioCodec, videoCodec);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] set quality failed. quality:%d", GetErrorMessage(r), quality);
+       }
+       __quality = quality;
+
+       return r;
+CATCH:
+       return r;
+}
+
+RecordingQuality
+_VideoRecorderImpl::GetQuality(void) const
+{
+       return __quality;
+}
+
+result
+_VideoRecorderImpl::SetRecordingResolution(const Tizen::Graphics::Dimension& resolution)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter. resolution(%d,%d)", resolution.width, resolution.height);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE
+                               || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.", state);
+
+       SysTryReturn(NID_MEDIA, resolution.width >= 0 && resolution.height >= 0
+                          , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] resolution is out of range. The resolution(%d,%d) must be greater than (0,0).",
+                               resolution.width,
+                               resolution.height);
+
+       std::unique_ptr<IList, _ListPtrUtil::Remover> pList (GetSupportedRecordingResolutionListN(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pList.get() != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the supported list was failed.\n");
+       SysTryReturn(NID_MEDIA, pList->Contains(resolution), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE]. resolution is out of range. This resolution(%d,%d) is not supported in the device.\n", resolution.width, resolution.height);
+
+       if ( __pVideoSourceAdapter->HasRecordingResolutionRestriction())
+       {
+               Dimension sourceResolution = __pVideoSourceAdapter->GetSourceResolution();
+               SysTryReturn(NID_MEDIA, sourceResolution == resolution, E_SYSTEM, E_SYSTEM,
+                       "[E_SYSTEM] A system error has been occurred.  The source resolution(%d,%d) should be same as the recording resolution(%d,%d).", sourceResolution.width, sourceResolution.height, resolution.width, resolution.height);
+       }
+       else
+       {
+               SysLog(NID_MEDIA, "There is no recording attribute... ");
+       }
+
+       __recordingResolution = resolution;
+
+       return r;
+}
+
+Tizen::Graphics::Dimension
+_VideoRecorderImpl::GetRecordingResolution(void) const
+{
+       return __recordingResolution;
+}
+
+Tizen::Base::Collection::IList*
+_VideoRecorderImpl::GetSupportedRecordingResolutionListN(void) const
+{
+       SysTryReturn(NID_MEDIA, __pVideoSourceAdapter != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
+
+       return __pVideoSourceAdapter->GetSupportedRecordingResolutionListN();
+}
+
+int
+_VideoRecorderImpl::GetSupportedMaxFrameRate(const Tizen::Graphics::Dimension& dim) const
+{
+       result r = E_SUCCESS;
+       int maxFrameRate = 0;
+
+       SysTryReturn(NID_MEDIA, __pVideoSourceAdapter != null, 0, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
+
+       std::unique_ptr<IListT<int>, _ListPtrUtil::Remover> pListT (__pVideoSourceAdapter->GetSupportedFrameRateListN(dim), _ListPtrUtil::remover);
+       SysTryCatch(NID_MEDIA, pListT.get() != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+       SysTryCatch(NID_MEDIA, pListT->GetCount() > 0, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+
+       r = pListT->GetAt(pListT->GetCount()-1, maxFrameRate);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s]  propogated", GetErrorMessage(r));
+
+       return maxFrameRate;
+
+CATCH:
+       return 0;
+}
+
+result
+_VideoRecorderImpl::SetMute(bool mute)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter. mute:%d", mute);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED || state == RECORDER_STATE_ENDOF_FILE || state == RECORDER_STATE_CLOSED
+                               || state == RECORDER_STATE_STOPPED || state == RECORDER_STATE_PAUSED || state == RECORDER_STATE_RECORDING
+                          , E_INVALID_STATE, r, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.", state);
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               r = SetMuteAttr(mute);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. mute:%d", GetErrorMessage(r), mute);
+       }
+       __mute = mute;
+       return r;
+}
+
+bool
+_VideoRecorderImpl::IsMuted(void) const
+{
+       return __mute;
+}
+
+result
+_VideoRecorderImpl::SetRecordingRotation(RecordingRotation rotation)
+{
+       result r = E_SUCCESS;
+       RecorderState state = RECORDER_STATE_ERROR;
+       SysLog(NID_MEDIA, "Enter. rotation:%d", rotation);
+
+       state = GetState();
+       SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED
+                               || state == RECORDER_STATE_OPENED  || state == RECORDER_STATE_CLOSED
+                          , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.", state);
+
+       SysTryReturn(NID_MEDIA, (rotation >= RECORDING_ROTATION_NONE&& rotation <= RECORDING_ROTATION_270)
+                          , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(rotation) is used. The rotation=%d.", rotation);
+
+       if (__handle != MM_INVALID_HANDLE)
+       {
+               __pCoordinator->SetRecordingOrientation(rotation);
+       }
+       __rotation = rotation;
+
+       return r;
+}
+
+RecordingRotation
+_VideoRecorderImpl::GetRecordingRotation(void) const
+{
+       return __rotation;
+}
+
+result
+_VideoRecorderImpl::SetFormatAttr(CodecType audioCodec, CodecType videoCodec, MediaContainerType container)
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+
+       recorder_audio_codec_e attrAudioCodec = ::RECORDER_AUDIO_CODEC_AAC;
+       recorder_video_codec_e attrVideoCodec = ::RECORDER_VIDEO_CODEC_MPEG4;
+       recorder_file_format_e attrFormat = ::RECORDER_FILE_FORMAT_MP4;
+
+       r = _RecorderUtil::GetMmAudioCodec(audioCodec, attrAudioCodec);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. audio codec:0x%x", GetErrorMessage(r), audioCodec);
+
+       err = recorder_set_audio_encoder(__handle, attrAudioCodec);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Audio codec set  failed. codec:0x%x", GetErrorMessage(r), audioCodec);
+
+       r = _RecorderUtil::GetMmVideoCodec(videoCodec, attrVideoCodec);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. video codec:0x%x", GetErrorMessage(r), videoCodec);
+
+       err = recorder_set_video_encoder(__handle, attrVideoCodec);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Video codec set  failed. codec:0x%x", GetErrorMessage(r), videoCodec);
+
+       r = _RecorderUtil::GetMmFileFormat(container, attrFormat);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. container:0x%x", GetErrorMessage(r), container);
+
+       err = recorder_set_file_format(__handle, attrFormat);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set  failed. container:0x%x", GetErrorMessage(r), container);
+
+       return r;
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::SetQualityAttr(RecordingQuality quality,   CodecType audioCodec, CodecType videoCodec)
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+       int attrVideoBitrate = 0;
+       if (audioCodec != CODEC_NONE)
+       {
+               int attrAudioSampleate = 0;
+               int attrAudioChannel = 0;
+               int attrAudioBitrate = 0;
+
+               r = _RecorderUtil::GetMmAudioQuality(audioCodec, quality, attrAudioSampleate, attrAudioChannel, attrAudioBitrate);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. audioCodec:%d, quality:%d", GetErrorMessage(r), audioCodec, quality);
+
+               err = recorder_attr_set_audio_samplerate(__handle, attrAudioSampleate);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Sampling-rate set  failed. attr:%d", GetErrorMessage(r), attrAudioSampleate);
+
+               err = recorder_attr_set_audio_channel(__handle, attrAudioChannel);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Channel set  failed. attr:%d", GetErrorMessage(r), attrAudioChannel);
+
+               err = recorder_attr_set_audio_encoder_bitrate(__handle, attrAudioBitrate);
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Bitrate set  failed. attr:%d", GetErrorMessage(r), attrAudioBitrate);
+       }
+       r = _RecorderUtil::GetMmVideoQuality(_CameraUtil::ConvertResolutionType(__recordingResolution), quality, attrVideoBitrate);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. videoCodec:%d, quality:%d", GetErrorMessage(r), videoCodec, quality);
+
+       err = recorder_attr_set_video_encoder_bitrate(__handle, attrVideoBitrate);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Bitrate set  failed. attr:%d", GetErrorMessage(r), attrVideoBitrate);
+
+       return r;
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::SetMuteAttr(bool mute)
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+
+       err = recorder_attr_set_mute(__handle, mute);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set mute failed", GetErrorMessage(r));
+       return r;
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::SetMaxRecordingTimeAttr(long msTime)
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+       int secTime = MEDIA_INVALID_VALUE;
+       // msec max time is not possible to set
+       secTime = msTime > 1000 ? ((msTime + 500) / 1000) : 1;
+       err = recorder_attr_set_time_limit(__handle, secTime);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder set attribute failed. msTime:%ls", GetErrorMessage(r), msTime);
+       return r;
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::SetCallback(void)
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+
+       err = recorder_set_state_changed_cb(__handle, StateChangedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set message callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_recording_limit_reached_cb(__handle, LimitReachedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_recording_status_cb(__handle, RecordingStatusCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set recording status callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_error_cb(__handle, ErrorCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       err = recorder_set_interrupted_cb(__handle, InterruptedCb, this);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set limit reached callback failed.", GetErrorMessage(r));
+
+       return r;
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::OnCameraCoordinatorModeChangePrepared(_CameraMode mode)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Mode:%d", mode);
+       __handle = __pCoordinator->GetRecorderHandle(); // update to the new handle. All configuration shuld be updated with this handle after mode changing.
+
+       if ( mode == _CAMERA_MODE_VIDEO )
+       {
+               r = __pCoordinator->SetCameraSourceFormat(__mmSourceFormat);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = ReloadConfiguration(_RELOAD_FORMAT | _RELOAD_QUALITY);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VideoRecorderImpl::OnCameraCoordinatorModeChanged(_CameraMode mode)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Mode:%d", mode);
+
+       if ( mode == _CAMERA_MODE_VIDEO )
+       {
+               r = ReloadConfiguration(_RELOAD_MAX_TIME | _RELOAD_FILE_PATH | _RELOAD_CALLBACK | _RELOAD_MUTE | _RELOAD_ROTATION);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+void
+_VideoRecorderImpl::StateChangedCb(recorder_state_e previous, recorder_state_e current, bool byPolicy, void* pUserData)
+{
+       result r = E_SUCCESS;
+       _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>( pUserData);
+       int tableTotalCount = 0;
+       int i = 0;
+       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+       SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
+
+       tableTotalCount = sizeof(_VIDEO_CALLBACK_EVENT) / sizeof(_VIDEO_CALLBACK_EVENT[0]);
+
+       for (i = 0; i < tableTotalCount; i++)
+       {
+               if (previous == _VIDEO_CALLBACK_EVENT[i].prevState && current == _VIDEO_CALLBACK_EVENT[i].postState && pImpl->GetStateChangeReason() == _VIDEO_CALLBACK_EVENT[i].reason)                //for cancel
+               {
+                       r = pImpl->GetEvent()->SendEvent(_VIDEO_CALLBACK_EVENT[i].event, _VIDEO_CALLBACK_EVENT[i].error, E_SUCCESS);
+                       SysLog(NID_MEDIA, "VIDEO_CALLBACK_EVENT(%d) is sent by StateChangedCb", _VIDEO_CALLBACK_EVENT[i].event);
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
+                       break;
+               }
+       }
+}
+
+void
+_VideoRecorderImpl::RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData)
+{
+       _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+
+       SysLog(NID_MEDIA, "FileSize:%llu,elapsedTime:%llu",fileSize,elapsedTime);
+
+       pImpl->SetRecordingTime((long)elapsedTime);
+       pImpl->SetRecordingSize((long)fileSize);
+}
+
+void
+_VideoRecorderImpl::AudioStreamCb(void* pStream, int size, audio_sample_type_e format, int channel, unsigned int timeStamp, void *pUserData)
+{
+       _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. Impl is null.");
+       SysTryReturn(NID_MEDIA, pStream != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] void instance is not available. pStream is null.");
+
+//     SysLog(NID_MEDIA, "Size:%d, format:%d, channel:%d, timeStamp:%u", size, format, channel, timeStamp);
+}
+
+void
+_VideoRecorderImpl::LimitReachedCb(recorder_recording_limit_type_e type, void *pUserData)
+{
+       result r = E_SUCCESS;
+       _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+
+       SysLog(NID_MEDIA, "Type:%d", type);
+
+       switch (type)
+       {
+       case ::RECORDER_RECORDING_LIMIT_TIME:
+               r = pImpl->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_TIME_REACHED);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+
+       case ::RECORDER_RECORDING_LIMIT_SIZE:
+               r = pImpl->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_SIZE_REACHED);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+
+       case ::RECORDER_RECORDING_LIMIT_FREE_SPACE:
+               r = pImpl->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_OUT_OF_STORAGE);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               break;
+
+       default:
+               break;
+       }
+
+CATCH:
+       return;
+}
+
+void
+_VideoRecorderImpl::ErrorCb(recorder_error_e error, recorder_state_e state, void *pUserData)
+{
+       result r = E_SUCCESS;
+       _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+       SysLog(NID_MEDIA, "Error:%d, state:%d", error, state);
+
+       _CameraCoordinator* __pCoordinator = null;
+       __pCoordinator = _CameraCoordinator::AddInstance(pImpl->GetDeviceType());
+       SysTryCatch(NID_MEDIA, __pCoordinator != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraCoordinator instance is not available. Coordinator is not found");
+
+       r = __pCoordinator->ChangeMode(_CAMERA_MODE_IMAGE, true);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _CameraCoordinator::Release(pImpl->GetDeviceType());
+
+       r = pImpl->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_DEVICE_FAILED, E_SUCCESS);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return;
+CATCH:
+       return;
+}
+
+void
+_VideoRecorderImpl::InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData)
+{
+       _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
+       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+
+       SysLog(NID_MEDIA, "Policy:%d, previous:%d, current:%d", policy, previous, current);
+}
+
+_VideoRecorderEvent*
+_VideoRecorderImpl::GetEvent(void) const
+{
+       return __pVideoRecorderEvent;
+}
+
+void
+_VideoRecorderImpl::SetState(RecorderState state)
+{
+       __state = state;
+}
+
+void
+_VideoRecorderImpl::SetRecordingTime(long recTime)
+{
+       __recTime = recTime;
+}
+
+void
+_VideoRecorderImpl::SetRecordingSize(long recSize)
+{
+       __recSize = recSize;
+}
+
+_RecorderDeviceType
+_VideoRecorderImpl::GetDeviceType(void) const
+{
+       return __deviceType;
+}
+
+result
+_VideoRecorderImpl::ConvertResult(int err) const
+{
+       result r = E_SYSTEM;
+       if (err != ::RECORDER_ERROR_NONE)
+       {
+               SysLog(NID_MEDIA, "MM Err:0x%x", err);
+       }
+
+       // Global error
+       if (err == ::RECORDER_ERROR_NONE)
+       {
+               r = E_SUCCESS;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_PARAMETER)
+       {
+               r = E_INVALID_ARG;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_STATE)
+       {
+               r = E_INVALID_STATE;
+       }
+       else if (err == ::RECORDER_ERROR_OUT_OF_MEMORY)
+       {
+               r = E_OUT_OF_MEMORY;
+       }
+       else if (err == ::RECORDER_ERROR_DEVICE)
+       {
+               r = E_DEVICE_FAILED;
+       }
+       else if (err == ::RECORDER_ERROR_INVALID_OPERATION
+               || err == ::RECORDER_ERROR_SECURITY_RESTRICTED)
+       {
+               r = E_SYSTEM;
+       }
+       else if (err == ::RECORDER_ERROR_SOUND_POLICY)
+       {
+               r = E_DEVICE_BUSY;
+       }
+       else
+       {
+               r = E_UNKNOWN;
+       }
+
+       return r;
+}
+
+void
+_VideoRecorderImpl::GetCodecString(const CodecType videoCodec, Tizen::Base::String& codec) const
+{
+       int i = 0;
+
+       while (_CODEC_VAL_TABLE[i].pCodecName != null)
+       {
+               if (videoCodec == _CODEC_VAL_TABLE[i].videoCodec)
+               {
+                       codec.Clear();
+                       codec.Append(_CODEC_VAL_TABLE[i].pCodecName);
+                       break;
+               }
+               i++;
+       }
+}
+
+result
+_VideoRecorderImpl::ChangeStateTo(recorder_state_e mmDestState, _RecorderStateChangeReason reason)
+{
+       result r = E_SUCCESS;
+       int tableTotalCount = 0;
+       int i = 0;
+       int err = MM_SUCCESS;
+       recorder_state_e preState = ::RECORDER_STATE_NONE;
+       recorder_state_e postState = ::RECORDER_STATE_NONE;
+
+       SysLog(NID_MEDIA, "Enter. mmDestState:%d", mmDestState);
+       SysTryReturn(NID_MEDIA, __isConstructed == true, E_INVALID_STATE, E_INVALID_STATE,
+                               "[E_INVALID_STATE] VideoRecorder is in an invalid state. VideoRecorder is not constructed.");
+
+       preState = GetMmState();
+       tableTotalCount = sizeof(_VIDEO_COMMAND_STATE) / sizeof(_VIDEO_COMMAND_STATE[0]);
+       SysLog(NID_MEDIA, " preState:%d, mmDestState:%d, tableTotalCount:%d", preState, mmDestState, tableTotalCount);
+
+       for (i = 0; i < tableTotalCount; i++)
+       {
+               if (preState == _VIDEO_COMMAND_STATE[i].preState && mmDestState == _VIDEO_COMMAND_STATE[i].postState && reason ==
+                       _VIDEO_COMMAND_STATE[i].reason)
+               {
+                       if (_VIDEO_COMMAND_STATE[i].pFunc != null)
+                       {
+                               SysLog(NID_MEDIA, "Exist the matching state field. current state:%d, mmState:%d, reason:%d",
+                                                       preState, mmDestState, reason);
+                               err = _VIDEO_COMMAND_STATE[i].pFunc(__handle);
+                               r = ConvertResult(err);
+                               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
+
+                               // Check whether the retuned states are destinationed states.
+                               postState = GetMmState();
+                               SysTryCatch(NID_MEDIA, mmDestState == postState, r = E_INVALID_STATE, E_INVALID_STATE,
+                                                  "[E_INVALID_STATE] VideoRecorder state of CAPI is in an invalid state. result mmState:%d, is different from the desired state:%", postState, mmDestState);
+                               SysLog(NID_MEDIA, "[E_SUCCESS] Found. result mmState:%d, param mmDestState:%d", postState,
+                                                       mmDestState);
+
+                               __stateChangeReason = reason;           //for distinguish between stop and cancel
+                       }
+
+                       if (_VIDEO_COMMAND_STATE[i].state >= RECORDER_STATE_INITIALIZED && _VIDEO_COMMAND_STATE[i].state <= RECORDER_STATE_ERROR)
+                       {
+                               SysLog(NID_MEDIA, "State set to %d", _VIDEO_COMMAND_STATE[i].state);
+                               SetState(_VIDEO_COMMAND_STATE[i].state);
+                       }
+                       break;
+               }
+       }
+       SysTryCatch(NID_MEDIA, i != tableTotalCount, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Not found. ");
+       return r;
+
+CATCH:
+       SysLog(NID_MEDIA, "[%s] Real mmState:%d, param mmState:%d", GetErrorMessage(r), preState, mmDestState);
+       return r;
+}
+
+_RecorderStateChangeReason
+_VideoRecorderImpl::GetStateChangeReason(void) const
+{
+       return __stateChangeReason;
+}
+
+recorder_state_e
+_VideoRecorderImpl::GetMmState(void) const
+{
+       result r = E_SUCCESS;
+       int err = ::RECORDER_ERROR_NONE;
+       recorder_state_e mmState = ::RECORDER_STATE_NONE;
+
+       err = recorder_get_state(__handle, &mmState);
+       r = ConvertResult(err);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return mmState;
+
+CATCH:
+       return ::RECORDER_STATE_NONE;
+}
+
+void
+_VideoRecorderImpl::GetMediaType(const Base::String& codec, CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const
+{
+       int i = 0;
+       std::unique_ptr<char[]> pCodecChars (Tizen::Base::_StringConverter::CopyToCharArrayN(codec));
+
+       while (_CODEC_VAL_TABLE[i].pCodecName != null)
+       {
+               if (strcmp(_CODEC_VAL_TABLE[i].pCodecName, pCodecChars.get()) == 0)
+               {
+                       videoCodec = _CODEC_VAL_TABLE[i].videoCodec;
+                       audioCodec = _CODEC_VAL_TABLE[i].audioCodec;
+                       container = _CODEC_VAL_TABLE[i].container;
+                       break;
+               }
+               i++;
+       }
+}
+
+void
+_VideoRecorderImpl::GetMediaType(VideoRecordingFormat format, CodecType& audioCodec, CodecType& videoCodec,
+                                                                MediaContainerType& container) const
+{
+       switch (format)
+       {
+       case VIDEORECORDING_FORMAT_3GP:
+               audioCodec = CODEC_AMR_NB;
+               videoCodec = CODEC_MPEG4;
+               container = MEDIA_CONTAINER_3GP;
+               break;
+
+       case VIDEORECORDING_FORMAT_DEFAULT:
+       case VIDEORECORDING_FORMAT_MP4:
+               audioCodec = CODEC_AAC;
+               videoCodec = CODEC_MPEG4;
+               container = MEDIA_CONTAINER_MP4;
+               break;
+
+       default:
+               audioCodec = CODEC_NONE;
+               videoCodec = CODEC_NONE;
+               container = MEDIA_CONTAINER_NONE;
+               break;
+       }
+}
+
+result
+_VideoRecorderImpl::ReloadConfiguration(int reload)
+{
+       result r = E_SUCCESS;
+       int err = MM_SUCCESS;
+       SysLog(NID_MEDIA, "Enter. reload:0x%x", reload);
+
+       if (reload & _RELOAD_FORMAT)
+       {
+               r = SetFormatAttr(__audioCodec, __videoCodec, __container);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set  failed. audioCodec:0x%x videoCodec:0x%x  container:0x%x",
+                               GetErrorMessage(r), __audioCodec, __videoCodec, __videoCodec);
+       }
+       if (reload & _RELOAD_QUALITY)
+       {
+               r = SetQualityAttr(__quality, __audioCodec, __videoCodec);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] set quality failed. quality:%d", GetErrorMessage(r), __quality);
+       }
+       if (reload & _RELOAD_MAX_TIME)
+       {
+               r = SetMaxRecordingTimeAttr(__maxTime);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder set attribute failed. maxTime:%ls", GetErrorMessage(r), __maxTime);
+       }
+       if (reload & _RELOAD_FILE_PATH)
+       {
+               result r = E_SUCCESS;
+               int err = MM_SUCCESS;
+               std::unique_ptr<char[]> pFileName (Tizen::Base::_StringConverter::CopyToCharArrayN(__filePath));
+               SysTryCatch(NID_MEDIA, pFileName.get() != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(__filePath) is used. File name is null.");
+               SysLog(NID_MEDIA, "File Path : %s\n", pFileName.get());
+
+               err = recorder_set_filename(__handle, pFileName.get());
+               r = ConvertResult(err);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_INIT)
+       {
+               __recTime = 0;
+               __recSize = 0;
+       }
+       if (reload & _RELOAD_CALLBACK)
+       {
+               r = SetCallback();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set callback failed.", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_MUTE)
+       {
+               r = SetMuteAttr(__mute);
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set mute failed", GetErrorMessage(r));
+       }
+       if (reload & _RELOAD_ROTATION)
+       {
+               __pCoordinator->SetRecordingOrientation(__rotation);
+       }
+
+       return r;
+
+CATCH:
+       if (__handle)
+       {
+               err = recorder_unset_state_changed_cb(__handle);
+               err = recorder_unset_recording_limit_reached_cb(__handle);
+               err = recorder_unset_error_cb(__handle);
+               err = recorder_unset_interrupted_cb(__handle);
+               __handle = MM_INVALID_HANDLE;
+       }
+
+       return r;
+}
+
+result
+_VideoRecorderImpl::LoadDefaultConfiguration(int reload)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_MEDIA, "Enter.");
+
+       // Preview resolution
+       if (reload & _RELOAD_RECORD_RESOLUTION)
+       {
+               __recordingResolution = __pVideoSourceAdapter->GetSourceResolution();
+       }
+
+       return r;
+}
+
+bool
+_VideoRecorderImpl::IsAlive(void)
+{
+       return __isUsed;
+}
+
+_VideoRecorderImpl*
+_VideoRecorderImpl::GetInstance(VideoRecorder *pVideoRecorder)
+{
+       if ( pVideoRecorder != null )
+       {
+               return pVideoRecorder->__pImpl;
+       }
+       return null;
+}
+
+const _VideoRecorderImpl*
+_VideoRecorderImpl::GetInstance(const VideoRecorder *pVideoRecorder)
+{
+       if ( pVideoRecorder != null )
+       {
+               return pVideoRecorder->__pImpl;
+       }
+       return null;
+}
+
+}}// Tizen::Media
+
diff --git a/src/FMedia_VideoRecorderImpl.h b/src/FMedia_VideoRecorderImpl.h
new file mode 100755 (executable)
index 0000000..0df05ba
--- /dev/null
@@ -0,0 +1,851 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_VideoRecorderImpl.h
+ * @brief                      This is the header file for the %_VideoRecorderImpl class.
+ */
+#ifndef _FMEDIA_INTERNAL_VIDEORECORDER_IMPL_H_
+#define _FMEDIA_INTERNAL_VIDEORECORDER_IMPL_H_
+
+#include <recorder.h>
+#include <FBaseColIList.h>
+#include <FGrpDimension.h>
+#include <FMediaTypes.h>
+#include <FMediaVideoRecorderTypes.h>
+#include "FMedia_ICameraCoordinatorListener.h"
+#include "FMedia_CameraTypes.h"
+#include "FMedia_RecorderTypes.h"
+#include "FMedia_RecorderTypes.h"
+
+namespace Tizen { namespace Media
+{
+class Camera;
+class VideoRecorder;
+class IVideoRecorderEventListener;
+
+class _CameraCoordinator;
+class _VideoRecorderEvent;
+class _VideoSourceAdapter;
+
+/**
+ * @class      _VideoRecorderImpl
+ * @brief      This class records a video.
+ */
+class _VideoRecorderImpl
+       : public Tizen::Base::Object
+       , public _ICameraCoordinatorListener
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks     The object is not fully constructed after this constructor is called. For full construction, 
+        * the Construct() method must be called right after calling this constructor.
+        * @see  Construct()
+        */
+       _VideoRecorderImpl(void);
+
+       /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread in
+        * which the Construct() method is called. This polymorphic destructor should be overridden if required.
+        * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @see  Construct()
+        */
+       virtual ~_VideoRecorderImpl(void);
+
+       /**
+       * Initializes this instance of _VideoRecorderImpl with an associated listener and an input source.
+       *
+       * @return               An error code
+       * @param[in]    listener                        An event listener object
+       * @param[in]    camera                          A Camera object for the input source
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_DEVICE_BUSY           The device cannot be approached because of other operations.
+       */
+       result Construct(IVideoRecorderEventListener& listener, const Camera& camera);
+
+       /**
+       * Creates a video file for a recording.
+       *
+       * @return               An error code
+       * @param[in]    destMediaPath                           The destination for the file be written @n
+       *                                                                               The available paths start with prefixes retrieved from the functions such as: @n
+       *                                                                               Tizen::App::App::GetInstance()->GetAppRootPath() @n
+       *                                                                               Tizen::System::Environment::GetMediaPath() @n
+       *                                                                               Tizen::System::Environment::GetExternalStoragePath()
+       * @param[in]    overwrite                                       Set to @c true to overwrite the file, @n
+       *                                                                                       else @c false
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_RESOURCE_UNAVAILABLE          The required file path is unavailable.
+       * @exception    E_FILE_ALREADY_EXIST            The specified file already exists.
+       * @exception    E_STORAGE_FULL                          The storage is full.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @see            Close()
+       */
+       result CreateVideoFile(const Tizen::Base::String& destMediaPath, bool overwrite);
+
+       /**
+       * Closes the video file. @n
+       * This is a synchronous method.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @see                  CreateVideoFile()
+       */
+       result Close(void);
+
+       /**
+       * Starts the recording. @n
+       * Resumes the recording if Pause() has been called.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_DEVICE_BUSY                   The device cannot be approached because of other operations.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks        This method must be called after the input media source is started (for example, Camera::StartPreview()).
+       * @see                  Stop(), Pause()
+       */
+       result Record(void);
+
+       /**
+       * Stops the recording.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @see                  Record(), Pause()
+       */
+       result Stop(void);
+
+       /**
+       * Pauses the recording. @n
+       * To resume the recording after this method is called, Record() must be called.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @see                  Stop(), Record()
+       */
+       result Pause(void);
+
+       /**
+       * Cancels the recording operation without saving the data.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              When this method is called, the state is changed to ::RECORDER_STATE_STOPPING. @n
+       *                               After IVideoRecorderEventListener::OnVideoRecorderCanceled is called, the state is changed to
+       *                               ::RECORDER_STATE_STOPPED.
+       * @see                  Record(), Stop()
+       */
+       result Cancel(void);
+
+       /**
+       * Gets the state of a recorder.
+       *
+       * @see                  CreateVideoFile(), Close(), Record(), Stop(), Pause(), RecorderState()
+       */
+       RecorderState GetState(void) const;
+
+       /**
+       * Gets the current recording time.
+       *
+       * @return               The current recording time in milliseconds, @n
+       *                               else @c -1 if the recording has not started as yet
+       */
+       long GetRecordingTime(void) const;
+
+       /**
+       * Gets the current recording size.
+       *
+       * @return               A @c long value indicating the current recording size in bytes, @n
+       *                               else @c -1 if the recording has not started as yet
+       */
+       long GetRecordingSize(void) const;
+
+       /**
+       * Sets the time limit for the recording in milliseconds.
+       *
+       * @return               An error code
+       * @param[in]    msTime                          The maximum recording time in milliseconds @n
+       *                                                                       The time must be greater than @c 0.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE          The specified time is out of range.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @remarks              The default time is @c 60 seconds.
+       * @see                  GetMaxRecordingTime()
+       */
+       result SetMaxRecordingTime(long msTime);
+
+       /**
+       * Gets the time limit of the recording in milliseconds.
+       *
+       * @return               A @c long value indicating the maximum recording time in milliseconds @n
+       *                               else @c -1 if the recording has not started as yet
+       * @see                  SetMaxRecordingTime()
+       */
+       long GetMaxRecordingTime(void) const;
+
+       /**
+       * Sets the codec for the recorder. @n
+       * Initially, the default codec from the internal configuration is set.
+       *
+       * @return               An error code
+       * @param[in]    codec                                   The codec name @n
+       *                                                                               It should be one of the strings listed by GetSupportedCodecListN(). @n
+       *                                                                               GetSupportedCodecListN() returns the list of strings in the following formats: @n
+       *                                                                               - "VIDEO_CODEC_H263" @n
+       *                                                                               - "VIDEO_CODEC_MPEG4SP" @n
+       *                                                                               The returned strings are different depending on each device. @n
+       *                                                                               The following string is always operated upon. This value is different
+       *                                                                               for each device. @n
+       *                                                                               "VIDEO_CODEC_DEFAULT": the default codec
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @see                  GetCodec(), GetSupportedCodecListN()
+       */
+       result SetCodec(const Tizen::Base::String& codec);
+
+       /**
+       * Gets the codec for the recorder.
+       *
+       * @return               The current codec
+       * @see                  SetCodec(), GetSupportedCodecListN()
+       */
+       Tizen::Base::String GetCodec(void) const;
+
+       /**
+       * Gets the list of supported video recorder codecs. @n
+       * Each item in the list is a Tizen::Base::String value.
+       *
+       * @return          The list of strings that represents the supported video recorder codecs, @n
+       *                               else @c null if no codec is supported or if an exception occurs
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                          The return value must be released by the caller. @n
+       *                          All items in the list must be released by the caller.
+       * @see                  SetCodec(), GetCodec()
+       */
+       Tizen::Base::Collection::IList* GetSupportedCodecListN(void) const;
+
+       /**
+       * Gets the list of supported audio codecs. @n
+       * Each item in the list has a ::CodecType value.
+       *
+       * @return          A list of supported audio codecs, @n
+       *                               else @c null if no codec is supported or if an exception occurs
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                          The return value must be released by the caller.
+       * @see            SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container ),
+       *                               GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
+       */
+       Tizen::Base::Collection::ArrayListT <CodecType>* GetSupportedAudioCodecListN(void) const;
+
+       /**
+       * Gets the list of supported video codecs. @n
+       * Each item in the list has a ::CodecType value.
+       *
+       * @return          A list of supported video codecs, @n
+       *                               else @c null if no codec is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                          The return value must be released by the caller.
+       * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container ), GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
+       */
+       Tizen::Base::Collection::ArrayListT <CodecType>* GetSupportedVideoCodecListN(void) const;
+
+       /**
+       * Gets the list of supported containers. @n
+       * Each item in the list has a ::MediaContainerType value.
+       *
+       * @return          A list of supported containers, @n
+       *                               else @c null if no container is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                          The return value must be released by the caller.
+       * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container ),
+       *                               GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
+       */
+       Tizen::Base::Collection::ArrayListT <MediaContainerType>* GetSupportedContainerListN(void) const;
+
+       /**
+       * Sets the video format of the recorder. @n
+       * Initially, the default format from internal configuration is set.
+       *
+       * @return               An error code
+       * @param[in]    format                                  The video format @n
+       *                                                                               ::VIDEORECORDING_FORMAT_DEFAULT sets the system's default recording format.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @see                  GetFormat()
+       */
+       result SetFormat(VideoRecordingFormat format);
+
+       /**
+       * Gets the current format that has been set for the recorder.
+       *
+       * @return               The current video format, @n
+       *                          else the default format if SetFormat() is not called before this method
+       * @see                  SetFormat()
+       */
+       VideoRecordingFormat GetFormat(void) const;
+
+       /**
+       * Sets the mode of the recorder.
+       *
+       * @return               An error code
+       * @param[in]    mode                            The mode for the recording @n
+       *                                                                       The default mode is ::VIDEORECORDER_MODE_VIDEO_WITH_AUDIO.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c mode is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @see                  GetMode()
+       */
+       result SetMode(VideoRecorderMode mode);
+
+       /**
+       * Gets the mode of the recorder.
+       *
+       * @return               The current mode
+       * @see                  SetMode()
+       */
+       VideoRecorderMode GetMode(void) const;
+
+       /**
+       * Sets the audio and video codecs, and the container of the recorder. @n
+       * Initially, the default codec and container format are set with the internal configuration.
+       *
+       * @return               An error code
+       * @param[in]    audioCodec                              The audio codec to set @n
+       *                                                                               ::CODEC_NONE makes the audio stream empty.
+       * @param[in]    videoCodec                              The video codec to set @n
+       *                                                                               ::CODEC_NONE cannot be set.
+       * @param[in]    container                               The media container to set
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_UNSUPPORTED_CODEC             The specified codec is not supported.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified container format is not supported.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              If the audio codec is ::CODEC_NONE, the audio will be ignored, and only the video stream will be recorded. @n
+       *                               If the specified container does not support the specified codec, E_UNSUPPORTED_FORMAT may be thrown.
+       * @see                  GetFormat( CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container ) const
+       */
+       result SetFormat(CodecType audioCodec, CodecType videoCodec, MediaContainerType container);
+
+       /**
+       * Gets the audio and video codecs, and the container of the recorder.
+       *
+       * @return               An error code
+       * @param[out]   audioCodec                      The retrieved audio codec
+       * @param[out]   videoCodec                      The retrieved video codec
+       * @param[out]   container                       The retrieved container
+       * @remarks              The default codecs and container are retrieved, if SetFormat( CodecType audioCodec, CodecType
+       *                               videoCodec, MediaContainerType container) is not called before calling this method.
+       * @see                  SetFormat( CodecType audioCodec, CodecType videoCodec, MediaContainerType container )
+       */
+       void GetFormat(CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const;
+
+       /**
+       * Sets the quality of the recorder.
+       *
+       * @return               An error code
+       * @param[in]    quality                         The quality of the recorder @n
+       *                                                                       The default quality is ::RECORDING_QUALITY_MEDIUM.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c quality is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @see                  GetQuality()
+       */
+       result SetQuality(RecordingQuality quality);
+
+       /**
+       * Gets the quality of the recorder.
+       *
+       * @return               The current quality
+       * @see                  SetQuality()
+       */
+       RecordingQuality GetQuality(void) const;
+
+       /**
+       * Sets the recording resolution of the recorder. @n
+       * Initially, the default resolution from the internal configuration is set.
+       *
+       * @return               An error code
+       * @param[in]    resolution                      The recording resolution @n
+       *                                                                       It should be one of the listed strings extracted from
+       *                                                                       GetSupportedRecordingResolutionListN().
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_RANGE          The specified resolution is out of range.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       *                               of this recording resolution.
+       * @see                  GetRecordingResolution(), GetSupportedRecordingResolutionListN()
+       */
+       result SetRecordingResolution(const Tizen::Graphics::Dimension& resolution);
+
+       /**
+       * Gets the recording resolution.
+       *
+       * @return               The recording resolution
+       * @see                  SetRecordingResolution(), GetSupportedRecordingResolutionListN()
+       */
+       Tizen::Graphics::Dimension GetRecordingResolution(void) const;
+
+       /**
+       * Gets a list of the supported video recorder resolutions. @n
+       * Each list item is a Tizen::Graphics::Dimension value.
+       *
+       * @return               A list of strings representing the supported video recorder resolutions, @n
+       *                               else an empty list if no recording resolution is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be released by the calling method. @n
+       *                               All items in the list must be released by the calling method. @n
+       *                               This method works after the input media source is initialized (for example, Camera::PowerOn()).
+       * @see                  SetRecordingResolution(), GetRecordingResolution()
+       */
+       Tizen::Base::Collection::IList* GetSupportedRecordingResolutionListN(void) const;
+
+       /**
+       * Gets the maximum supported frame rate of the input resolution.
+       *
+       * @return               The maximum frame rate of the input recording resolution
+       * @param[in]    dim                                             The preview resolution of the Camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG                   The specified input resolution is invalid.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @remark               The specific error code can be accessed using the GetLastResult method. @n
+       *                               This method works after the input media source is initialized (for example: Camera::PowerOn()).
+       * @see                  Camera::SetPreviewFrameRate()
+       */
+       int GetSupportedMaxFrameRate(const Tizen::Graphics::Dimension& dim) const;
+
+       /**
+       * Enables or disables the mute state of a recorder.
+       *
+       * @return               An error code
+       * @param[in]    mute                            Set to @c true to enable the mute state of the recorder, @n
+       *                                                                       else @c false
+       *                                                                  By default, the mute state is disabled.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @remarks              The recording continues even in the mute state.
+       * @see                  IsMuted()
+       */
+       result SetMute(bool mute);
+
+       /**
+       * Checks whether the mute state of the recorder is enabled.
+       *
+       * @return               The mute state of the recorder
+       * @see                  SetMute()
+       */
+       bool IsMuted(void) const;
+
+       /**
+       * Sets the rotation of the recorder.
+       *
+       * @return               An error code
+       * @param[in]    rotation                        The rotation of the recorder
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This method is invalid for the current state of this instance.
+       * @exception    E_INVALID_ARG           The specified @c rotation is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @remarks              Before recording a video, the rotate information is tagged to the recording file. @n
+       *                     Using this information, a video player shows the video correctly regardless of the device orientation.
+       * @see                  GetRecordingRotation()
+       */
+       result SetRecordingRotation(RecordingRotation rotation);
+
+       /**
+       * Gets the rotation of the recorder.
+       *
+       * @return               The current rotation
+       * @see                  SetRecordingRotation()
+       */
+       RecordingRotation GetRecordingRotation(void) const;
+
+       /**
+       * Called when the mode is prepared to change.
+       *
+       * @return               An error code
+       * @param[in]     mode           recorder mode
+       */
+       result OnCameraCoordinatorModeChangePrepared(_CameraMode mode);
+
+       /**
+       * Called when the mode is changed.
+       *
+       * @return               An error code
+       * @param[in]     mode           recorder mode
+       */
+       result OnCameraCoordinatorModeChanged(_CameraMode mode);
+
+       /**
+       * Sets the state.
+       *
+       * @param[in]    state              new _VideoRecorder's state
+       */
+       void SetState(RecorderState state);
+
+       /**
+       * Sets the recording time
+       *
+       * @param[in]    recTime                  recording time in milliseconds
+       */
+       void SetRecordingTime(long recTime);
+
+       /**
+       * Sets the recording size
+       *
+       * @param[in]    recSize                  recording size in bytes
+       */
+       void SetRecordingSize(long recSize);
+
+       /**
+       * Gets the device type
+       *
+       * @return               The current device type
+       */
+       _RecorderDeviceType GetDeviceType(void) const;
+
+       /**
+       * Called when the event is received from the %_ICameraCoordinatorListener object.
+       *
+       *
+       * @param[in]    previous                 Previous recorder state
+       * @param[in]    current          Current recorder state
+       * @param[in]    byPolicy                true if the state is changed by policy, otherewise false
+       * @param[in]    pUserData               User data
+       */
+       static void StateChangedCb(recorder_state_e previous, recorder_state_e current, bool byPolicy, void* pUserData);
+
+       /**
+       * Recording Status callback function
+       *
+       * @param[in]    elapsedTime       recording time elapsed
+       * @param[in]    fileSize                 size of file written
+       * @param[in]    pUserData               User data
+       */
+       static void RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData);
+
+       /**
+       * Audio stream callback function
+       *
+       * @param[in]    pStream           Stream data
+       * @param[in]    format          Sample format
+       * @param[in]    channel         Sample channel
+       * @param[in]    timeStampl      The time stamp
+       * @param[in]    pUserData               User data
+        */
+       static void AudioStreamCb(void* pStream, int size, audio_sample_type_e format, int channel, unsigned int timeStamp, void *pUserData);
+
+       /**
+       * Limit reached callback function
+       *
+       * @param[in]    type              Limit reached reason
+       * @param[in]    pUserData               User data
+        */
+       static void LimitReachedCb(recorder_recording_limit_type_e type, void *pUserData);
+
+       /**
+       * Message callback function
+       *
+       * @param[in]    error                   Error reason
+       * @param[in]    state           Error state
+       * @param[in]    pUserData               User data
+        */
+       static void ErrorCb(recorder_error_e error, recorder_state_e state, void *pUserData);
+
+       /**
+       * Message callback function
+       *
+       * @param[in]    policy          The policy which occurs the interruption
+       * @param[in]    previous                Previous recorder state
+       * @param[in]    current         Current recorder state
+       * @param[in]    pUserData               User data
+        */
+       static void InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData);
+
+       /**
+        * Function check fo this object is alive.
+        *
+        * @return              true if the object is alive, otherwise false.
+        */
+       static bool IsAlive(void);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return              The pointer to %_VideoRecorderImpl
+        * @param[in]   pVideoRecorder          The %VideoRecorder pointer
+        */
+       static _VideoRecorderImpl* GetInstance(VideoRecorder *pVideoRecorder);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @return              The pointer to %_VideoRecorderImpl
+        * @param[in]   pVideoRecorder          The %VideoRecorder pointer
+        */
+       static const _VideoRecorderImpl* GetInstance(const VideoRecorder *pVideoRecorder);
+
+private:
+       /**
+       * Converts the error from recorder to Result.
+       *
+       * @return          An error code
+       * @param[in]    err                      recorder error
+       */
+       result ConvertResult(int err) const;
+
+       /**
+       * Converts codecType to String
+       *
+       * @return          void
+       * @param[in]    codecType       video codec type
+       * @param[out]   codec   Codec in string format
+       */
+       void GetCodecString(const CodecType videoCodec, Tizen::Base::String& codec) const;
+
+       /**
+       * Transfer the state.
+       *
+       * @return          An error code
+       * @param[in]    mmState                  recorder's destinationed state
+       * @param[in]    reason             state change reason
+       * @remarks      This method makes the recorder's state change. @n
+       *                       Sometimes, acccording to this, Recorder's state is changed.
+       */
+       result ChangeStateTo(recorder_state_e mmDestState, _RecorderStateChangeReason reason);
+
+       /**
+       * Checks the operation is for completing.
+       *
+       * @return               The state change reason
+       * @remarks      If the Cancel() is called, this value is false, because the Record() is not completed.
+       */
+       _RecorderStateChangeReason GetStateChangeReason(void) const;
+
+       /**
+       * Gets the recorder's state.
+       *
+       * @return                  The state
+       *
+       */
+       recorder_state_e GetMmState(void) const;
+
+       /**
+       * Get the event processing object.
+       *
+       * @return          The event processing object.
+       * @remarks      This event is working synchronously.
+       */
+       _VideoRecorderEvent* GetEvent(void) const;
+
+       /**
+       * Converts String to codecType
+       *
+       * @return          CodecType
+       * @param[in]    codec   Codec in string format
+       * @param[out]   audioCodec   Audio codec type
+       * @param[out]   videoCodec   Video codec type
+       * @param[out]container   Container type
+       */
+       void GetMediaType(const Base::String& codec, CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const;
+
+       /**
+       * Gets the new media type from the old type.
+       *
+       * @param[in]    format            recording type
+       * @param[out]   audioCodec        audiocodec type matching the input format
+       * @param[out]   videoCodec        videocodec type matching the input format
+       * @param[out]   container          container type matching the input format
+       *
+       */
+       void GetMediaType(VideoRecordingFormat format, CodecType& audioCodec, CodecType& videoCodec, MediaContainerType& container) const;
+
+       /**
+       * Re-load configuration.
+       *
+       * @return          An error code
+       * @param[in]    reload                            reload configuration field
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @remarks      Multiple configuration field can be set using reloadConf parameter appending.
+       */
+       result ReloadConfiguration(int reload);
+
+       /**
+       * Load default configuration.
+       *
+       * @return          An error code
+       * @param[in]    reload                            reload configuration field
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       result LoadDefaultConfiguration(int reload);
+
+       /**
+       * Sets the format of the recorder.
+       *
+       * @return               An error code
+       * @param[in]    audioCodec                              The audioCodec of the recorder
+       * @param[in]    videoCodec                              The videoCodec of the recorder
+       * @param[in]    container                               The container of the recorder
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c quality is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @see                  SetFormat()
+       */
+       result SetFormatAttr(CodecType audioCodec, CodecType videoCodec, MediaContainerType container);
+
+       /**
+       * Sets the quality of the recorder.
+       *
+       * @return               An error code
+       * @param[in]    quality                         The quality of the recorder
+       * @param[in]    audioCodec                              The audioCodec of the recorder
+       * @param[in]    videoCodec                              The videoCodec of the recorder
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c quality is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @see                  SetQuality()
+       */
+       result SetQualityAttr(RecordingQuality quality,         CodecType audioCodec, CodecType videoCodec);
+
+       /**
+       * Enables or disables the mute state of a recorder.
+       *
+       * @return               An error code
+       * @param[in]    mute                            Set to @c true to enable the mute state of the recorder, @n
+       *                                                                       else @c false
+       *                                                                  By default, the mute state is disabled.
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @remarks              The recording continues even in the mute state.
+       * @see                  SetMute()
+       */
+       result SetMuteAttr(bool mute);
+
+       /**
+       * Gets the time limit of the recording in milliseconds.
+       *
+       * @return               A @c long value indicating the maximum recording time in milliseconds @n
+       *                               else @c -1 if the recording has not started as yet
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  SetMaxRecordingTime()
+       */
+       result SetMaxRecordingTimeAttr(long msTime);
+
+       /**
+       * Sets the callback of the recorder.
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         This instance is in an invalid state for this method.
+       * @exception    E_INVALID_ARG           The specified @c quality is not supported.
+       * @exception    E_OUT_OF_MEMORY         The memory is insufficient.
+       * @see                  ReloadConfiguration()
+       */
+       result SetCallback(void);
+
+       _VideoRecorderImpl(const _VideoRecorderImpl& _VideoRecorderImpl);
+       _VideoRecorderImpl& operator =(const _VideoRecorderImpl& _VideoRecorderImpl);
+
+       _CameraCoordinator* __pCoordinator;
+       _VideoRecorderEvent* __pVideoRecorderEvent;
+       IVideoRecorderEventListener* __pVideoRecorderEventListener;
+       _VideoSourceAdapter* __pVideoSourceAdapter;
+       bool __isConstructed;
+       RecorderState __state;
+       long __recTime;
+       long __recSize;
+       long __maxTime;
+       VideoRecordingFormat __format;
+       CodecType __audioCodec;
+       CodecType __videoCodec;
+       MediaContainerType __container;
+       VideoRecorderMode __mode;
+       RecordingQuality __quality;
+       bool __mute;
+       RecordingRotation __rotation;
+       _RecorderHandle __handle;
+       _RecorderDeviceType     __deviceType;
+       Tizen::Graphics::Dimension __recordingResolution;
+       camera_pixel_format_e __mmSourceFormat;
+       Tizen::Base::String __filePath;
+       _RecorderStateChangeReason __stateChangeReason;
+
+       static bool __isUsed;
+};
+
+}}// Tizen::Media
+
+#endif
diff --git a/src/FMedia_VideoSourceAdapter.cpp b/src/FMedia_VideoSourceAdapter.cpp
new file mode 100755 (executable)
index 0000000..0dfa355
--- /dev/null
@@ -0,0 +1,174 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_VideoSourceAdapter.cpp
+ * @brief                      This file contains the implementation of the %FMedia_VideoSourceAdapter class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseColIList.h>
+#include "FMedia_VideoSourceAdapter.h"
+#include "FMedia_CameraCapability.h"
+#include "FMedia_CameraImpl.h"
+#include "FMedia_CamPtrUtil.h"
+
+//#define _SAFE_VIDEO_FORMAT_
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Media
+{
+
+_VideoSourceAdapter::_VideoSourceAdapter(const Tizen::Media::_CameraImpl &cameraImpl)
+{
+       __pSource = const_cast<_CameraImpl*>(&cameraImpl);
+       __sourceType = _VIDEO_SOURCE_CAMERA;
+       __recommendPreviewFormat = CAMERA_PIXEL_FORMAT_NV12;
+}
+
+_VideoSourceAdapter::~_VideoSourceAdapter()
+{
+}
+
+Tizen::Base::Collection::IList*
+_VideoSourceAdapter::GetSupportedRecordingResolutionListN(void) const
+{
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pResolutionList (null, _ListPtrUtil::remover);
+
+       if (__sourceType == _VIDEO_SOURCE_CAMERA)
+       {
+               _CameraImpl* pCameraImpl = null;
+               _CameraOperationType operation = _COP_NONE;
+               _ResultType itemType = _RESULT_NONE;
+
+               pCameraImpl = dynamic_cast<_CameraImpl*>(__pSource);
+               SysTryReturn(NID_MEDIA, pCameraImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  This is not the camera object.");
+               operation = pCameraImpl->GetSelection() == CAMERA_PRIMARY ? _COP_PRIMARY_RECORDING_RESOLUTION : _COP_SECONDARY_RECORDING_RESOLUTION;
+
+               pResolutionList.reset(_CameraCapability::GetListN(operation, itemType));
+               SysTryReturn(NID_MEDIA, pResolutionList.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+               SysTryReturn(NID_MEDIA, pResolutionList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+               SysTryReturn(NID_MEDIA, itemType == _RESULT_DIMENSION_LIST, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list items are wrong.");
+       }
+
+       return pResolutionList.release();
+}
+
+Tizen::Base::Collection::IListT<camera_pixel_format_e>*
+_VideoSourceAdapter::GetSupportedRecordingFormatListN(void) const
+{
+       result r = E_SUCCESS;
+       std::unique_ptr <ArrayListT<camera_pixel_format_e>, _ListPtrUtil::Remover> pListT (null, _ListPtrUtil::remover);
+       camera_pixel_format_e recommendPreviewFormat = CAMERA_PIXEL_FORMAT_NV12;
+
+       if (__sourceType == _VIDEO_SOURCE_CAMERA)
+       {
+               pListT.reset(new (std::nothrow) ArrayListT<camera_pixel_format_e>());
+               SysTryReturn(NID_MEDIA, pListT.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  out of memory");
+
+               r = pListT->Construct();
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating", GetErrorMessage(r));
+
+               // This means that the device supports recommeded format for the recording.
+               recommendPreviewFormat = __recommendPreviewFormat;
+               r = pListT->Add(recommendPreviewFormat);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating", GetErrorMessage(r));
+       }
+
+       return pListT.release();
+}
+
+Tizen::Base::Collection::IListT<int>*
+_VideoSourceAdapter::GetSupportedFrameRateListN(const Tizen::Graphics::Dimension& dim) const
+{
+       std::unique_ptr <IListT<int>, _ListPtrUtil::Remover> pFpsListT (null, _ListPtrUtil::remover);
+
+       if (__sourceType == _VIDEO_SOURCE_CAMERA)
+       {
+               _CameraImpl* pCameraImpl = null;
+
+               pCameraImpl = dynamic_cast<_CameraImpl*>(__pSource);
+               SysTryReturn(NID_MEDIA, pCameraImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  This is not the camera object.");
+
+               pFpsListT.reset(pCameraImpl->GetSupportedPreviewFrameRateListN(dim));
+               SysTryReturn(NID_MEDIA, pFpsListT.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
+               SysTryReturn(NID_MEDIA, pFpsListT->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The list was empty.");
+       }
+       return pFpsListT.release();
+}
+
+
+Tizen::Graphics::Dimension
+_VideoSourceAdapter::GetSourceResolution(void) const
+{
+       Dimension resolution;
+
+       if (__sourceType == _VIDEO_SOURCE_CAMERA)
+       {
+               _CameraImpl* pCameraImpl = null;
+               pCameraImpl = dynamic_cast<_CameraImpl*>(__pSource);
+               SysTryCatch(NID_MEDIA, pCameraImpl != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  This is not the camera object.");
+
+               resolution = pCameraImpl->GetPreviewResolution();
+       }
+
+       return resolution;
+
+CATCH:
+       return Dimension(0, 0);
+}
+
+bool
+_VideoSourceAdapter::HasRecordingResolutionRestriction(void) const
+{
+       bool restriction = false;
+
+       if (__sourceType == _VIDEO_SOURCE_CAMERA)
+       {
+               restriction = true;
+       }
+
+       return restriction;
+}
+
+result
+_VideoSourceAdapter::SetRecommendPreviewFormat(_CameraHandle cameraHandle)
+{
+       int err = MM_SUCCESS;
+       result r = E_SUCCESS;
+#if defined _SAFE_VIDEO_FORMAT_
+       camera_pixel_format_e recommendPreviewFormat = CAMERA_PIXEL_FORMAT_I420;
+#else
+       camera_pixel_format_e recommendPreviewFormat = CAMERA_PIXEL_FORMAT_NV12;
+
+       err = camera_get_preview_format(cameraHandle, &recommendPreviewFormat);
+       SysTryCatch(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Getting the Recommend Preview Format error.");
+#endif
+       __recommendPreviewFormat = recommendPreviewFormat;
+       err = camera_set_preview_format(cameraHandle, __recommendPreviewFormat);
+
+       SysLog(NID_MEDIA, "the Recommend Preview Format:%d", __recommendPreviewFormat);
+       return r;
+CATCH:
+       return r;
+}
+}}
diff --git a/src/FMedia_VideoSourceAdapter.h b/src/FMedia_VideoSourceAdapter.h
new file mode 100755 (executable)
index 0000000..6cd05d4
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_VideoSourceAdapter.h
+ * @brief                      This is the header file for the %_VideoSourceAdapter class.
+ */
+#ifndef _FMEDIA_INTERNAL_VIDEO_SOURCE_ADAPTER_H_
+#define _FMEDIA_INTERNAL_VIDEO_SOURCE_ADAPTER_H_
+
+#include <camera.h>
+#include <FBaseObject.h>
+#include <FBaseColIList.h>
+#include <FBaseColIListT.h>
+#include <FGrpDimension.h>
+#include "FMedia_CameraTypes.h"
+
+namespace Tizen { namespace Media
+{
+class _CameraImpl;
+
+enum _VideoSourceType
+{
+       _VIDEO_SOURCE_NONE,
+       _VIDEO_SOURCE_CAMERA,
+};
+
+/**
+ * @class      _VideoSourceAdapter
+ */
+class _VideoSourceAdapter
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the constructor for this class.
+        *
+        * @param[in]   cameraImpl      _CameraImpl instance
+        */
+       _VideoSourceAdapter(const Tizen::Media::_CameraImpl &cameraImpl);
+
+       /**
+        * This is the destructor for this class.
+        * All allocated resources are deallocated by this method.
+        */
+       virtual ~_VideoSourceAdapter(void);
+
+       /**
+       * Gets a list of the supported camcorder resolutions. @n
+       * Each list item is a Tizen::Graphics::Dimension value.
+       *
+       * @return               A list of dimension representing the supported video recorder resolutions, @n
+       *                               else an empty list if no recording resolution is supported or if an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be released by the calling method. @n
+       *                               All items in the list must be released by the calling method. @n
+       */
+       Tizen::Base::Collection::IList* GetSupportedRecordingResolutionListN(void) const;
+
+       /**
+       * Gets the supported source format list for the video recording. @n
+       * Each list item has camera_pixel_format_e value.
+       *
+       * @return               A list of the formats supported by the recorder, @n
+       *                               else @c null if no source format is supported or an exception occurs
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remark               The specific error code can be accessed using the GetLastResult() method. @n
+       *                               The return value must be deleted. @n
+       */
+       Tizen::Base::Collection::IListT<camera_pixel_format_e>* GetSupportedRecordingFormatListN(void) const;
+
+       /**
+       * Gets the supported frame rate list of the input resolution.@n
+       * Each item of the list has an integer value.
+       *
+       * @return               A list of the frame rate of the input resolution, @n
+       *                               else @c null if no frame rate is supported or an exception occurs
+       * @param[in]    dim                                             The preview resolution of the camera
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       Tizen::Base::Collection::IListT<int>* GetSupportedFrameRateListN(const Tizen::Graphics::Dimension& dim) const;
+
+       /**
+       * Gets the source's resolution.
+       *
+       * @return               A dimension representing the source's resolution.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state for this method.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       Tizen::Graphics::Dimension GetSourceResolution(void) const;
+
+       /**
+       * Check if the source has the restriction of recording resolution.
+       *
+       * @return               @c true if the recording resolution is restricted, @n
+       *                               else @c false
+       */
+       bool HasRecordingResolutionRestriction(void) const;
+       /**
+       * Set the recommended preview format for videorecord.
+       *
+       * @return               An error code
+       * @param[in]    mode                                            _CameraHandle
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       result SetRecommendPreviewFormat(_CameraHandle cameraHandle);
+
+private:
+       Tizen::Base::Object* __pSource;
+       _VideoSourceType __sourceType;
+       camera_pixel_format_e __recommendPreviewFormat;
+};
+
+}}// Tizen::Media
+
+#endif
+
diff --git a/src/FMedia_VideoStreamInfoImpl.cpp b/src/FMedia_VideoStreamInfoImpl.cpp
new file mode 100644 (file)
index 0000000..374cb2e
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "FMedia_VideoStreamInfoImpl.h"
+
+
+namespace Tizen { namespace Media
+{
+
+using namespace Tizen::Base;
+
+_VideoStreamInfoImpl::_VideoStreamInfoImpl(CodecType codecType, int width, int height, int bitrate, float frameRate)
+{
+       __codecType = codecType;
+       __width = width;
+       __height = height;
+       __bitrate = bitrate;
+       __frameRate = frameRate;
+}
+
+_VideoStreamInfoImpl::~_VideoStreamInfoImpl()
+{
+
+}
+
+_VideoStreamInfoImpl::_VideoStreamInfoImpl(const _VideoStreamInfoImpl& rhs)
+{
+       __codecType = rhs.__codecType;
+       __bitrate = rhs.__bitrate;
+       __width = rhs.__width;
+       __height = rhs.__height;
+       __frameRate = rhs.__frameRate;
+}
+
+_VideoStreamInfoImpl&
+_VideoStreamInfoImpl::operator =(const _VideoStreamInfoImpl& rhs)
+{
+       // check for self-assignment
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __codecType = rhs.__codecType;
+       __bitrate = rhs.__bitrate;
+       __width = rhs.__width;
+       __height = rhs.__height;
+       __frameRate = rhs.__frameRate;
+
+       return *this;
+}
+
+bool
+_VideoStreamInfoImpl::Equals(const Object& info) const
+{
+       const _VideoStreamInfoImpl* pVideoStreamInfoImpl = dynamic_cast <const _VideoStreamInfoImpl *> (&info);
+       if (!pVideoStreamInfoImpl)
+       {
+               return false;
+       }
+       return (((__codecType == pVideoStreamInfoImpl->__codecType) && (__width == pVideoStreamInfoImpl->__width)
+               && (__height == pVideoStreamInfoImpl->__height) && (__bitrate == pVideoStreamInfoImpl->__bitrate ) &&
+               (!Float::Compare(this->__frameRate, pVideoStreamInfoImpl->__frameRate))) ? true : false);
+}
+
+int
+_VideoStreamInfoImpl::GetHashCode(void) const
+{
+       int framerate = (int)__frameRate;
+       int codecType = (int)__codecType;
+       return ((framerate ^ codecType) + (__width * __height) + (__bitrate));
+}
+
+int
+_VideoStreamInfoImpl::GetWidth() const
+{
+       return __width;
+}
+
+int
+_VideoStreamInfoImpl::GetHeight() const
+{
+       return __height;
+}
+
+int
+_VideoStreamInfoImpl::GetBitRate() const
+{
+       return __bitrate;
+}
+
+CodecType
+_VideoStreamInfoImpl::GetCodecType() const
+{
+       return __codecType;
+
+}
+
+//Rational
+float
+_VideoStreamInfoImpl::GetFrameRate() const
+{
+       return __frameRate;
+}
+
+};
+};
diff --git a/src/FMedia_VideoStreamInfoImpl.h b/src/FMedia_VideoStreamInfoImpl.h
new file mode 100644 (file)
index 0000000..3f292d1
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMediaVideoStreamInfo.h
+ * @brief                      This is the header file for the %VideoStreamInfo class.
+ *
+ * This header file contains the declarations of the %VideoStreamInfo class.
+ */
+
+#ifndef _FMEDIA_INTERNAL_VIDEOSTREAMINFO_IMPL_H_
+#define _FMEDIA_INTERNAL_VIDEOSTREAMINFO_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseFloat.h>
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+
+class VideoStreamInfo;
+
+//
+// @class     VideoStreamInfo
+// @brief     This class provides methods to get video information.
+//
+// This class provides methods to get video stream information, such as codec type, video width or height, bit rate,
+// and frame rate.
+//
+
+class  _VideoStreamInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       //
+       // This is the destructor for this class.
+       //
+       //
+       virtual ~_VideoStreamInfoImpl(void);
+
+public:
+       //
+       //      Gets the encoding type of a video.
+       //
+       //      @return             The value of the encoding type
+       //
+       CodecType GetCodecType(void) const;
+
+       //
+       //      Gets the width of a video.
+       //
+       //      @return             The value of the video width
+       //
+       int GetWidth(void) const;
+
+       //
+       //      Gets the height of a video.
+       //
+       //      @return             The value of the video height
+       //
+       int GetHeight(void) const;
+
+       //
+       //      Gets the bit rate of a video.
+       //
+       //      @return             The video bit rate in bits per second (bps)
+       //
+       int GetBitRate(void) const;
+
+       //
+       //      Gets the frame rate of a video.
+       //
+       //      @return             The video frame rate
+       //
+       float GetFrameRate(void) const;
+
+       //
+       // @see @ref Tizen::Media::VideoStreamInfo::Equals()
+       //
+       virtual bool Equals(const Object& obj) const;
+
+       //
+       // @see @ref Tizen::Media::VideoStreamInfo::GetHashCode()
+       //
+       virtual int GetHashCode(void) const;
+
+private:
+       //
+       // Initializes this instance of VideoStreamInfo with the specified parameters.
+       //
+       // @param [in]  codecType       The value of the encoding type
+       // @param [in]  width           The value of the video width
+       // @param [in]  height          The value of the video height
+       // @param [in]  bitrate         The video bit rate in bits per second (bps)
+       // @param [in]  frameRate       The video frame rate
+       //
+       _VideoStreamInfoImpl(CodecType codecType, int width, int height, int bitrate, float frameRate);
+       _VideoStreamInfoImpl(const _VideoStreamInfoImpl& rhs);
+       _VideoStreamInfoImpl& operator =(const _VideoStreamInfoImpl& rhs);
+
+private:
+       int __width;
+       int __height;
+       int __bitrate;
+       CodecType __codecType;
+       float __frameRate;
+       friend class VideoStreamInfo;
+};
+
+}}//Tizen::Media
+
+
+#endif
diff --git a/src/FMedia_VoipAudioSessionManagerImpl.cpp b/src/FMedia_VoipAudioSessionManagerImpl.cpp
new file mode 100644 (file)
index 0000000..8ef3beb
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License)
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <iostream>
+#include <pthread.h>
+#include <sound_manager.h>
+#include <FBaseRt.h>
+#include <FBaseSysLog.h>
+#include <FMediaAudioManagerTypes.h>
+#include "FMedia_AudioManagerConvert.h"
+#include "FMedia_VoipAudioSessionManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Media {
+
+_VoipAudioSessionManagerImpl* _VoipAudioSessionManagerImpl::__pVoipAudioSessionManagerImpl = null;
+
+_VoipAudioSessionManagerImpl::_VoipAudioSessionManagerImpl()
+       :__soundCallSessionHandle(null)
+{
+
+}
+
+_VoipAudioSessionManagerImpl::~_VoipAudioSessionManagerImpl(void)
+{
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       result r = E_SUCCESS;
+       if (__soundCallSessionHandle != null)
+       {
+               ret = sound_manager_call_session_destroy(__soundCallSessionHandle);
+               r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+               SysTryLog(NID_MEDIA, r == E_SUCCESS,
+                       "[%s] Failed to perform sound_manager_call_session_destroy operation.", GetErrorMessage(r));
+               __soundCallSessionHandle = null;
+       }
+}
+
+void
+_VoipAudioSessionManagerImpl::InitVoipAudioSessionManagerImpl(void)
+{
+       static _VoipAudioSessionManagerImpl instance;
+       __pVoipAudioSessionManagerImpl = &instance;
+}
+
+_VoipAudioSessionManagerImpl*
+_VoipAudioSessionManagerImpl::GetInstance(void)
+{
+       ClearLastResult();
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (__pVoipAudioSessionManagerImpl == null)
+       {
+               pthread_once(&onceBlock, InitVoipAudioSessionManagerImpl);
+       }
+       return __pVoipAudioSessionManagerImpl;
+}
+
+result
+_VoipAudioSessionManagerImpl::EnterCallSession(void)
+{
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       result r = E_SUCCESS;
+       SysTryReturn(NID_MEDIA, __soundCallSessionHandle == null , E_INVALID_OPERATION, E_INVALID_OPERATION,
+               "[E_INVALID_OPERATION] A error has been occurred. The value of __soundCallSessionHandle is not null.");
+
+       ret = sound_manager_call_session_create(SOUND_SESSION_TYPE_VOIP, &__soundCallSessionHandle);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Failed to perform sound_manager_get_a2dp_status operation with error code : 0x%x", GetErrorMessage(r), ret);
+       SysTryCatch(NID_MEDIA, __soundCallSessionHandle != null, r = E_SYSTEM, E_SYSTEM,
+               "[E_SYSTEM] A system error has been occurred. The value of __soundCallSessionHandle is null.");
+
+       return E_SUCCESS;
+CATCH:
+       if (__soundCallSessionHandle)
+       {
+               sound_manager_call_session_destroy(__soundCallSessionHandle);
+               __soundCallSessionHandle = null;
+       }
+       return r;
+}
+
+result
+_VoipAudioSessionManagerImpl::ExitCallSession(void)
+{
+       SysTryReturn(NID_MEDIA, __soundCallSessionHandle != null , E_INVALID_OPERATION, E_INVALID_OPERATION,
+               "[E_INVALID_OPERATION] A error has been occurred. The value of __soundCallSessionHandle is null.");
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       result r = E_SUCCESS;
+       ret = sound_manager_call_session_destroy(__soundCallSessionHandle);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r,"[%s] Failed to perform sound_manager_call_session_destroy operation.", GetErrorMessage(r));
+       __soundCallSessionHandle = null;
+       return E_SUCCESS;
+}
+
+result
+_VoipAudioSessionManagerImpl::SetCallSessionMode(VoipAudioSessionMode mode)
+{
+       result r = E_SUCCESS;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       SysAssertf(__soundCallSessionHandle != null, "Not yet constructed! Construct() should be called before use");
+       SysTryReturn(NID_MEDIA, mode != VOIP_AUDIO_SESSION_MODE_NONE , E_INVALID_ARG, E_INVALID_ARG,
+               " [E_INVALID_ARG] Invalid argument is used. The mode is not correct : %d", mode);
+       ret = sound_manager_call_session_set_mode(__soundCallSessionHandle, _AudioManagerConvert::ConvertVoipMode2CallMode(mode));
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r,
+               "[%s] Failed to perform sound_manager_call_session_set_mode operation.", GetErrorMessage(r));
+       return r;
+}
+
+VoipAudioSessionMode
+_VoipAudioSessionManagerImpl::GetCallSessionMode(void)
+{
+       int ret = SOUND_MANAGER_ERROR_NONE;
+       result r = E_SUCCESS;
+       SysAssertf(__soundCallSessionHandle != null, "Not yet constructed! Construct() should be called before use");
+       sound_call_session_mode_e soundCallSessionMode = SOUND_CALL_SESSION_MODE_VOICE;
+       ret = sound_manager_call_session_get_mode(__soundCallSessionHandle, &soundCallSessionMode);
+       r = _AudioManagerConvert::CovertSoundManagerError2Result(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Failed to perform sound_manager_call_session_get_mode operation with error code : 0x%x", GetErrorMessage(r), ret);
+       return _AudioManagerConvert::ConvertCallSessionMode2VoipMode(soundCallSessionMode);
+CATCH:
+       return VOIP_AUDIO_SESSION_MODE_NONE;
+}
+
+};
+};             //Tizen::Media
diff --git a/src/FMedia_VorbisDecoder.cpp b/src/FMedia_VorbisDecoder.cpp
new file mode 100644 (file)
index 0000000..d7ca20c
--- /dev/null
@@ -0,0 +1,551 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <ogg.h>
+#include <vorbis/codec.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColHashMapT.h>
+#include <FBaseUtilMath.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioTypes.h>
+#include <FBaseSysLog.h>
+#include "FMedia_VorbisDecoder.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Media
+{
+
+class _OggStream
+{
+public:
+       _OggStream(int serial)
+       {
+               mSerial = serial;
+               memset((void *)&mState, 0, sizeof(mState));
+               mPacketCount = 0;
+       }
+       ~_OggStream()
+       {
+               ogg_stream_clear(&mState);
+       }
+
+       int mSerial;
+       ogg_stream_state mState;
+       int mPacketCount;
+};
+
+
+_IAudioDecoder*
+_VorbisDecoder_CreateInstance()
+{
+       return new (std::nothrow) _VorbisDecoder();
+}
+
+_VorbisDecoder::_VorbisDecoder(void)
+{
+       __isConstructed = false;
+       memset(&__vorbisBlock, 0, sizeof(vorbis_block));
+       memset(&__vorbisComment, 0, sizeof(vorbis_comment));
+       memset(&__vorbisInfo, 0, sizeof(vorbis_info));
+       memset(&__vorbisState, 0, sizeof(vorbis_dsp_state));
+       memset(&__state, 0, sizeof(__state));
+       __isHeaderDecoded = false;
+       __pStream = null;
+       __pBuf = null;
+       __offset = 0;
+       __maxOffsetLength = 0;
+       __serial = 0;
+}
+
+_VorbisDecoder::~_VorbisDecoder(void)
+{
+       __isConstructed = false;
+       __isHeaderDecoded = false;
+
+       // Eliminate the memory leak for stream* previously added in hashmap
+       {
+               IMapEnumeratorT<int,_OggStream*> * pEnum = __streamMap.GetMapEnumeratorN();
+               if (pEnum)
+               {
+                       _OggStream* pValue = null;
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               pEnum->GetValue(pValue);
+                               if (pValue != null)
+                               {
+                                       delete pValue;
+                               }
+                       }
+                       delete pEnum;
+               }
+       }
+       __streamMap.RemoveAll();
+
+       // Clear calls for the vorbis decoder library to avoid memory leak.
+       vorbis_block_clear(&__vorbisBlock);
+       vorbis_dsp_clear(&__vorbisState);
+       vorbis_comment_clear(&__vorbisComment);
+       vorbis_info_clear(&__vorbisInfo);
+
+
+       ogg_sync_clear(&__state);
+}
+
+result
+_VorbisDecoder::Construct(const Tizen::Base::Collection::HashMap* pOption)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf( __isConstructed == false, " Already Constructed .");
+
+       vorbis_info_init(&__vorbisInfo);
+       vorbis_comment_init(&__vorbisComment);
+       r = __streamMap.Construct();
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                         "[%s] map construct  Failed",GetErrorMessage(E_SYSTEM));
+       __isConstructed = true;
+       SetLastResult(r);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VorbisDecoder::ParseOggStream(void)
+{
+       ogg_page page;
+       int res = 0;
+       result r = E_SUCCESS;
+       char* pBuffer = null;
+
+       // " ParseOggStream offSet  & maxOffSetLength
+       SysTryCatch(NID_MEDIA, __offset != __maxOffsetLength, r = E_END_OF_FILE, E_END_OF_FILE,
+                          "[%s]  Reached End of File",GetErrorMessage(E_END_OF_FILE));         
+
+       while (ogg_sync_pageout(&__state, &page) != 1)
+       {
+               pBuffer = ogg_sync_buffer(&__state, PAGE_SIZE);
+               SysTryCatch(NID_MEDIA, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                  "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+               if ( !(__offset + PAGE_SIZE > __maxOffsetLength))
+               {
+                       memcpy(pBuffer, __pBuf + __offset, PAGE_SIZE);
+                       __offset += PAGE_SIZE;
+                       ogg_sync_wrote(&__state, PAGE_SIZE);
+               }
+               else
+               {
+                       memcpy(pBuffer, __pBuf + __offset, __maxOffsetLength - __offset );
+                       __offset = __maxOffsetLength;
+                       ogg_sync_wrote(&__state, PAGE_SIZE);
+                       res = ogg_sync_pageout(&__state, &page);
+                       SysTryCatch(NID_MEDIA, res == 1, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
+                                          "[%s] The input data format is not supported or Reached End of File ",GetErrorMessage(E_UNSUPPORTED_FORMAT));        
+               }
+       }
+
+
+       __serial = ogg_page_serialno(&page);
+
+       if (ogg_page_bos(&page))
+       {
+               //  " page is the beginning of a bitstream"
+               __pStream = new (std::nothrow) _OggStream(__serial);
+               SysTryCatch(NID_MEDIA, (__pStream != null), r = E_SYSTEM, E_SYSTEM,
+                  "[E_SYSTEM]__streamMap.GetValue Failed",GetErrorMessage(E_SYSTEM));
+               res = ogg_stream_init(&__pStream->mState, __serial);
+               SysTryCatch(NID_MEDIA, (res == 0), r = E_SYSTEM, E_SYSTEM,
+                  "[%s] ogg_stream_init:", GetErrorMessage(E_SYSTEM));
+
+               //All the hash map elements will be removed in the destructor
+               __streamMap.Add(__serial,__pStream);
+       }
+       else
+       {
+               _OggStream* pTemp = null;
+               r = __streamMap.GetValue(__serial, pTemp);
+               SysTryCatch(NID_MEDIA, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM,
+                  "[%s] __streamMap.GetValue Failed", GetErrorMessage(r));
+               SysTryCatch(NID_MEDIA, (pTemp != null), r = E_SYSTEM, E_SYSTEM,
+                  "[%s] __streamMap.GetValue Failed", GetErrorMessage(E_SYSTEM));
+               __pStream = pTemp;
+       }
+
+       ogg_stream_pagein(&__pStream->mState, &page);
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VorbisDecoder::SetStreamHeader(void)
+{
+       int headerCount = 0;
+       int res = 0;
+       result r = E_SUCCESS;
+       ogg_packet oggPacket;
+
+
+       r = ParseOggStream();
+       SysTryCatch(NID_MEDIA, (r == E_SUCCESS), , r,
+                                  "[%s]  ParseOggStream Failed", GetErrorMessage(r));
+
+       for (headerCount = 0; headerCount < HEADER_COUNT;)
+       {
+               res = ogg_stream_packetout(&__pStream->mState, &oggPacket);
+               while (res == 0)
+               {
+                       r = ParseOggStream();
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                                          "[%s] ParseOggStream Failed", GetErrorMessage(r))
+                       res = ogg_stream_packetout(&__pStream->mState, &oggPacket);
+               }
+               SysTryCatch(NID_MEDIA, (res > 0), r = E_SYSTEM, E_SYSTEM,
+                                  "[%s] Failed to get a packet");
+
+               res = vorbis_synthesis_headerin(&__vorbisInfo, &__vorbisComment,
+                                                                               &oggPacket);
+               SysTryCatch(NID_MEDIA, (res == E_SUCCESS), r = E_SYSTEM, E_SYSTEM,
+                                  "[%s]  vorbis_synthesis_headerin Failed", GetErrorMessage(E_SYSTEM));
+               headerCount++;
+       }
+
+       return r;
+CATCH:
+       return r;
+}
+
+result
+_VorbisDecoder::Decode(const byte* srcBuf, int srcBufSize, int& srcBufUsed,
+                                          byte* dstBuf, int dstBufSize, int& dstBufUsed)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+       ogg_packet oggPacket;
+       float** pcm = null;
+       int samples = 0;
+       short* ptr = null;
+       int dstOffset = 0;
+
+       SysTryCatch(NID_MEDIA, ( __isConstructed == true), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, ( srcBuf != null && srcBufSize >= 0), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       __pBuf = (byte*) srcBuf;
+       __maxOffsetLength = srcBufSize;
+       __offset = 0;
+
+       if (__isHeaderDecoded != true)
+       {
+               res = ogg_sync_init(&__state);
+               SysTryCatch(NID_MEDIA, (res == 0), r = E_SYSTEM, E_SYSTEM,
+                                  "[%s] ogg_sync_init Failed", GetErrorMessage(E_SYSTEM));
+
+               r = SetStreamHeader();
+               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                                         "[%s] Failed to get a packet", GetErrorMessage(E_SYSTEM));
+
+               res = vorbis_synthesis_init(&__vorbisState, &__vorbisInfo);
+               SysTryCatch(NID_MEDIA, (res == E_SUCCESS), r = E_SYSTEM, E_SYSTEM,
+                                  "[%s] vorbis_synthesis_init Failed", GetErrorMessage(E_SYSTEM));
+               res = vorbis_block_init(&__vorbisState, &__vorbisBlock);
+               SysTryCatch(NID_MEDIA, (res == E_SUCCESS), r = E_SYSTEM, E_SYSTEM,
+                                  "[%s] vorbis_block_init Failed", GetErrorMessage(E_SYSTEM));
+               __isHeaderDecoded = true;
+       }
+
+       //  " Decoding  Vorbis Audio "
+       while (!samples)
+       {
+               res = ogg_stream_packetout(&__pStream->mState, &oggPacket);
+               if (res == 0)
+               {
+                       r = ParseOggStream();
+                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+                                          "[%s] Failed to get a packet", GetErrorMessage(E_SYSTEM));
+                       res = ogg_stream_packetout(&__pStream->mState, &oggPacket);
+               }
+               if (res < 0)
+               {
+                       continue; //no block required here , this is a continue statement.
+               }
+
+               res = vorbis_synthesis(&__vorbisBlock, &oggPacket);             
+               if (res == OV_ENOTAUDIO || res == OV_EBADPACKET)
+               {
+                       continue; //no block required here , this is a continue statement.
+               }
+               SysTryCatch(NID_MEDIA, (res == E_SUCCESS), r = E_SYSTEM, E_SYSTEM,
+                                  "[%s] vorbis_synthesis Failed", GetErrorMessage(E_SYSTEM));
+
+               res = vorbis_synthesis_blockin(&__vorbisState, &__vorbisBlock);
+               SysTryCatch(NID_MEDIA, (res == E_SUCCESS), r = E_SYSTEM, E_SYSTEM,
+                                  "[%s] vorbis_synthesis_blockin Failed", GetErrorMessage(E_SYSTEM));
+
+               samples = vorbis_synthesis_pcmout(&__vorbisState, &pcm);
+       }
+
+       ptr = (short*) (dstBuf + dstOffset);
+       SysTryCatch(NID_MEDIA, dstBufSize >= (samples * __vorbisInfo.channels * sizeof(short)),
+                          r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Failed to get a packet", GetErrorMessage(E_SYSTEM));
+       for (int i = 0; i < samples; ++i)
+       {
+               for (int j = 0; j < __vorbisInfo.channels; ++j)
+               {
+                       int v = static_cast<int>(Tizen::Base::Utility::Math::Floor(0.5 + pcm[j][i] * 32767.0));
+                       if (v > 32767)
+                       {
+                               v = 32767;
+                       }
+                       if (v < -32768)
+                       {
+                               v = -32768;
+                       }
+                       *ptr++ = v;
+               }
+       }
+
+       res = vorbis_synthesis_read(&__vorbisState, samples);
+       SysTryCatch(NID_MEDIA, res == E_SUCCESS, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s]  Decode Failed", GetErrorMessage(E_SYSTEM));
+
+       dstBufUsed = (samples * __vorbisInfo.channels * sizeof(short));
+       srcBufUsed = __offset;
+       return r;
+
+CATCH:
+       if ( r == E_UNSUPPORTED_FORMAT && __isHeaderDecoded && srcBufSize <  PAGE_SIZE )
+       {
+               srcBufUsed = __offset;
+               dstBufUsed = 0;
+               r = E_SUCCESS;
+       }
+       return r;
+}
+
+
+result
+_VorbisDecoder::Probe(const byte* srcBuf, const int srcBufLength,
+                                         Tizen::Media::AudioSampleType& sampleType,
+                                         Tizen::Media::AudioChannelType& channelType, int& sampleRate)
+{
+       result r = E_SUCCESS;
+       int res = 0;
+
+       SysTryCatch(NID_MEDIA, (__isConstructed == true), r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, (srcBuf != null && srcBufLength > 0), r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+
+       __pBuf = (byte*) srcBuf;
+       __maxOffsetLength = srcBufLength;
+       __offset = 0;
+
+       res = ogg_sync_init(&__state);
+       SysTryCatch(NID_MEDIA, (res == 0), r = E_SYSTEM, E_SYSTEM,
+                          "[%s] ogg_sync_init Failed", GetErrorMessage(E_SYSTEM));
+
+       r = SetStreamHeader();
+       SysTryCatch(NID_MEDIA, (r == E_SUCCESS), , r,
+                                  "[%s]  ParseOggStream Failed", GetErrorMessage(r));
+
+       res = vorbis_synthesis_init(&__vorbisState, &__vorbisInfo);
+       SysTryCatch(NID_MEDIA, (res == E_SUCCESS), r = E_SYSTEM, E_SYSTEM,
+                          "[%s]vorbis_synthesis_init Failed", GetErrorMessage(E_SYSTEM));
+       res = vorbis_block_init(&__vorbisState, &__vorbisBlock);
+       SysTryCatch(NID_MEDIA, (res == E_SUCCESS), r = E_SYSTEM, E_SYSTEM,
+                          "[%s]vorbis_block_init Failed", GetErrorMessage(E_SYSTEM));
+
+       channelType = (Tizen::Media::AudioChannelType)__vorbisInfo.channels;
+       sampleType = AUDIO_TYPE_PCM_S16_LE;
+       sampleRate = __vorbisInfo.rate;
+
+       // Eliminate the memory leak for stream* previously added in hashmap
+       {
+               IMapEnumeratorT<int,_OggStream*> * pEnum = __streamMap.GetMapEnumeratorN();
+               if (pEnum != null)
+               {
+                       _OggStream* pValue = null;
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               pEnum->GetValue(pValue);
+                               if (pValue)
+                               {
+                                       delete pValue;
+                               }
+                       }
+                       delete pEnum;
+               }
+       }
+       __streamMap.RemoveAll();
+
+       // Clear calls for the vorbis decoder library to avoid memory leak.
+       vorbis_block_clear(&__vorbisBlock);
+       vorbis_dsp_clear(&__vorbisState);
+       vorbis_comment_clear(&__vorbisComment);
+       vorbis_info_clear(&__vorbisInfo);
+
+       // call to avoid memory leak
+       ogg_sync_clear(&__state);
+
+       vorbis_info_init(&__vorbisInfo);
+       vorbis_comment_init(&__vorbisComment);
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VorbisDecoder::Reset(void)
+{
+       result r = E_SUCCESS;
+       int res = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, (__isConstructed == true), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       vorbis_info_init(&__vorbisInfo);
+       vorbis_comment_init(&__vorbisComment);
+       res = vorbis_synthesis_restart(&__vorbisState);
+       __isHeaderDecoded = false;
+       SysTryCatch(NID_MEDIA, res == E_SUCCESS, r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VorbisDecoder::GetValue(MediaPropertyType type, int& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, (__isConstructed == true), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, 0 < type, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, (__isHeaderDecoded == true), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       switch (type)
+       {
+       case MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE:
+               switch (__vorbisInfo.channels)
+               {
+               case 0:
+                       value = AUDIO_CHANNEL_TYPE_NONE;
+                       break;
+
+               case 1:
+                       value = AUDIO_CHANNEL_TYPE_MONO;
+                       break;
+
+               case 2:
+                       value = AUDIO_CHANNEL_TYPE_STEREO;
+                       break;
+
+               default:
+                       break;
+       }
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE:
+               value = AUDIO_TYPE_PCM_S16_LE;
+       break;
+
+       case MEDIA_PROPERTY_AUDIO_SAMPLE_RATE:
+               value = __vorbisInfo.rate;
+       break;
+
+       default:
+               return E_OBJ_NOT_FOUND;
+       break;
+       }
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_VorbisDecoder::GetValue(MediaPropertyType type, float& value) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, (__isConstructed == true), r = E_INVALID_STATE, E_INVALID_STATE,
+                           "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+       SysTryCatch(NID_MEDIA, type < 0, r = E_INVALID_ARG, E_INVALID_ARG,
+                          "[%s] Invalid argument is used. The argument is not valid",GetErrorMessage(E_INVALID_ARG));
+       SysTryCatch(NID_MEDIA, type < MEDIA_PROPERTY_VIDEO_WIDTH || type >= MEDIA_PROPERTY_AUDIO_SAMPLE_RATE,
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysTryCatch(NID_MEDIA, (__isHeaderDecoded == true), r = E_INVALID_STATE, E_INVALID_STATE,
+                          "[%s] The instance is in invalid state",GetErrorMessage(E_INVALID_STATE));
+
+       return E_OBJ_NOT_FOUND;
+
+CATCH:
+       return r;
+}
+
+Tizen::Base::Collection::IListT<MediaPropertyType>*
+_VorbisDecoder::GetSupportedPropertyListN(void) const
+{
+       result r = E_SUCCESS;
+       ArrayListT<MediaPropertyType>* pPropList = new (std::nothrow) ArrayListT<MediaPropertyType>;
+
+       SysTryCatch(NID_MEDIA, pPropList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                          "[%s] Memory Allocation  Failed ",GetErrorMessage(E_OUT_OF_MEMORY));
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE);
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE);
+       pPropList->Add(MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE);
+       SetLastResult(r);
+       return pPropList;
+
+CATCH:
+       return null;
+}
+
+bool
+_VorbisDecoder::IsPropertySupported(MediaPropertyType type) const
+{
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_MEDIA, (type == MEDIA_PROPERTY_AUDIO_SAMPLE_RATE
+                                                  || type == MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE
+                                                  || type == MEDIA_PROPERTY_AUDIO_SAMPLE_TYPE),
+                          r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+                          "[%s] The instance is not available ",GetErrorMessage(E_OBJ_NOT_FOUND));
+       SetLastResult(r);
+       return true;
+
+CATCH:
+       return false;
+}
+
+}} // Tizen::Media
diff --git a/src/FMedia_VorbisDecoder.h b/src/FMedia_VorbisDecoder.h
new file mode 100644 (file)
index 0000000..e99eb6f
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ *  @file   FMedia_VorbisDecoder.h
+ *  @brief  This is the header file for the _VorbisDecoder.
+ *
+ *  This header file contains the declarations of the Tizen::Media::_VorbisDecoder.
+ */
+#ifndef _FMEDIA_INTERNAL_VORBISDECODER_H_
+#define _FMEDIA_INTERNAL_VORBISDECODER_H_
+
+#include "FMedia_IAudioDecoder.h"
+
+namespace Tizen { namespace Media
+{
+
+class _OggStream;
+
+class _VorbisDecoder
+       : public Tizen::Media::_IAudioDecoder
+{
+public:
+       _VorbisDecoder(void);
+
+       virtual ~_VorbisDecoder(void);
+
+public:
+       virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
+
+       virtual result Probe(const byte* srcBuf, const int length, Tizen::Media::AudioSampleType& sampleType, Tizen::Media::AudioChannelType& channelType, int& sampleRate);
+
+       virtual result Decode(const byte* srcBuf, int srcBufSize, int &srcBufUsed,
+                                                 byte* dstBuf, int dstBufSize, int& dstBufUsed);
+
+       virtual result Reset(void);
+
+       virtual result GetValue(MediaPropertyType type, int& value) const;
+
+       virtual result GetValue(MediaPropertyType type, float& value) const;
+
+       virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
+
+       virtual bool IsPropertySupported(MediaPropertyType type) const;
+
+private:
+       result ParseOggStream(void);
+
+       result SetStreamHeader(void);
+
+       _VorbisDecoder(const _VorbisDecoder&);
+
+       _VorbisDecoder& operator =(const _VorbisDecoder&);
+
+private:
+       static const int PAGE_SIZE = 4096;
+       static const int DEFAULT_BUFFER_SIZE = 8192 * 2;
+       static const int HEADER_COUNT = 3;
+
+       vorbis_dsp_state __vorbisState;
+       vorbis_info __vorbisInfo;
+       vorbis_comment __vorbisComment;
+       vorbis_block __vorbisBlock;
+       bool __isConstructed;
+       bool __isHeaderDecoded;
+       ogg_sync_state __state;
+       Tizen::Base::Collection::HashMapT<int, _OggStream*> __streamMap;
+       _OggStream* __pStream;
+       byte* __pBuf;
+       int __offset;
+       int __maxOffsetLength;
+       int __serial;
+};
+
+} } // Tizen::Media
+
+#endif // _FMEDIA_INTERNAL_VORBISDECODER_H_
diff --git a/src/inc/FMedia_AudioOutImpl.h b/src/inc/FMedia_AudioOutImpl.h
new file mode 100644 (file)
index 0000000..1443fd5
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// @file               FMedia_AudioOutImpl.h
+// @brief              This is the header file for the FMediaAudioOutImpl.
+//
+// This header file contains the declarations of the FMediaAudioOutImpl.
+//
+//
+#ifndef _FMEDIA_INTERNAL_AUDIO_OUT_IMPL_H_
+#define _FMEDIA_INTERNAL_AUDIO_OUT_IMPL_H_
+#include <memory>
+#include <audio_io.h>
+#include <unique_ptr.h>
+#include <FBaseRtIRunnable.h>
+#include <FBaseRtMutex.h>
+#include <FBaseColQueueT.h>
+#include <FBaseRtMonitor.h>
+#include <FBaseRtThread.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioOut.h>
+#include <FMediaAudioTypes.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaIAudioOutEventListener.h>
+
+namespace Tizen { namespace Media
+{
+
+class _AudioOutEvent;
+
+class _OSP_EXPORT_ _AudioOutImpl
+       : public Tizen::Base::Runtime::IRunnable
+       , public Tizen::Base::Object
+{
+public:
+       _AudioOutImpl(void);
+       virtual ~_AudioOutImpl(void);
+
+       result Construct(const Tizen::Media::AudioOut* pAudiOut, Tizen::Media::IAudioOutEventListener& listener);
+       int GetMaxBufferSize(void);
+       int GetMinBufferSize(void);
+       int GetOptimizedSampleRate(void);
+       AudioChannelType GetOptimizedChannelType(void);
+       AudioSampleType GetOptimizedSampleType(void);
+       AudioOutState GetState(void);
+       int GetVolume(void) const;
+       result SetVolume(int& volume);
+       result Prepare(AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate);
+       result Prepare(AudioStreamType audioStreamType, AudioSampleType audioSampleType, AudioChannelType audioChannelType, int audioSampleRate);
+       result UnPrepare(void);
+       result Start(void);
+       result Stop(void);
+       result Reset(void);
+       result WriteBuffer(const Tizen::Base::ByteBuffer& userData);
+       Tizen::Base::Object* Run(void);
+       static void AudioIoInterrupted(audio_io_interrupted_code_e code, void *pUserData);
+       static _AudioOutImpl* GetInstance(AudioOut* pAudioOut);
+       static const _AudioOutImpl* GetInstance(const AudioOut* pAudioOut);
+       static int instanceCount;
+       static int maxInstanceCount;
+       static AudioChannelType audioOutOptimalChannelType;
+       static AudioSampleType audioOutOptimalSampleType;
+       static int audioOutOptimalSampleRate;
+       static int audioOutMinimumBufferSize;
+       static int audioOutMaximumBufferSize;
+private:
+       _AudioOutImpl(const _AudioOutImpl& rhs);
+       _AudioOutImpl& operator =(const _AudioOutImpl& rhs);
+
+       static void InitInstanceMutex(void);
+       result SendBufferEndReachedEvent(void);
+       result SendInterrupted(void);
+       result SendReleased(void);
+       result SendAudioFocusChanged(void);
+       void DownSample(unsigned char* pDataBuffer, int bytes);
+       void ScaleDownVolume(unsigned char* pDataBuffer, int bytes);
+       void PreProcess(Tizen::Base::ByteBuffer* pBuffer);
+       result MapExceptionToResult(int reason);
+       void HandleInterrupted(audio_io_interrupted_code_e code);
+
+       std::unique_ptr<_AudioOutEvent> __pAudioOutEvent;
+       std::unique_ptr<Tizen::Base::Runtime::Thread> __pWorkerThread;
+       std::unique_ptr<Tizen::Base::Runtime::Monitor> __pBufferSync;
+       static std::unique_ptr<Tizen::Base::Runtime::Mutex> __pInstanceMutex;
+       static bool __isInstanceMutexInitialized;
+
+       AudioOut* __pAudioOut;
+       IAudioOutEventListener* __pAudioOutEventListener;
+       AudioOutState __audioOutState;
+       int __volume;
+       int __volume256;
+       AudioSampleType __presentSampleType;
+       int __presentSampleRate;
+       audio_out_h __audioOutHandle;
+       Tizen::Base::Collection::QueueT <Tizen::Base::ByteBuffer*> __bufferQueue;
+       int __audioOutOptimalBufferSize;
+       bool __stop;
+       bool __interruptFlag;
+};  //end of _AudioOutImpl
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/inc/FMedia_AudioRouteManagerImpl.h b/src/inc/FMedia_AudioRouteManagerImpl.h
new file mode 100644 (file)
index 0000000..8a7b2bd
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// @file               FMedia_AudioRouteManagerImpl.h
+// @brief              This is the header file for the FMedia_AudioRouteManagerImpl.h
+//
+// This header file contains the declarations of the FMedia_AudioRouteManagerImpl.h
+//
+//
+#ifndef _FMEDIA_INTERNAL_AUDIO_ROUTE_MANAGER_IMPL_H_
+#define _FMEDIA_INTERNAL_AUDIO_ROUTE_MANAGER_IMPL_H_
+#include <memory>
+#include <unique_ptr.h>
+#include <sound_manager.h>
+#include <FBaseRt.h>
+#include <FBaseCol.h>
+#include <FMediaTypes.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaAudioRouteInfo.h>
+#include "FMedia_AudioRouteEvent.h"
+#include "FMedia_AudioRouteEventArg.h"
+
+namespace Tizen { namespace Media
+{
+
+class IAudioRouteEventListener;
+class _AudioRouteManagerImpl
+       :public Tizen::Base::Object
+{
+public:
+       static _AudioRouteManagerImpl* GetInstance(void);
+       Tizen::Base::Collection::IList* GetAvailableAudioRouteListN();
+       bool IsAudioRouteAvailable(const AudioRouteInfo& device);
+       result SetActiveAudioRoute(const AudioRouteInfo& route);
+       AudioRouteInfo GetActiveAudioRoute(void);
+       Tizen::Base::String GetActiveBluetoothA2dpName(void);
+       AudioStreamType GetActiveAudioStreamType(void);
+       result SetAudioRouteEventListener(IAudioRouteEventListener* pListener);
+       static bool SoundAvailableRouteCallback(sound_route_e route, void* pUserData);
+       static void SoundAvailableRouteChangedCallback(sound_route_e route, bool available, void* pUserData);
+       static void SoundActiveDeviceChangedCallback(sound_device_in_e in, sound_device_out_e out, void* pUserData);
+private:
+       _AudioRouteManagerImpl(void);
+       virtual ~_AudioRouteManagerImpl(void);
+       result Construct(void);
+       static void InitAudioRouteManagerImpl(void);
+       static InputAudioDevice ConvertSoundIn2InputAudio(unsigned int route);
+       static OutputAudioDevice ConvertSoundOut2OutputAudio(unsigned int route);
+       static void ConvertRoute2AudioDevice(unsigned int route, AudioRouteInfo& audioDevice);
+       unsigned int ConvertOutputAudio2SoundOut(OutputAudioDevice output);
+       unsigned int ConvertInputAudio2SoundIn(InputAudioDevice input);
+       unsigned int ConvertAudioDevice2Route(const AudioRouteInfo &device);
+       IAudioRouteEventListener* __pListener;
+       std::unique_ptr<_AudioRouteEvent> __pAudioRouteEvent;
+       IAudioRouteEventListener* __pSingleAudioRouteListner;
+       static _AudioRouteManagerImpl* __pAudioRouteImpl;
+};
+}}             //Tizen::Media
+#endif
diff --git a/src/inc/FMedia_AudioSessionManagerImpl.h b/src/inc/FMedia_AudioSessionManagerImpl.h
new file mode 100644 (file)
index 0000000..95059d8
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef _FMEDIA_INTERNAL_AUDIO_SESSION_MANAGER_IMPL_H_
+#define _FMEDIA_INTERNAL_AUDIO_SESSION_MANAGER_IMPL_H_
+#include <unique_ptr.h>
+#include <sound_manager.h>
+#include <FBaseObject.h>
+#include <FBaseRt.h>
+#include <FMediaAudioManagerTypes.h>
+#include "FMedia_AudioSessionEvent.h"
+#include "FMedia_AudioSessionEventArg.h"
+
+namespace Tizen{ namespace Media{
+class IAudioSessionEventListener;
+
+class _AudioSessionManagerImpl
+       :public Tizen::Base::Object
+{
+public:
+       static _AudioSessionManagerImpl* GetInstance();
+       static void SoundSessionNotificationsCallback(sound_interrupted_code_e notify, void* pUserData);
+       result SetAudioSessionEventListener(IAudioSessionEventListener* pListener);
+       result AddListener(IAudioSessionEventListener* pListener);
+       result RemoveListener(IAudioSessionEventListener* pListener);
+       result SetMode(AudioSessionMode sessionMode);
+       AudioSessionMode GetMode(void);
+       sound_interrupted_code_e GetInterruptType(void);
+
+private:
+       _AudioSessionManagerImpl();
+       virtual ~_AudioSessionManagerImpl();
+       _AudioSessionManagerImpl(const _AudioSessionManagerImpl& audioSessionManager);
+       _AudioSessionManagerImpl& operator =(const _AudioSessionManagerImpl& audioSessionManager);
+       static void InitAudioSessionManagerImpl(void);
+       result Construct(void);
+       void SendInterrupted(sound_interrupted_code_e notify);
+       void SendAudioFocusChanged(sound_interrupted_code_e notify);
+       void SendReleased();
+       static _AudioSessionManagerImpl* __pAudioSessionImpl;
+       std::unique_ptr<_AudioSessionEvent> __pAudioSessionEvent;
+       IAudioSessionEventListener* __pSingleAudioSessionListner;
+       AudioSessionMode __currentSessionMode;
+       sound_interrupted_code_e __interruptedEvent;
+       bool __interruptFlag;
+};
+
+};
+};
+#endif
diff --git a/src/inc/FMedia_CameraPreProcessUtil.h b/src/inc/FMedia_CameraPreProcessUtil.h
new file mode 100755 (executable)
index 0000000..8554665
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CameraPreProcessUtil.h
+ * @brief                      This header file contains the declarations of Camera's extened functions.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_PROCESSING_H_
+#define _FMEDIA_INTERNAL_CAMERA_PROCESSING_H_
+
+#include <FMediaTypes.h>
+
+namespace Tizen { namespace Media
+{
+class Camera;
+
+typedef void (*_CameraPreprocessingCallback)( MediaPixelFormat format, byte* data[4], int size[4], void* user);
+
+extern "C" _OSP_EXPORT_ result SetPreProcessingCallback(Camera &cam, _CameraPreprocessingCallback pPreProcessCbFunc, void* pPreProcessUserData);
+extern "C" _OSP_EXPORT_ result UnSetPreProcessingCallback(Camera &cam);
+
+}}// Tizen::Media
+
+#endif
+
diff --git a/src/inc/FMedia_CapabilityImpl.h b/src/inc/FMedia_CapabilityImpl.h
new file mode 100755 (executable)
index 0000000..029ca0f
--- /dev/null
@@ -0,0 +1,371 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_CapabilityImpl.h
+ * @brief                      This is the header file for the _CapabilityImpl class.
+ *
+ * This header file contains the declarations of the _CapabilityImpl class.
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAPABILITY_IMPL_H_
+#define _FMEDIA_INTERNAL_CAPABILITY_IMPL_H_
+
+#include <libxml/tree.h>
+#include <FBaseColIList.h>
+#include <FBaseColHashMap.h>
+
+namespace Tizen { namespace Media
+{
+_OSP_EXPORT_ extern const wchar_t* const AUDIORECORDER_CODEC_TYPE;
+_OSP_EXPORT_ extern const wchar_t* const AUDIORECORDER_MEDIA_CONTAINER_TYPE;
+_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_AUDIO_CODEC_TYPE;
+_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_VIDEO_CODEC_TYPE;
+_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_MEDIA_CONTAINER_TYPE;
+_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_CODEC;
+
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_ZOOM_LEVEL;
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_FOCUS_POINT;
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_ZOOM_LEVEL;
+_OSP_EXPORT_ extern const wchar_t* const CAMERA_SECONDARY_FOCUS_POINT;
+
+enum _MediaCapValueType
+{
+       _MEDIA_CAP_VALUE_TYPE_BOOL,
+       _MEDIA_CAP_VALUE_TYPE_INT,
+       _MEDIA_CAP_VALUE_TYPE_LONG_LONG,
+       _MEDIA_CAP_VALUE_TYPE_DOUBLE,
+       _MEDIA_CAP_VALUE_TYPE_STRING,
+       _MEDIA_CAP_VALUE_TYPE_LIST,
+};
+
+enum _MediaCapCategoryType
+{
+       _MEDIA_CAP_CATEGORY_NONE,
+       _MEDIA_CAP_CATEGORY_AUDIO,
+       _MEDIA_CAP_CATEGORY_IMAGE,
+       _MEDIA_CAP_CATEGORY_PLAYER,
+       _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA,
+       _MEDIA_CAP_CATEGORY_SECONDARY_CAMERA,
+       _MEDIA_CAP_CATEGORY_VIDEO_RECORDER,
+       _MEDIA_CAP_CATEGORY_AUDIO_RECORDER,
+       _MEDIA_CAP_CATEGORY_CODEC,
+};
+
+/**
+ * @class      _CapabilityImpl
+ * @brief      This class provides parsing class for MediaCapability class.
+ */
+class _CapabilityImpl
+       : public Tizen::Base::Object
+{
+public:
+       static _CapabilityImpl* GetInstance(void);
+
+       /**
+       *       Initializes this instance of _CapabilityImpl.
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result Construct(void);
+
+       /**
+       *       Get capability value in Media.
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result GetValue(const Tizen::Base::String& key, bool& value);
+
+       /**
+       *       Get capability value in Media.
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result GetValue(const Tizen::Base::String& key, int& value);
+
+
+       /**
+       *       Get capability value in Media.
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result GetValue(const Tizen::Base::String& key, long long& value);
+
+       /**
+       *       Get capability value in Media.
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result GetValue(const Tizen::Base::String& key, double& value);
+
+       /**
+       *       Get capability value in Media.
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+
+       /**
+       *       Get capability value in Media.
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result GetValueN(const Tizen::Base::String& key, Tizen::Base::Collection::IList& value);
+
+
+       /**
+       *       Convert char to integer
+       *
+       *       @return         Tizen::Base::Object*
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static Tizen::Base::Object* ConvertCharToInteger(const char* input, Object* pObj, const void* param);
+
+       /**
+       *       Convert char to string
+       *
+       *       @return         Tizen::Base::Object*
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static Tizen::Base::Object* ConvertCharToString(const char* input, Object* pObj, const void* param);
+
+       /**
+       *       Convert char to enum
+       *
+       *       @return         Tizen::Base::Object*
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static Tizen::Base::Object* ConvertCharToEnum(const char* input, Object* pObj, const void* param);
+
+       /**
+       *       Convert char to dimesion
+       *
+       *       @return         Tizen::Base::Object*
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static Tizen::Base::Object* ConvertCharToDimension(const char* input, Object* pObj, const void* param);
+
+       /**
+       *       Copy object to list integer type
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static result CopyListInteger(int type, Object* pObj, void* value);
+
+       /**
+       *       Copy object to list string type
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static result CopyListString(int type, Object* pObj, void* value);
+
+       /**
+       *       Copy object to demension type
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static result CopyListDimension(int type, Object* pObj, void* value);
+
+       /**
+       *       Copy object to integer type
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static result CopyInteger(int type, Object* pObj, void* value);
+
+       /**
+       *       Copy object to bool type
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_OUT_OF_MEMORY                                 The memory is insufficient.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       static result CopyBool(int type, Object* pObj, void* value);
+
+protected:
+       /**
+       *       Get capability value in Media.
+       *
+       *       @return         E_SUCCESS in success, an error code in failure
+       *
+       *       @param[in]      key                     The key string for capability lookup
+       *       @param[in]      type            value type
+       *       @param[out]     value           returned capability value
+       *
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result GetValue(const Tizen::Base::String& key, int type, void* value);
+
+       /**
+       *       parse the xml file data
+       *       @return         E_SUCCESS in success, an error code in failure
+       *       @param[in]      pXmlBuffer                                              xml file content
+       *       @param[in]      length                                  size of xml buffer
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_OBJ_NOT_FOUND                 The specified key was not found.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result ParseCapability(const char* pXmlBuffer, int length);
+
+       /**
+       *       parse the xml node data
+       *       @param[in]      pRoot                                            xml start tag node
+       *       @param[in]      section                              section name
+       */
+       void ParseSection(xmlNode* pRoot, const Tizen::Base::String& section);
+
+private:
+       /**
+       *       This is the default constructor for this class.
+       *
+       *       @remarks        After creating an instance of this class, you must explicitly call one of
+       *                               the Construct() methods to initialize the instance.
+       *       @see            Construct()
+       */
+       _CapabilityImpl(void);
+
+       /**
+       *       This is the destructor for this class. @n
+       *       Resources are deallocated by this method.
+       *       This method should be called in the same thread as Construct() method
+       *
+       *       @see            Construct()
+       */
+       virtual ~_CapabilityImpl(void);
+
+       /**
+       *       copy constructor
+       *       @param[in]      src                                     _CapabilityImpl type object
+       */
+       _CapabilityImpl(const _CapabilityImpl& src);
+
+       /**
+       *       assignment operator overloading
+       *       @param[in]      src                                     _CapabilityImpl type object
+       */
+       _CapabilityImpl& operator =(const _CapabilityImpl& src);
+
+       /**
+       *       parse the capability by the category
+       *       @return         E_SUCCESS in success, an error code in failure
+       *       @param[in]      category                                        the category
+       *       @exception      E_SUCCESS                                               The method was successful.
+       *       @exception      E_INVALID_ARG                 The specified category is not valid.
+       *       @exception      E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       *       @exception      E_SYSTEM                                                A system error occurred.
+       */
+       result ParseCapability(_MediaCapCategoryType category);
+
+       static void InitCapabilityImpl(void);
+
+       Tizen::Base::Collection::HashMap* __pMap;
+       int __cameraCount;
+       bool __primaryCameraDone;
+       bool __secondaryCameraDone;
+       bool __videoRecorderDone;
+       bool __audioRecorderDone;
+
+       static _CapabilityImpl* __pCapabilityImplInst;
+};
+
+
+};
+};  // Tizen::Media
+
+#endif
diff --git a/src/inc/FMedia_FfmpegUtil.h b/src/inc/FMedia_FfmpegUtil.h
new file mode 100644 (file)
index 0000000..326af6c
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FMedia_FfmpegUtil.h
+ * @brief  This is the header file for the _FfmpegUtil.
+ *
+ * This header file contains the declarations of the _FfmpegUtil.
+ *
+ */
+#ifndef _FMEDIA_INTERNAL_FFMPEG_UTIL_H_
+#define _FMEDIA_INTERNAL_FFMPEG_UTIL_H_
+
+namespace Tizen { namespace Media
+{
+
+class _OSP_EXPORT_ _FfmpegUtil
+       : public Tizen::Base::Object
+{
+public:
+       static Tizen::Media::CodecType ToCodecType(CodecID codecId);
+
+       static CodecID ToCodecID(Tizen::Media::CodecType codecType);
+
+       static enum AudioChannelType ToAudioChannelType(int channel);
+
+       static enum AudioSampleType ToAudioSampleType(AVSampleFormat fmt);
+
+       static enum AVSampleFormat ToAvSampleFormat(AudioSampleType fmt);
+};
+
+}} // Tizen::Media
+
+#endif //  _FMEDIA_INTERNAL_FFMPEG_UTIL_H_
diff --git a/src/inc/FMedia_PlayerEvent.h b/src/inc/FMedia_PlayerEvent.h
new file mode 100644 (file)
index 0000000..0f75a1a
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_PlayerEvent.h
+ * @brief                      This header file contains the declaration of Tizen::Media namespace.
+ */
+
+#ifndef _FMEDIA_INTERNAL_PLAYER_EVENT_H_
+#define _FMEDIA_INTERNAL_PLAYER_EVENT_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseRt_Event.h>
+#include <FMediaIPlayerEventListener.h>
+#include <FMediaPlayer.h>
+
+namespace Tizen { namespace Media
+{
+
+class _OSP_EXPORT_ _PlayerEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       _PlayerEvent();
+       virtual ~_PlayerEvent(void);
+       result Construct(void);
+
+protected:
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+private:
+       _PlayerEvent(const _PlayerEvent& rhs);
+       _PlayerEvent& operator =(const _PlayerEvent& rhs);
+       int __cntListener;
+
+};
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/inc/FMedia_PlayerEventTypes.h b/src/inc/FMedia_PlayerEventTypes.h
new file mode 100644 (file)
index 0000000..6e963be
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMedia_PlayerEventTypes.h
+ * @brief              This header file defines common data structures or types for Media::Player.
+ */
+
+
+#ifndef _FMEDIA_INTERNAL_PLAYER_EVENT_TYPES_H_
+#define _FMEDIA_INTERNAL_PLAYER_EVENT_TYPES_H_
+
+#include <FOspConfig.h>
+#include <FMediaPlayerTypes.h>
+
+
+namespace Tizen {namespace Media
+{
+
+enum _PlayerEventType
+{
+       _PLAYER_EVENT_NONE = 0x00,                              /**< Event None */
+       _PLAYER_EVENT_OPENED = 0x01,                            /**< Player Opened event */
+       _PLAYER_EVENT_ENDOFCLIP,                                        /**< Player reached to end of clip event */
+       _PLAYER_EVENT_BUFFERING,                                        /**< Buffering event */
+       _PLAYER_EVENT_SEEKTO,                                   /**< SeekTo result event */
+       _PLAYER_EVENT_INTERRUPTED,                              /**< Interrupted event */
+       _PLAYER_EVENT_RELEASED,                                 /**< Released event */
+       _PLAYER_EVENT_ERROR,                                            /**< Error event */
+       _PLAYER_EVENT_DOWNLOAD_START,                   /**< Progressive download has started */
+       _PLAYER_EVENT_DOWNLOADING,                              /**< Progressive download size is updated */
+       _PLAYER_EVENT_DOWNLOAD_COMPLETE,                        /**< Progressive download has completed */
+       _PLAYER_EVENT_AUDIO_FOCUS_CHANGED               /**< event to signify that audio foucs has changed*/
+};
+
+
+}} // Tizen::Media
+
+#endif
diff --git a/src/inc/FMedia_PlayerImpl.h b/src/inc/FMedia_PlayerImpl.h
new file mode 100644 (file)
index 0000000..2b92f5c
--- /dev/null
@@ -0,0 +1,206 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// @file                       FMedia_PlayerImpl.h
+// @brief                      This header file contains the interface for subsystem's Player.
+//
+
+#ifndef _FMEDIA_INTERNAL_PLAYER_IMPL_H_
+#define _FMEDIA_INTERNAL_PLAYER_IMPL_H_
+
+#include <memory>
+#include <glib.h>
+#include <unique_ptr.h>
+#include <player.h>
+#include <FOspConfig.h>
+#include <FBaseRtTimer.h>
+#include <FBaseRtThread.h>
+#include <FGrp_BufferInfoImpl.h>
+#include <FGrp_VideoTextureImpl.h>
+#include <FMediaPlayerTypes.h>
+#include <FMediaAudioManagerTypes.h>
+#include <FMediaIPlayerEventListener.h>
+#include <FMediaIPlayerVideoEventListener.h>
+#include <FMediaIPlayerProgressiveDownloadListener.h>
+
+namespace Samsung { namespace Media
+{
+class _AudioEffectorImpl;
+}}
+
+namespace Tizen {namespace Media
+{
+
+class _PlayerEvent;
+class _PlayerVideoEvent;
+class _PlayerProgressiveDownloadEvent;
+enum _PlayerEventType;
+
+class _OSP_EXPORT_ _PlayerImpl
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::ITimerEventListener
+{
+               enum Orientation
+       {
+               ORIENTATION_PORTRAIT,
+               ORIENTATION_LANDSCAPE,
+               ORIENTATION_PORTRAIT_REVERSE,
+               ORIENTATION_LANDSCAPE_REVERSE
+       };
+
+       enum PlayerImplEvent
+       {
+               PLAYER_OPEN_ASYNC_EVENT = 0,
+               PLAYER_PLAY_EVENT,
+               PLAYER_PAUSE_EVENT,
+               PLAYER_STOP_EVENT,
+               PLAYER_CLOSE_EVENT,
+               PLAYER_SEEKTO_EVENT,
+               PLAYER_CAPTUREVIDEO_EVENT,
+               PLAYER_VIDEO_STREAM_CALLBACK
+       };
+
+public:
+       _PlayerImpl(void);
+       virtual ~_PlayerImpl(void);
+
+       static _PlayerImpl* GetInstance(Player* pPlayer);
+       static const _PlayerImpl* GetInstance(const Player* pPlayer);
+       result Construct(IPlayerEventListener& listener, const Tizen::Graphics::BufferInfo* pBufferInfo);
+       result Construct(IPlayerEventListener& listener, IPlayerVideoEventListener& videoListener, void* pPlayer);
+       result OpenFile(const Tizen::Base::String& mediaLocalPath, bool isAsync);
+       result OpenUrl(const Tizen::Base::Utility::Uri& mediaUri, bool isAsync = false);
+       result OpenBuffer(const Tizen::Base::ByteBuffer& mediaBuffer, bool isAsync);
+       result Play(void);
+       result Pause(void);
+       result Stop(void);
+       result Close(void);
+       PlayerState GetState(void);
+       long GetPosition(void)const;
+       int GetVolume(void) const;
+       bool IsMute(void) const;
+       bool IsLooping(void)const;
+       long GetDuration(void);
+       result SeekTo(long msTime);
+       result SetVolume(int volume);
+       result SetMute(bool mute);
+       result SetLooping(bool looping);
+       MediaStreamInfo* GetCurrentMediaStreamInfoN();
+       result SetRenderingBuffer(const Tizen::Graphics::BufferInfo& bufferInfo);
+       result CaptureVideo(void);
+       result SetAudioStreamType(AudioStreamType type);
+       result OpenUrlAsync(const Tizen::Base::String& url, const Tizen::Base::Collection::IMap* pHeader = null);
+       result OpenUrlAsync(Player* pPlayerInstance, const Tizen::Base::String& url, const Tizen::Base::String& filePath, IPlayerProgressiveDownloadListener& listener, const Tizen::Base::Collection::IMap* pHeader = null);
+       void SetProgressiveDownloadIntervalByPercent(int percent);
+       result Construct(IPlayerEventListener& listener, Tizen::Graphics::Opengl::VideoTexture& videoTexture);
+
+       void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+
+       static void PlayerStartedCallBack(void *pUserData);
+       static void PlayerCompletedCallBack(void *pUserData);
+       static void PlayerPreparedCallBack(void *pUserData);
+       static void PlayerInterruptedCallBack(player_interrupted_code_e code, void *pUserData);
+       static void PlayerErrorCallBack(int errorCode, void *pUserData);
+       static void PlayerBufferingCallBack(int percent, void *pUserData);
+       static void PlayerSubtitleUpdatedCallBack(unsigned long duration, char *pText, void *pUserData);
+       static void PlayerVideoCapturedCallBack(unsigned char *pData, int width, int height, unsigned int size, void *pUserData);
+       static void PlayerVideoFrameDecodedCallBack(unsigned char *pData, int width, int height, unsigned int size, void *pUserData);
+       static void PlayerAudioFrameDecodedCallBack(unsigned char *pData, unsigned int size, void *pUserData);
+       static void PlayerSeekCompletedCallBack(void *pUserData);
+       static void PlayerPdMessageCallBack(player_pd_message_type_e type, void* pUserData);
+
+private:
+       _PlayerImpl(const _PlayerImpl&);
+       _PlayerImpl& operator =(const _PlayerImpl& _PlayerImpl);
+
+       result OpenInputData(std::unique_ptr<char[]> pStrInputFilePath);
+       void SetSystemBitPerPixel(int bitPerPixel);
+       bool SendEvent(_PlayerEventType eventType, int value);
+       result SendCapturedVideoFrame(_PlayerVideoEventType event, void* pStream, int streamSize, int width, int height, result r);
+       result CreatePlayerAndSetCallBack(void);
+       static PlayerErrorReason MapExceptionToPlayerErrorReason(int reason);
+       static result MapExceptionToResult(int reason);
+       static CodecType ConvertAudioCodec(char *pAudioCodec);
+       static CodecType ConvertVideoCodec(char *pVideoCodec);
+       void HandlePlayerPrepared(void);
+       void HandlePlayerCompleted(void);
+       void HandlePlayerError(int errorCode);
+       void HandlePlayerBuffering(int percent);
+       void HandlePlayerVideoCaptured(unsigned char *pData, int width, int height, unsigned int size);
+       void HandlePlayerVideoFrameDecoded(unsigned char *pData, int width, int height, unsigned int size);
+       void HandlePlayerSeekCompleted(void);
+       void HandlePlayerInterrupted(void);
+       void HandlePlayerReleased(void);
+       void HandlePlayerAudioFoucsChanged(void);
+       result HandlePdMessageCallBack(player_pd_message_type_e type);
+       static void InitInstanceMutex(void);
+
+       static const int _PLAYER_IMPL_VIDEO_PIXEL_SIZE_RGB565 = 16;
+       static const float _PLAYER_MIN_VOLUME = 0.0;
+       static const float _PLAYER_MAX_VOLUME = 1.0;
+       static const int _PLAYER_PROGRESSIVE_DOWNLOAD_TIMER_100_MS = 100;
+
+       player_h __hPlayer;
+       player_state_e __corePlayerCurState;
+       Handle __hCanvas;
+       Tizen::Graphics::_BufferInfoImpl::HandleType __handleType;
+
+       std::unique_ptr<_PlayerEvent> __pPlayerEvent;
+       std::unique_ptr<_PlayerVideoEvent> __pPlayerVideoEvent;
+       std::unique_ptr<_PlayerProgressiveDownloadEvent> __pPlayerProgressiveDownloadEvent;
+       std::unique_ptr<Tizen::Base::Runtime::Timer> __pPdTimer;
+       std::unique_ptr<Tizen::Base::ByteBuffer> __pTargetByteBuffer;
+       static std::unique_ptr<Tizen::Base::Runtime::Mutex> __pMutex;
+       static bool __isInstanceMutexInitialized;
+
+       IPlayerEventListener* __pPlayerEventListener;
+       IPlayerVideoEventListener* __pPlayerVideoEventListener;
+       IPlayerProgressiveDownloadListener* __pPlayerProgressiveDownloadListener;
+
+       Orientation __orientation;
+       int __currentVolume;
+       PlayerState __currentState;
+       Tizen::Graphics::BitmapPixelFormat __videoPixelFormat;
+       int __bufferDataSize;
+       int __decodedFrameWidth;
+       int __decodedFrameHeight;
+       int __decodedFrameSize;
+       int __pdCallbackRate;
+       unsigned int __pdNextCallbackSize;
+       Tizen::Graphics::Opengl::_VideoTextureImpl* __pVideoTextureImpl;
+       bool __isOpenBuffer;
+       bool __isMuted;
+       bool __isLooped;
+       bool __isLocalData;
+       bool __isAsync;
+       bool __checkCallbackForReadyState;
+       bool __isStreamingContent;
+       bool __videoEventCreated;
+       bool __isPlayerConstructed;
+       bool __isStateChangeForVideoCapture;
+       bool __isProgressiveContent;
+       bool __isProgressiveTimerStarted;
+       bool __interruptFlag;
+       static int __playerCount;
+       static int __maxInstanceCount;
+       friend class Samsung::Media::_AudioEffectorImpl;
+       friend class _AudioEqualizerImpl;
+};
+};
+};
+#endif
diff --git a/src/inc/FMedia_PlayerProgressiveDownloadEvent.h b/src/inc/FMedia_PlayerProgressiveDownloadEvent.h
new file mode 100644 (file)
index 0000000..80cb953
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef _FMEDIA_INTERNAL_PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_H_
+#define _FMEDIA_INTERNAL_PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseRt_Event.h>
+#include <FMediaPlayer.h>
+
+namespace Tizen { namespace Media
+{
+
+class _OSP_EXPORT_ _PlayerProgressiveDownloadEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       _PlayerProgressiveDownloadEvent();
+       virtual ~_PlayerProgressiveDownloadEvent(void);
+       result Construct(Player* playerInstance);
+
+protected:
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+private:
+       _PlayerProgressiveDownloadEvent(const _PlayerProgressiveDownloadEvent& rhs);
+       _PlayerProgressiveDownloadEvent& operator =(const _PlayerProgressiveDownloadEvent& rhs);
+       Player* __pPlayerInstance;
+};
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/inc/FMedia_PlayerProgressiveDownloadEventArg.h b/src/inc/FMedia_PlayerProgressiveDownloadEventArg.h
new file mode 100644 (file)
index 0000000..c3cc3cf
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef _FMEDIA_INTERNAL_PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_ARG_H_
+#define _FMEDIA_INTERNAL_PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_ARG_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen {namespace Media
+{
+class _PlayerImpl;
+
+enum _PlayerProgressiveDownloadEventType
+{
+       PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_NONE,                                                 // Event_None
+       PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_STARTED,                                              // Recorded Event
+       PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_IN_PROGRESS,                                  // event interrupted by the system
+       PLAYER_PROGRESSIVE_DOWNLOAD_EVENT_COMPLETED,                                    // event released by the system
+};
+
+class _PlayerProgressiveDownloadEventTypeArg
+       : public Tizen::Base::Runtime::IEventArg
+       , public Tizen::Base::Object
+{
+public:
+
+       _PlayerProgressiveDownloadEventTypeArg(void);
+       virtual ~_PlayerProgressiveDownloadEventTypeArg(void);
+       _PlayerProgressiveDownloadEventType GetEventType(void) const;
+       void SetEventType(_PlayerProgressiveDownloadEventType eType);
+
+private:
+       _PlayerProgressiveDownloadEventTypeArg(const _PlayerProgressiveDownloadEventTypeArg& rhs);
+       _PlayerProgressiveDownloadEventTypeArg& operator =(const _PlayerProgressiveDownloadEventTypeArg& rhs);
+
+       _PlayerProgressiveDownloadEventType __playerProgresiveDownloadEventType;
+       friend class _PlayerImpl;
+};
+
+class _PlayerProgressiveDownloadEventArg
+       : public _PlayerProgressiveDownloadEventTypeArg
+{
+public:
+
+       _PlayerProgressiveDownloadEventArg(void);
+       virtual ~_PlayerProgressiveDownloadEventArg(void);
+       int GetDownloadedSize(void) const;
+       int GetTotalSize(void) const;
+       result GetResult() const;
+
+private:
+       void SetDownloadedSize(int downloadedSize);
+       void SetTotalSize(int totalSize);
+       void SetResult(result returnResult);
+       int __downloadedSize;
+       int __totalSize;
+       result __resultReturned;
+       friend class _PlayerImpl;
+};
+
+}} // Tizen::Media
+#endif
diff --git a/src/inc/FMedia_PlayerVideoEvent.h b/src/inc/FMedia_PlayerVideoEvent.h
new file mode 100644 (file)
index 0000000..eac26cd
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FMedia_PlayerVideoEvent.h
+ * @brief                      This header file contains the declaration of Tizen::Media namespace.
+ */
+
+#ifndef _FMEDIA_INTERNAL_PLAYER_VIDEO_EVENT_H_
+#define _FMEDIA_INTERNAL_PLAYER_VIDEO_EVENT_H_
+
+#include <FBaseRt_Event.h>
+#include <FMediaIPlayerVideoEventListener.h>
+#include <FMediaPlayer.h>
+
+namespace Tizen { namespace Media
+{
+
+
+class _OSP_EXPORT_ _PlayerVideoEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       _PlayerVideoEvent(void);
+       virtual ~_PlayerVideoEvent(void);
+       result Construct(void* pPlayer);
+protected:
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+private:
+       _PlayerVideoEvent(const _PlayerVideoEvent& rhs);
+       _PlayerVideoEvent& operator =(const _PlayerVideoEvent& rhs);
+
+       Player* __pPlayerSrc;
+       int __cntListener;
+};
+
+}}//Tizen::Media
+
+#endif
diff --git a/src/inc/FMedia_PlayerVideoEventTypes.h b/src/inc/FMedia_PlayerVideoEventTypes.h
new file mode 100644 (file)
index 0000000..055f651
--- /dev/null
@@ -0,0 +1,45 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FMedia_PlayerVideoEventTypes.h
+ * @brief              This header file defines common data structures or types for Media::Player.
+ *
+ */
+
+
+#ifndef _FMEDIA_INTERNAL_PLAYER_VIDEO_EVENT_TYPES_H_
+#define _FMEDIA_INTERNAL_PLAYER_VIDEO_EVENT_TYPES_H_
+
+#include <FOspConfig.h>
+#include <FMediaPlayerTypes.h>
+
+namespace Tizen {namespace Media
+{
+
+enum _PlayerVideoEventType
+{
+       _PLAYER_VIDEO_EVENT_NONE = 0x00,                 // Event None
+       _PLAYER_VIDEO_EVENT_DECODED = 0x01,              // Player decoded event
+       _PLAYER_VIDEO_EVENT_ERROR,                       // Error event
+       _PLAYER_VIDEO_EVENT_DECODED_WITHOUT_DATA,        // Player decoded event without any data
+};
+
+
+}} //Tizen::Media
+
+#endif
diff --git a/src/inc/FMedia_VoipAudioSessionManagerImpl.h b/src/inc/FMedia_VoipAudioSessionManagerImpl.h
new file mode 100644 (file)
index 0000000..812f974
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// @file               FMedia_VoipAudioSessionManagerImpl.h
+// @brief              This is the header file for the FMedia_VoipAudioSessionManagerImpl.h
+//
+// This header file contains the declarations of the FMedia_VoipAudioSessionManagerImpl.h
+//
+//
+#ifndef _FMEDIA_VOIP_AUDIO_SESSION_MANAGER_IMPL_H
+#define _FMEDIA_VOIP_AUDIO_SESSION_MANAGER_IMPL_H_
+#include <memory>
+#include <sound_manager.h>
+#include <FBaseRt.h>
+#include <FMediaAudioManagerTypes.h>
+
+namespace Tizen { namespace Media
+{
+class _VoipAudioSessionManagerImpl
+       :public Tizen::Base::Object
+{
+public:
+       static _VoipAudioSessionManagerImpl* GetInstance();
+       result EnterCallSession(void);
+       result ExitCallSession(void);
+       result SetCallSessionMode(VoipAudioSessionMode mode);
+       VoipAudioSessionMode GetCallSessionMode(void);
+private:
+       _VoipAudioSessionManagerImpl(void);
+       virtual ~_VoipAudioSessionManagerImpl(void);
+       static void InitVoipAudioSessionManagerImpl(void);
+       sound_call_session_h __soundCallSessionHandle;
+       static _VoipAudioSessionManagerImpl* __pVoipAudioSessionManagerImpl;
+};
+}}     //Tizen::Media
+#endif