4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
26 * @defgroup MultiMediaPG MultiMedia Camcorder,Player,Sound and Radio
28 <h1 class="pg">Introduction</h1>
29 <h2 class="pg">Purpose</h2>
31 The purpose of this document is to give the application developer detailed information on creating and configuring Multimedia applications using the Multimedia Framework API's.
34 <h2 class="pg">Scope</h2>
36 The scope of this document is limited to Samsung platform Multimedia Framework API usage.
38 <h2 class="pg">Abbreviations</h2>
46 Application Programming Interface
54 Joint Photographic Experts Group
70 Realtime Transport Protocol
91 @defgroup MM_Feature 2.Feature
94 <h1 class="pg">Multimedia Framework Feature</h1>
96 The Multimedia Framework is designed to provide easy to use services for developing multimedia applications based on an embedded Linux platform.
99 <h2 class="pg">Features</h2>
102 - Initialize Camcorder for Image capture
103 - Initialize Camcorder for Video capture
104 - Initialize Camcorder for Audio capture
105 - Uninitialize camcorder
107 - Record and Save a Audio/Video file or a Audio only file
108 - Record and Cancel saving of a recording file
109 - Record, Pause and resume recording
110 - Get state of camcorder
111 - Start and Stop focus
112 - User defined filename for recording file
113 - Set VideoStream Callback
114 - Set VideoCapture Callback
115 - Set Message Callback
118 - Play video/audio from local file, network stream, buffer and memory data
119 - Pause and resume playback
120 - Seeking the position during playing
121 - Setting section repeat
126 - Determine application's multimedia functional policy.
129 - Extracting Media Property Information
130 - Extracting Media Meta (Tag) data
131 - Extracting Stream information
134 - Play audio file with simple API (supports uncompressed wav/mp3 file only).
135 - Playback or capture PCM with given memory buffer.
138 - Cross platform 3D audio API appropriate for gaming applications.
139 - OpenAL in SLP only supports playback function.
142 - Listening to FM Radio
143 - Scan the effective frequencies
146 - Get/Set relative volume
149 - Image processing (Rotation, Resizing, and Color converting)
150 - Jpeg encoding and decoding
153 @defgroup MM_Architecture 1.Architecture
154 @ingroup MultiMediaPG
157 <h2 class="pg">Architecture diagram</h2>
164 The Camcorder Library is a module of the Multimedia framework of SLP. It is responsible for capturing various types of media data such as still image, audio frame, and video frame. According to its operating modes, the camcorder is able to 1) capture Still image, 2) record audio/video frame, and 3) record audio frame only. It provides many convenient functions to control itself. Users can select types of encoders, detailed specifications of video/audio data, and various effects that enhance the quality of the resulting file.
165 (The current release of SDK might not support all of the camcorder library functions because the camera driver in SDK does not support many APIs should be supported.)
170 The Player Library provides various functions for a multimedia application to implement playback of media contents. An application can play different formats of audio and audio/video files. The Player Library provides an interface for playing different formats by hiding the creation/construction of various streaming elements from the application, which makes application coding simpler and faster.
175 Session means timeline of multimedia resources are used.
176 Application developer can determine applications' session type as "shared", "exclusive" or "replace".
177 "Shared" type means the multimedia session is shared with other applications, if possible. The multimedia resources can be used by other applications.
178 "Exclusive" type means using the multimedia session exclusively. Other applications are not allowed to use multimedia resources during this time.
179 "Replace" type means this will make stop previous session but allows sharing session with following application.
184 The Fileinfo library provides APIs to extract media property information and meta data from media content. These values can be used to display detailed information of the media content without playing it.
190 The Sound library provides fuctions to play audio files (uncompressed wav and mp3) with a very simple API and to control sound volume of predefined type.
191 Also provides functions to playback raw PCM from a memory buffer and capture raw PCM to a memory buffer.
198 OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications. OpenAL in SLP only supports playback function.
199 For further information, see official website : http://connect.creativelabs.com/openal/default.aspx
205 The Radio Library provides various functions for implementing radio application. It supports the radio operations for HW radio chipset. This library can be only used when HW radio chipset is exist. Radio APIs provides the functionality for playing/stopping radio, changing the frequency, scanning and changing radio sound volumes.
210 The Utility library provides simple functions for a multimedia application to process YUV image data and to handle jpeg data. The Utility library for processing image data supports the conversion of color format from YUV to RGB, rotation of images, and resizing the width and height of the picture. The library also saves and loads the image in the Jpeg format. This library includes simple utility features which are related to multimedia.
213 @image html SLP_MultimediaFW_PG_image001.png
216 @defgroup MM_Camcorder Camcorder
217 @ingroup MultiMediaPG
220 @brief <sub class="ref">Also see</sub> Use Cases of @ref Camcorder_UC
221 <h2 class="pg">Camcorder</h2>
223 This part describes the APIs of the Multimedia Camcorder Library. Camcorder Library is used for recording video from video/audio input devices, capturing still images from the video input device, and audio recording from the audio input device.
225 Camcorder states can be changed by calling the functions shown in the following figure, "State of Camcorder".
226 Between each state there is intermediate state, and whilst in this state, any function call which attempts to change the camcorder state will fail.
227 Recording state and paused state exist when the camcorder is in video-capture mode. When in audio-capture mode, CAPTURING state will be replaced with RECORDING state.
229 All of the functions which change the state of the camcorder are asynchronous. The function returns immediately and a successful confirmation of state change will be notified through the message callback function. If the state is changed successfully, a state message callback function will be received with the new state, if not an error message will be received.
232 @image html SLP_MultimediaFW_PG_image002.png
234 <center>Figure. State of Camcorder</center>
238 The following table specifies the state changes of the camcorder module.
243 <center><b>FUNCTION</b></center>
246 <center><b>PRE-STATE</b></center>
249 <center><b>POST-STATE</b></center>
254 mm_camcorder_create()
265 mm_camcorder_destroy()
276 mm_camcorder_realize()
287 mm_camcorder_unrealize()
320 mm_camcorder_capture_start()
331 mm_camcorder_capture_stop()
342 mm_camcorder_record()
364 mm_camcorder_commit()
375 mm_camcorder_cancel()
387 The followings are functions to manage camcorder module.
389 - mm_camcorder_set_message_callback()
390 - Set callback for receiving messages from camcorder. Through this callback function, camcorder sends various message including status changes, asynchronous errors, capturing, and limitations. One thing you have to know is that message callback is working on the main loop of application. So until releasing the main loop, message callback will not be called.
392 - mm_camcorder_set_video_stream_callback()
393 - Set callback for user defined video stream callback function. Users can retrieve video frame using registered callback.
395 - mm_camcorder_set_video_capture_callback()
396 - Set callback for user defined video capture callback function. (Image mode only)
398 - mm_camcorder_get_state()
399 - Get the current state of camcorder.
401 - mm_camcorder_get_attributes()
402 - Get attributes of camcorder with given attribute names. This function can get multiple attributes simultaneously. If one of attribute fails, this function will stop at that point. 'err_attr_name' let you know the name of the attribute.
404 - mm_camcorder_set_attributes()
405 - Set attributes of camcorder with given attribute names. This function can set multiple attributes simultaneously. If one of attribute fails, this function will stop at that point. 'err_attr_name' let you know the name of the attribute.
407 - mm_camcorder_get_attribute_info()
408 - Get detailed information of the attribute.
410 - mm_camcorder_init_focusing()
411 - Initialize auto focusing. If auto focusing is in progressing, stop auto focusing and adjust the camera lens to initial position.
413 - mm_camcorder_start_focusing()
414 - Start focusing. This function return immediately. However, focusing operation will continue until it gets results. After finishing operation, you can get 'MM_MESSAGE_CAMCORDER_FOCUS_CHANGED' message.
416 - mm_camcorder_stop_focusing()
417 - Stop focusing. This function halts focusing operation.
421 The followings are full proto types of camcorder functions.
423 - int mm_camcorder_create( MMHandleType* camcorder, MMCamPreset* info );
425 - int mm_camcorder_destroy(MMHandleType camcorder);
427 - int mm_camcorder_realize(MMHandleType camcorder);
429 - int mm_camcorder_unrealize(MMHandleType camcorder);
431 - int mm_camcorder_start(MMHandleType camcorder);
433 - int mm_camcorder_stop(MMHandleType camcorder);
435 - int mm_camcorder_capture_start(MMHandleType camcorder);
437 - int mm_camcorder_capture_stop(MMHandleType camcorder);
439 - int mm_camcorder_record(MMHandleType camcorder);
441 - int mm_camcorder_pause(MMHandleType camcorder);
443 - int mm_camcorder_commit(MMHandleType camcorder);
445 - int mm_camcorder_cancel(MMHandleType camcorder);
447 - int mm_camcorder_set_message_callback(MMHandleType camcorder, MMMessageCallback callback, void *user_data);
449 - int mm_camcorder_set_video_stream_callback( MMHandleType camcorder, mm_camcorder_video_stream_callback callback, void* user_data );
451 - int mm_camcorder_set_video_capture_callback( MMHandleType camcorder, mm_camcorder_video_capture_callback callback, void* user_data );
453 - int mm_camcorder_get_state(MMHandleType camcorder, MMCamcorderStateType* state);
455 - int #mm_camcorder_get_attributes(MMHandleType camcorder, char **err_attr_name, const char *attribute_name, ...) G_GNUC_NULL_TERMINATED;
457 - int #mm_camcorder_set_attributes(MMHandleType camcorder, char **err_attr_name, const char *attribute_name, ...) G_GNUC_NULL_TERMINATED;
459 - int mm_camcorder_get_attribute_info(MMHandleType camcorder, const char *attribute_name, MMCamAttrsInfo *info);
461 - int mm_camcorder_init_focusing( MMHandleType camcorder );
463 - int mm_camcorder_start_focusing( MMHandleType camcorder );
465 - int mm_camcorder_stop_focusing( MMHandleType camcorder );
471 - Attribute system is an interface to operate camcorder. Depending on each attribute, camcorder behaves differently. Attribute system provides get/set functions. Setting proper attributes, a user can control camcorder as he wants (mm_camcorder_set_attributes()) Also, a user can retrieve the current status of the camcorder, calling getter function(mm_camcorder_get_attributes()). Beware, arguments of mm_camcorder_set_attributes() and mm_camcorder_get_attributes() should be finished with 'NULL'. This is a rule for the variable argument.
472 - Besides its value, each Attribute also has 'type' and 'validity type'. 'type' describes variable type that the attribute can have. If you input a value that has wrong type, camcorder will not work properly or will crash. 'validity' describes array or range of values that can be set to the attribute. 'validity type' defines type of the 'validity'.
473 - A user can retrieve these values using mm_camcorder_get_attribute_info().
476 Followings are the attributes which should be set before initialization (mm_camcorder_realize):
477 - For more detail information, please refer the doxygen document of Camcorder FW.
484 <center><b>Attribute</b></center>
487 <center><b>Description</b></center>
495 Mode of camcorder ( still/video/audio )
503 Audio device ID for capturing audio stream
511 Video device ID for capturing video stream
519 Audio codec for encoding audio stream
527 Video codec for encoding video stream
535 Image codec for capturing still-image
543 File format for recording media stream
548 #MMCAM_AUDIO_SAMPLERATE
551 Sampling rate of audio stream ( This is an integer field )
559 Audio format of each sample
567 Channels of each sample ( This is an integer field )
572 #MMCAM_AUDIO_INPUT_ROUTE
575 Set audio input route
583 Format of video stream. This is an integer field
591 Frames per second ( This is an integer field )
599 Width of input video stream
607 Height of input video stream
612 #MMCAM_CAMERA_FPS_AUTO
615 FPS Auto. When you set true to this attribute, FPS will vary depending on the amount of the light.
620 #MMCAM_DISPLAY_HANDLE
623 Pointer of display buffer or ID of xwindow
628 #MMCAM_DISPLAY_DEVICE
636 #MMCAM_DISPLAY_SOURCE_X
639 X position of source rectangle. When you want to crop the source, you can set the area with this value.
644 #MMCAM_DISPLAY_SOURCE_Y
647 Y position of source rectangle. When you want to crop the source, you can set the area with this value.
652 #MMCAM_DISPLAY_SOURCE_WIDTH
655 Width of source rectangle. When you want to crop the source, you can set the area with this value.
660 #MMCAM_DISPLAY_SOURCE_HEIGHT
663 Height of source rectangle. When you want to crop the source, you can set the area with this value.
668 #MMCAM_DISPLAY_ROTATION
676 #MMCAM_DISPLAY_VISIBLE
687 A scale of displayed image
692 #MMCAM_DISPLAY_GEOMETRY_METHOD
695 A method that describes a form of geometry for display
700 Followings are the attributes which should be set before recording (mm_camcorder_record()):
706 <center><b>Attribute</b></center>
709 <center><b>Description</b></center>
714 #MMCAM_AUDIO_ENCODER_BITRATE
717 Bitrate of Audio Encoder
722 #MMCAM_VIDEO_ENCODER_BITRATE
725 Bitrate of Video Encoder
730 #MMCAM_TARGET_FILENAME
733 Target filename. Only used in Audio/Video recording. This is not used for capturing.
738 #MMCAM_TARGET_MAX_SIZE
741 Maximum size of recording file(Kbyte). If the size of file reaches this value.
746 #MMCAM_TARGET_TIME_LIMIT
749 Time limit of recording file. If the elapsed time of recording reaches this value.
754 Followings are the attributes which should be set before capturing (mm_camcorder_capture_start()):
760 <center><b>Attribute</b></center>
763 <center><b>Description</b></center>
768 #MMCAM_IMAGE_ENCODER_QUALITY
771 Encoding quality of Image codec
776 #MMCAM_CAPTURE_FORMAT
779 Pixel format that you want to capture
787 Width of the image that you want to capture
792 #MMCAM_CAPTURE_HEIGHT
795 Height of the image that you want to capture
803 Total count of capturing
808 #MMCAM_CAPTURE_INTERVAL
811 Interval between each capturing on Multishot ( MMCAM_CAPTURE_COUNT > 1 )
816 Followings are the attributes which can be set anytime:
822 <center><b>Attribute</b></center>
825 <center><b>Description</b></center>
833 Input volume of audio source ( double value )
838 #MMCAM_CAMERA_DIGITAL_ZOOM
846 #MMCAM_CAMERA_OPTICAL_ZOOM
854 #MMCAM_CAMERA_FOCUS_MODE
862 #MMCAM_CAMERA_AF_SCAN_RANGE
870 #MMCAM_CAMERA_AF_TOUCH_X
873 X coordinate of touching position
878 #MMCAM_CAMERA_AF_TOUCH_Y
881 Y coordinate of touching position
886 #MMCAM_CAMERA_AF_TOUCH_WIDTH
889 Width of touching area
894 #MMCAM_CAMERA_AF_TOUCH_HEIGHT
897 Height of touching area
902 #MMCAM_CAMERA_EXPOSURE_MODE
910 #MMCAM_CAMERA_EXPOSURE_VALUE
918 #MMCAM_CAMERA_F_NUMBER
926 #MMCAM_CAMERA_SHUTTER_SPEED
937 ISO of capturing image
950 #MMCAM_CAMERA_ANTI_HANDSHAKE
958 #MMCAM_CAMERA_FOCAL_LENGTH
961 Focal length of camera lens
966 #MMCAM_FILTER_BRIGHTNESS
974 #MMCAM_FILTER_CONTRAST
990 #MMCAM_FILTER_COLOR_TONE
993 Color tone (Color effect)
998 #MMCAM_FILTER_SCENE_MODE
1001 Scene mode (Program mode)
1006 #MMCAM_FILTER_SATURATION
1022 #MMCAM_FILTER_SHARPNESS
1030 #MMCAM_CAPTURE_BREAK_CONTINUOUS_SHOT
1033 Set this as true when you want to stop multishot immediately
1038 #MMCAM_DISPLAY_RECT_X
1041 X position of display rectangle ( This is only available when MMCAM_DISPLAY_GEOMETRY_METHOD is MM_CAMCORDER_CUSTOM_ROI )
1046 #MMCAM_DISPLAY_RECT_Y
1049 Y position of display rectangle ( This is only available when MMCAM_DISPLAY_GEOMETRY_METHOD is MM_CAMCORDER_CUSTOM_ROI )
1054 #MMCAM_DISPLAY_RECT_WIDTH
1057 Width of display rectangle ( This is only available when MMCAM_DISPLAY_GEOMETRY_METHOD is MM_CAMCORDER_CUSTOM_ROI )
1062 #MMCAM_DISPLAY_RECT_HEIGHT
1065 Height of display rectangle ( This is only available when MMCAM_DISPLAY_GEOMETRY_METHOD is MM_CAMCORDER_CUSTOM_ROI )
1073 Enable to write tags ( If this value is FALSE, none of tag information will be written to captured file )
1078 #MMCAM_TAG_IMAGE_DESCRIPTION
1086 #MMCAM_TAG_ORIENTATION
1089 Orientation of captured image
1097 software name and version
1105 Latitude of captured postion ( GPS information )
1110 #MMCAM_TAG_LONGITUDE
1113 Longitude of captured postion ( GPS information )
1121 Altitude of captured postion ( GPS information )
1126 #MMCAM_STROBE_CONTROL
1137 Operation Mode of strobe
1150 #MMCAM_DETECT_NUMBER
1153 Total number of detected object
1158 #MMCAM_DETECT_FOCUS_SELECT
1161 Select one of detected objects
1166 @defgroup Camcorder_uc1 Initialize Camcorder for Image capture
1167 @ingroup Camcorder_UC
1170 <h2 class="pg">Initialize Camcorder for Image capture </h2>
1173 - Start preview for capturing image
1177 The camcorder module is initialized for Image capture by using the following steps:
1179 -# Create the camcorder handle using mm_camcorder_create().
1180 -# Set message callback. Message callback is a handler for camcorder message. If camcorder is trying to deliever a certain signal that happens on runtime, it uses this method. For more detail information, refer "Set Message Callback"
1181 -# Set video capture callback. Video capture callback is a handler for the captured image. This is the only method to deliever the image. (Do not use 'MMCAM_TARGET_FILENAME' for image capturing. It can't handle multishot.) For more detail information, refer "Set VideoCapture Callback"
1182 -# Set various attributes using mm_camcorder_set_attributes(). You can set as many attributes as you want. If you don't set any attributes, it will operate with the default values. But as a minimum, you have to set 'MMCAM_DISPLAY_HANDLE'. This is the attribute to deliever display pointer or index, such as xid of x window. So if you don't set this, there is no way to display the image.
1183 -# Allocate resources (memory, device node, etc) for camcorder handle using mm_camcorder_realize().
1184 -# Start receiving input video stream (previewing) calling mm_camcorder_start().
1188 The following is a sample code:
1191 MMHandleType hcam = 0;
1202 static gboolean initialize_image_capture()
1208 MMCamPreset cam_info;
1210 char *err_attr_name = NULL;
1212 void * hdisplay = NULL;
1218 cam_info.videodev_type = MM_VIDEO_DEVICE_CAMERA0;
1220 err = mm_camcorder_create(&hcam, &cam_info);
1224 if (err != MM_ERROR_NONE)
1228 printf("Fail to call mm_camcorder_create = %x\n", err);
1236 mm_camcorder_set_message_callback(hcam,(MMMessageCallback)msg_callback, (void*)hcam);
1238 mm_camcorder_set_video_capture_callback(hcam,(mm_camcorder_video_capture_callback)camcordertest_video_capture_cb, (void*)hcam);
1244 hsize = sizeof(ad.xid);
1248 // camcorder attribute setting
1250 err = mm_camcorder_set_attributes((MMHandleType)hcam, &err_attr_name,
1252 MMCAM_MODE, MM_CAMCORDER_MODE_IMAGE,
1254 MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG,
1256 MMCAM_CAMERA_WIDTH, 640,
1258 MMCAM_CAMERA_HEIGHT, 480,
1260 MMCAM_CAMERA_FORMAT, MM_PIXEL_FORMAT_YUYV,
1262 MMCAM_CAMERA_FPS, 30,
1264 MMCAM_DISPLAY_ROTATION, MM_DISPLAY_ROTATION_270,
1266 MMCAM_DISPLAY_HANDLE, (void*) hdisplay, hsize,
1268 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
1270 MMCAM_CAPTURE_WIDTH, 640,
1272 MMCAM_CAPTURE_HEIGHT, 480,
1282 printf("Set attrs fail. (%s:%x)\n", err_attr_name, err);
1284 if (err_attr_name) {
1286 free(err_attr_name);
1288 err_attr_name = NULL;
1298 err = mm_camcorder_realize(hcam);
1304 printf("Fail to call mm_camcorder_realize = %x\n", err);
1314 err = mm_camcorder_start(hcam);
1320 printf("Fail to call mm_camcorder_start = %x\n", err);
1334 Basically, you can check the return value to determine whether the function succeeded. But camcorder is composed of several thread context. So you have to check error code delievered by the message callback as well. It will notify you of errors that happened in other asynchronous contexts.
1337 @defgroup Camcorder_uc2 Initialize Camcorder for Video capture
1338 @ingroup Camcorder_UC
1341 <h2 class="pg">Initialize Camcorder for Video capture</h2>
1343 - Start preview for video recording
1347 Everything is the same with "Initialize Camcorder for Image capture" except for two things:
1349 -# You don't need to set 'mm_camcorder_set_video_capture_callback' because the function is for capturing image.
1350 -# Set different attributes. For example, you have to specify types of encoder for audio and video, types of fileformat (this will define muxer). You should also define detail settings of video and audio input. Set proper filename to 'MMCAM_TARGET_FILENAME', too.
1356 The following is a sample code:
1359 MMHandleType hcam = 0;
1370 static gboolean initialize_video_capture()
1376 MMCamPreset cam_info;
1378 char *err_attr_name = NULL;
1380 void * hdisplay = NULL;
1386 cam_info.videodev_type = MM_VIDEO_DEVICE_CAMERA0;
1388 err = mm_camcorder_create(&hcam, &cam_info);
1390 if (err != MM_ERROR_NONE)
1393 printf("Fail to call mm_camcorder_create = %x\n", err);
1401 mm_camcorder_set_message_callback(hcam,(MMMessageCallback)msg_callback, hcam);
1407 hsize = sizeof(ad.xid);
1411 // camcorder attribute setting
1413 err = mm_camcorder_set_attributes((MMHandleType)hcam, &err_attr_name,
1415 MMCAM_MODE, MM_CAMCORDER_MODE_VIDEO,
1417 MMCAM_AUDIO_DEVICE, MM_AUDIO_DEVICE_MIC,
1419 MMCAM_AUDIO_ENCODER, MM_AUDIO_CODEC_AAC,
1421 MMCAM_VIDEO_ENCODER, MM_VIDEO_CODEC_MPEG4,
1423 MMCAM_FILE_FORMAT, MM_FILE_FORMAT_3GP,
1425 MMCAM_CAMERA_WIDTH, 1280,
1427 MMCAM_CAMERA_HEIGHT, 720,
1429 MMCAM_CAMERA_FORMAT, MM_PIXEL_FORMAT_NV12,
1431 MMCAM_CAMERA_FPS, 30,
1433 MMCAM_AUDIO_SAMPLERATE, 44100,
1435 MMCAM_AUDIO_FORMAT, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE,
1437 MMCAM_AUDIO_CHANNEL, 2,
1439 MMCAM_AUDIO_INPUT_ROUTE, MM_AUDIOROUTE_CAPTURE_NORMAL,
1441 MMCAM_DISPLAY_ROTATION, MM_DISPLAY_ROTATION_270,
1443 MMCAM_DISPLAY_HANDLE, (void*) hdisplay, hsize,
1445 MMCAM_TARGET_FILENAME, TARGET_FILENAME, strlen(TARGET_FILENAME),
1455 printf("Set attrs fail. (%s:%x)\n", err_attr_name, err);
1457 if (err_attr_name) {
1459 free(err_attr_name);
1461 err_attr_name = NULL;
1471 err = mm_camcorder_realize(hcam);
1477 printf("Fail to call mm_camcorder_realize = %x\n", err);
1487 err = mm_camcorder_start(hcam);
1493 printf("Fail to call mm_camcorder_start = %x\n", err);
1507 @defgroup Camcorder_uc3 Initialize Camcorder for Audio capture
1508 @ingroup Camcorder_UC
1511 <h2 class="pg">Initialize Camcorder for Audio capture</h2>
1513 - Prepare for audio recording
1515 Everything is the same with "Initialize Camcorder for Video capture" except for attributes settings:
1516 -# In this case, you don't need to set video information.
1520 The following is a sample code:
1523 MMHandleType hcam = 0;
1534 static gboolean initialize_audio_capture()
1540 MMCamPreset cam_info;
1542 char *err_attr_name = NULL;
1544 void * hdisplay = NULL;
1550 cam_info.videodev_type = MM_VIDEO_DEVICE_NONE;
1554 err = mm_camcorder_create(&hcam, &cam_info);
1558 if (err != MM_ERROR_NONE)
1562 printf("Fail to call mm_camcorder_create = %x\n", err);
1570 mm_camcorder_set_message_callback(hcam,(MMMessageCallback)msg_callback, (void*)hcam);
1576 hsize = sizeof(ad.xid);
1580 // camcorder attribute setting
1582 err = mm_camcorder_set_attributes((MMHandleType)hcam, &err_attr_name,
1584 MMCAM_MODE, MM_CAMCORDER_MODE_AUDIO,
1586 MMCAM_AUDIO_DEVICE, MM_AUDIO_DEVICE_MIC,
1588 MMCAM_AUDIO_ENCODER, MM_AUDIO_CODEC_AAC,
1590 MMCAM_FILE_FORMAT, MM_FILE_FORMAT_3GP,
1592 MMCAM_AUDIO_SAMPLERATE, 44100,
1594 MMCAM_AUDIO_FORMAT, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE,
1596 MMCAM_AUDIO_CHANNEL, 2,
1598 MMCAM_AUDIO_INPUT_ROUTE, MM_AUDIOROUTE_CAPTURE_NORMAL,
1600 MMCAM_TARGET_FILENAME, TARGET_FILENAME, strlen(TARGET_FILENAME),
1602 MMCAM_TARGET_TIME_LIMIT, 360000,
1612 printf("Set attrs fail. (%s:%x)\n", err_attr_name, err);
1614 if (err_attr_name) {
1616 free(err_attr_name);
1618 err_attr_name = NULL;
1628 err = mm_camcorder_realize(hcam);
1634 printf("Fail to call mm_camcorder_realize = %x\n", err);
1644 err = mm_camcorder_start(hcam);
1650 printf("Fail to call mm_camcorder_start = %x\n", err);
1664 @defgroup Camcorder_uc4 Uninitialize camcorder
1665 @ingroup Camcorder_UC
1668 <h2 class="pg">Uninitialize camcorder</h2>
1670 - Destory camcorder handle and resources
1672 - Preliminary condition
1673 - Camcorder is lauched for Image capture, Video capture, or Audio capture.
1677 The initialized camcorder is uninitialized by using the following steps:
1678 -# Stop receiving the video input stream using mm_camcorder_stop(). In audio capture mode, it will stop pipeline itself.
1679 -# Free the allocated memory and release devices calling mm_camcorder_unrealize().
1680 -# Destroy the camcorder handle instance using mm_camcorder_destroy().
1684 The following is a sample code:
1687 static gboolean uninitialize_camcorder()
1695 err = mm_camcorder_stop(hcam);
1701 printf("Fail to call mm_camcorder_stop = %x\n", err);
1709 err = mm_camcorder_unrealize(hcam);
1715 printf("Fail to call mm_camcorder_unrealize = %x\n", err);
1723 err = mm_camcorder_destroy(hcam);
1729 printf("Fail to call mm_camcorder_destroy = %x\n", err);
1742 @defgroup Camcorder_uc5 Capturing Picture
1743 @ingroup Camcorder_UC
1746 <h2 class="pg">Capturing Picture</h2>
1748 - Capturing still image
1750 - Preliminary condition
1751 - Camcorder is launched for Image capture mode. Refer to "Initialize Camcorder for Image capture".
1754 -# Initialize camcorder for image capture as explained in "Initialize Camcorder for Image capture".
1755 -# Start capturing the still image using mm_camcorder_capture_start(). The status of the camcorder is changed to 'MM_CAMCORDER_STATE_CAPTURING' after success.
1756 -# You can stop capturing the still image using mm_camcorder_capture_stop(). But do not call mm_camcorder_capture_stop(), just after calling mm_camcorder_capture_start(). Because captured image is retrieved asynchronously, you can call mm_camcorder_capture_stop() after receiving the 'MM_MESSAGE_CAMCORDER_CAPTURE' message.
1757 -# Beware! Since message callback of camcorder is operated on main loop of the application, you shouldn't hold main loop when you are waiting for the message 'MM_MESSAGE_CAMCORDER_CAPTURED'.
1758 -# Recommended implementation is
1759 -# Just call mm_camcorder_capture_start() and return
1760 -# Wait for capture callback that you registered (the callback function that you set to 'mm_camcorder_set_video_capture_callback')
1761 -# Wait for 'MM_MESSAGE_CAMCORDER_CAPTURED' message
1762 -# Then call mm_camcorder_capture_stop() in the context of the message or another idle callback.
1763 -# Uninitialize camcorder as explained in "Uninitialize camcorder"
1767 The following is a sample code:
1770 static gboolean capturing_picture()
1778 err = mm_camcorder_capture_start(hcam);
1784 printf("Fail to call mm_camcorder_capture_start = %x\n", err);
1792 // mm_camcorder_capture_stop should be called after getting the message
1793 // - MM_MESSAGE_CAMCORDER_CAPTURED message
1802 Handling for captured message, please refer to the callback function of "Set Message Callback".
1805 @defgroup Camcorder_uc6 Record and Save a Audio/Video file or a Audio only file
1806 @ingroup Camcorder_UC
1809 <h2 class="pg">Record and Save a Audio/Video file or a Audio only file</h2>
1811 - Start recording and save the file
1813 - Preliminary condition
1814 - Camcorder is launched for Video capture mode. (Refer "Initialize Camcorder for Video capture".)
1815 - Or Camcorder is launched for Audio capture mode. (Refer "Initialize Camcorder for Video capture".)
1819 A video is recorded and saved by camcorder by using the following steps:
1820 -# Initialize camcorder for video capture or audio capture
1821 -# Start audio/video recording using mm_camcorder_record().
1822 -# Save the recorded Video file using mm_camcorder_commit().
1823 -# Uninitialize camcorder. Refer "Uninitialize camcorder".
1825 The procedure of "Audio recording" and "Audio/Video recording" is just same except for settings for video related attributes.
1829 The following is a sample code:
1832 static gboolean record_and_save_video_file()
1842 err = mm_camcorder_record(hcam);
1848 printf("Fail to call mm_camcorder_record = %x\n", err);
1855 // Wait while recording
1861 err = mm_camcorder_commit(hcam);
1867 printf("Fail to call mm_camcorder_commit = %x\n", err);
1880 In the above example code, MMCamcorderRecord and MMCamcorderCommit will return immediately, but whether the video is captured and saved successfully or not is known through a callback function which is set using the API MMCamcorderSetMessageCallback.
1884 @defgroup Camcorder_uc7 Record and Cancel saving of a recording file
1885 @ingroup Camcorder_UC
1887 <h2 class="pg">Record and Cancel saving of a recording file</h2>
1889 - Cancel the operation while recording.
1891 - Preliminary condition
1892 - Camcorder is launched for Video capture mode. (Refer "Initialize Camcorder for Video capture".)
1893 - Or Camcorder is launched for Audio capture mode. (Refer "Initialize Camcorder for Video capture".)
1897 A video is recorded and not saved by camcorder by using the following steps:
1898 -# Initialize camcorder for video capture or audio capture
1899 -# Start audio/video recording using mm_camcorder_record().
1900 -# Cancel saving the recorded Video file using mm_camcorder_cancel().
1901 -# Uninitialize camcorder. Refer "Uninitialize camcorder".
1905 The following is a sample code:
1909 static gboolean record_and_cancel_video_file()
1919 err = mm_camcorder_record(hcam);
1925 printf("Fail to call mm_camcorder_record = %x\n", err);
1932 // Wait while recording
1938 err = mm_camcorder_cancel(hcam);
1944 printf("Fail to call mm_camcorder_cancel = %x\n", err);
1958 @defgroup Camcorder_uc8 Record, Pause and resume recording
1959 @ingroup Camcorder_UC
1962 <h2 class="pg">Record, Pause and resume recording</h2>
1964 - Pause and Resume operation while recording
1966 - Preliminary condition
1967 - Camcorder is launched for Video capture mode. (Refer "Initialize Camcorder for Video capture".)
1968 - Or Camcorder is launched for Audio capture mode. (Refer "Initialize Camcorder for Video capture".)
1971 Recording, pausing and resuming recording of a video file is accomplished by using the following steps:
1972 -# Initialize camcorder for video capture or audio capture
1973 -# Start recording calling mm_camcorder_record().
1974 -# Pause recording. mm_camcorder_pause().
1975 -# When you want to resume recording, call mm_camcorder_record again.
1976 -# Save the recorded file. mm_camcorder_commit().
1977 -# Uninitialize camcorder. Refer "Uninitialize camcorde".
1980 The following is a sample code:
1983 static gboolean record_pause_and_resume_recording()
1993 err = mm_camcorder_record(hcam);
1999 printf("Fail to call mm_camcorder_record = %x\n", err);
2006 // Wait while recording
2012 err = mm_camcorder_pause(hcam);
2018 printf("Fail to call mm_camcorder_pause = %x\n", err);
2030 err = mm_camcorder_record(hcam);
2036 printf("Fail to call mm_camcorder_record = %x\n", err);
2043 // Wait while recording
2049 err = mm_camcorder_commit(hcam);
2055 printf("Fail to call mm_camcorder_commit = %x\n", err);
2069 Even though recording is paused, preview is continuously displayed.
2072 @defgroup Camcorder_uc9 Get state of camcorder
2073 @ingroup Camcorder_UC
2076 <h2 class="pg">Get state of camcorder</h2>
2078 - Get the current state of camcorder
2080 If handle is available, you can get the current status of camcorder using mm_camcorder_get_state()
2082 The following is a sample code:
2085 static gboolean get_state_of_camcorder()
2089 MMCamcorderStateType state;
2093 mm_camcorder_get_state(hcam, &state);
2095 printf("Current status is %d\n", state);
2105 @defgroup Camcorder_uc10 Start and Stop focus
2106 @ingroup Camcorder_UC
2110 <h2 class="pg">Start and Stop focus</h2>
2114 - Preliminary condition
2115 - Camcorder is launched for Image or Video capture mode. Refer "Initialize Camcorder for Image capture" and "Initialize Camcorder for Video capture".
2119 Starting and Stopping focus feature of camcorder:
2120 -# Initialize camcorder for image or video capture as explained in "Initialize Camcorder for Video capture" or "Initialize Camcorder for Image capture".
2121 -# Set proper focusing mode using attribute 'MMCAM_CAMERA_FOCUS_MODE' and 'MMCAM_CAMERA_AF_SCAN_RANGE'.
2122 -# Initialize auto focus mode and adjust the camera lens to initial position using mm_camcorder_init_focusing().
2123 -# Start focusing of camcorder using mm_camcorder_start_focusing().
2124 -# Focusing state will be sent through message callback. (MM_MESSAGE_CAMCORDER_FOCUS_CHANGED)
2125 -# If you want to stop focusing immediately, call mm_camcorder_stop_focusing().
2126 -# But in general case, you don't need to call this. Just wait the message.
2127 -# Uninitialize camcorder. Refer "Uninitialize camcorder".
2130 The following is a samsple code
2133 static gboolean start_autofocus()
2139 char * err_attr_name = NULL;
2143 // Set focus mode to 'AUTO' and scan range to 'AF Normal'
2145 err = mm_camcorder_set_attributes((MMHandleType)hcam, &err_attr_name,
2147 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO,
2149 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
2159 printf("Set attrs fail. (%s:%x)\n", err_attr_name, err);
2161 if (err_attr_name) {
2163 free(err_attr_name);
2165 err_attr_name = NULL;
2173 mm_camcorder_init_focusing(hcam);
2175 mm_camcorder_start_focusing(hcam);
2177 printf("Waiting for adjusting focus\n");
2181 // Waiting for 'MM_MESSAGE_CAMCORDER_FOCUS_CHANGED'
2191 @defgroup Camcorder_uc11 User defined filename for recording file
2192 @ingroup Camcorder_UC
2195 <h2 class="pg">User defined filename for recording file</h2>
2197 To Save an video or audio captured file with user defined name, you have to set an attribute named 'MMCAM_TARGET_FILENAM'.
2199 In image capture mode, there is no interface to set the name of captured file because camcorder gives you a captured buffer directly. You can create an image file with proper name in the application.
2202 The following is a samsple code
2205 static gboolean filename_setting()
2211 char * new_filename = "new_name.mp4";
2215 // camcorder attribute setting
2217 err = mm_camcorder_set_attributes((MMHandleType)hcam, NULL,
2219 MMCAM_TARGET_FILENAME, new_filename, strlen(new_filename),
2225 printf("New file name (%s)\n", new_filename);
2234 @defgroup Camcorder_uc12 Set VideoStream Callback
2235 @ingroup Camcorder_UC
2238 <h2 class="pg">Set VideoStream Callback</h2>
2240 MMCamcorderSetVideoStreamCallback API is used to set callback for receiving video stream data (preview) from the camcorder.
2244 The following is a sample code:
2247 static gboolean set_video_stream_callback()
2251 mm_camcorder_set_video_stream_callback(hcam, (mm_camcorder_video_stream_callback)camcordertest_video_stream_cb, (void*)hcam);
2261 camcordertest_video_stream_cb(MMCamcorderVideoStreamDataType *stream, void *user_param)
2269 printf("stream cb is called(%p, %d, %d)\n", stream->data, stream->width, stream->height);
2279 @defgroup Camcorder_uc13 Set VideoCapture Callback
2280 @ingroup Camcorder_UC
2283 <h2 class="pg">Set VideoCapture Callback</h2>
2285 mm_camcorder_set_video_capture_callback() is used to set callback for receiving still capture data from the camcorder. In here, you can handle the result data.
2288 The following is a sample code:
2291 mm_camcorder_set_video_capture_callback(hcam,(mm_camcorder_video_capture_callback)
2293 camcordertest_video_capture_cb, (void*)hcam);
2298 camcordertest_video_capture_cb(MMCamcorderCaptureDataType *src, MMCamcorderCaptureDataType *thumb, void *preview)
2304 char m_filename[MAX_STRING_LEN];
2310 sprintf(m_filename, "%s%03d.jpg", "./stillshot_", stillshot_count++);
2314 printf("filename : %s\n", m_filename);
2318 fp=fopen(m_filename, "w+");
2324 printf("FileOPEN error!!\n");
2334 printf("open success\n\n");
2336 if(fwrite(src->data, src->length, 1, fp )!=1)
2340 printf("File write error!!\n");
2346 printf("write success\n");
2352 printf("Capture done!\n");
2362 @defgroup Camcorder_uc14 Set Message Callback
2363 @ingroup Camcorder_UC
2366 <h2 class="pg">Set Message Callback</h2>
2368 The following is a sample code:
2370 mm_camcorder_set_message_callback(hcam,(MMMessageCallback)msg_callback, (void*)hcam);
2373 The following code snippet explains the callback function for 'MMMessageCallback':
2374 - First argument gives the index of the message. You can handle each message with the value.
2375 - Second argument has a parameter structure that holds useful values for application. The original parameter type is 'MMMessageParamType'.
2376 - It has several fields for message including union structure. By checking 'union_type' field, you can determine which type of union is used. For the type of union, refer 'MMMessageUnionType' in 'mm_types.h'.
2377 - One message type only has one specific union in anycase. Please refer following table
2383 MM_MESSAGE_CAMCORDER_STATE_CHANGED
2391 MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM
2399 MM_MESSAGE_CAMCORDER_RECORDING_STATUS
2402 MM_MSG_UNION_RECORDING_STATUS
2407 MM_MESSAGE_CAMCORDER_FIRMWARE_UPDATE
2410 MM_MSG_UNION_FIRMWARE
2415 MM_MESSAGE_CAMCORDER_TIME_LIMIT
2423 MM_MESSAGE_CAMCORDER_MAX_SIZE
2431 MM_MESSAGE_CAMCORDER_NO_FREE_SPACE
2439 MM_MESSAGE_CAMCORDER_ERROR
2447 MM_MESSAGE_CAMCORDER_FOCUS_CHANGED
2455 MM_MESSAGE_CAMCORDER_CURRENT_VOLUME
2463 MM_MESSAGE_CAMCORDER_CAPTURED
2471 MM_MESSAGE_READY_TO_RESUME
2479 - 'MM_MESSAGE_READY_TO_RESUME' is a message type that notifies that the camcorder is able to start again after being halting by internal session manager.
2482 static gboolean msg_callback(int message, void *msg_param, void *user_param)
2486 MMHandleType hcamcorder = (MMHandleType)user_param;
2488 MMMessageParamType *param = (MMMessageParamType *) msg_param;
2496 case MM_MESSAGE_CAMCORDER_ERROR:
2498 printf("MM_MESSAGE_CAMCORDER_ERROR : code = %x\n", param->code);
2502 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
2504 g_current_state = param->state.current;
2510 case MM_MESSAGE_CAMCORDER_CAPTURED:
2514 //Get mode of camcorder
2518 err = mm_camcorder_get_attributes(hcamcorder, NULL,
2526 if (mode == MM_CAMCORDER_MODE_IMAGE)
2530 printf("Stillshot Captured!!(number=%d)\n", param->code);
2534 err = mm_camcorder_capture_stop(hcam);
2540 printf("Fail to call mm_camcorder_capture_start= %x\n", err);
2552 //Audio/Video recording
2554 MMCamRecordingReport* report ;
2560 report = (MMCamRecordingReport*)(param->data);
2568 printf("Recording Complete(filename=%s)\n", report->recording_filename);
2572 if (report->recording_filename)
2574 free(report->recording_filename);
2588 case MM_MESSAGE_CAMCORDER_RECORDING_STATUS:
2592 unsigned int elapsed;
2594 elapsed = param->recording_status.elapsed / 1000;
2596 if (elapsed_time != elapsed) {
2598 unsigned int temp_time;
2600 int hour, minute, second;
2602 elapsed_time = elapsed;
2604 temp_time = elapsed;
2606 hour = temp_time / 3600;
2608 temp_time = elapsed % 3600;
2610 minute = temp_time / 60;
2612 second = temp_time % 60;
2614 printf("Current Time - %d:%d:%d\n", hour, minute, second);
2622 case MM_MESSAGE_CAMCORDER_MAX_SIZE:
2626 printf("Reach Size limitation.\n");
2630 // After reaching max size, Camcorder starts to drop all buffers that
2632 it receives. You have to call mm_camcorder_commit() to finish recording.
2634 err = mm_camcorder_commit(hcamcorder);
2642 printf("Save recording mm_camcorder_commit = %x\n", err);
2650 case MM_MESSAGE_CAMCORDER_NO_FREE_SPACE:
2654 printf("There is no space in storage.\n");
2658 // If there is no free space to save recording frame, Camcorder starts to
2660 drop all buffers that it receives.
2662 You have to call mm_camcorder_commit() to finish recording.
2664 err = mm_camcorder_commit(hcamcorder);
2672 printf("Save recording mm_camcorder_commit = %x\n", err);
2680 case MM_MESSAGE_CAMCORDER_TIME_LIMIT:
2684 printf("Reach time limitation.\n");
2688 // After reaching time limit, Camcorder starts to drop all buffers that it
2690 receives. You have to call mm_camcorder_commit() to finish recording.
2692 err = mm_camcorder_commit(hcamcorder);
2700 printf("Save recording mm_camcorder_commit = %x\n", err);
2708 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED:
2712 printf( "Focus State changed. State:[%d]\n", param->code );
2733 @defgroup MM_Player Player
2734 @ingroup MultiMediaPG
2737 <h2 class="pg">Player</h2>
2738 @brief <sub class="ref">Also see</sub> Use Cases of @ref Player_UC
2740 This section describes APIs used for playback of multimedia contents.
2744 Player can have 5 states, and each state can be changed by calling the following functions as described in "State of mm_player" diagram.
2752 <b>PRE-STATE</b><b></b>
2754 <b>POST-STATE</b><b></b>
2759 <p>mm_player_create()
2768 <p>mm_player_destroy()
2777 <p>mm_player_realize()
2786 <p>mm_player_unrealize()
2795 <p>mm_player_start()
2813 <p>mm_player_pause()
2822 <p>mm_player_resume()
2832 @image html SLP_MultimediaFW_PG_image003.png
2833 Figure. State of MMPlayer
2837 Most of functions which change player state work as synchronous . But, mm_player_start() should be used asynchronously. Both mm_player_pause() and mm_player_resume() should also be used asynchronously in the case of streaming data. So, application has to confirm the result through message callback function.
2841 Note: "None" and "Null" state could be reached from any state by calling mm_player_destroy() and mm_player_unrealize().
2844 The following are supported functions in the player module.
2845 - int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
2846 - int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
2847 - int mm_player_get_mute(MMHandleType player, int *mute)
2848 - int mm_player_set_mute(MMHandleType player, int mute)
2849 - int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
2850 - int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int *pos)
2851 - int mm_player_activate_section_repeat(MMHandleType player)
2852 - int mm_player_deactivate_section_repeat(MMHandleType player, int start, int end)
2853 - int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
2854 - int mm_player_set_subtitle_silent(MMHandleType player, int slient)
2855 - int mm_player_get_subtitle_silent(MMHandleType player, int *slient)
2856 - int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
2857 - int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
2858 - int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
2862 Application can set/get some values into player library for applying its properties using attributes.
2866 The following are supported attributes list of player library.
2868 - For more detail information, please refer the doxygen document of player framework.
2873 <td><b>Attribute Name</b>
2877 <b>Validity Type</b>
2879 <b>Default Value</b>
2887 "profile_user_param" <td>
2892 "profile_play_count" <td>
2897 "streaming_type" <td>
2900 STREAMING_SERVICE_NONE <tr>
2902 "streaming_udp_timeout" <td>
2907 "streaming_user_agent" <td>
2912 "streaming_wap_profile" <td>
2917 "streaming_network_bandwidth" <td>
2922 "streaming_cookie" <td>
2927 "streaming_proxy_ip" <td>
2932 "streaming_proxy_port" <td>
2937 "display_overlay" <td>
2942 "display_rotation" <td>
2945 MM_DISPLAY_ROTATION_270 <tr>
2952 "content_duration" <td>
2957 "content_video_codec" <td>
2962 "content_video_bitrate" <td>
2967 "content_video_fps" <td>
2972 "content_video_width" <td>
2977 "content_video_height" <td>
2982 "content_video_track_id" <td>
2987 "content_video_track_num" <td>
2992 "content_audio_codec" <td>
2997 "content_audio_bitrate" <td>
3002 "content_audio_channels" <td>
3007 "content_audio_samplerate" <td>
3012 "content_audio_track_id" <td>
3017 "content_audio_track_num" <td>
3047 "tag_copyright" <td>
3057 "tag_description" <td>
3062 "tag_track_num" <td>
3070 @defgroup Player_uc1 Create and initialize Player
3073 <h2 class="pg">Create and initialize Player</h2>
3074 - Applications can create the player handle using mm_player_create().
3075 - And then, attributes for the player such as the url can be set through mm_player_set_attribute() .
3076 - Fundamentally, one url should be set to play both audio and video contents.
3077 - The created window id should be set to display video using the "display_overlay" attribute.
3078 - All messages are sent through message callback functions to the application from the player.
3079 - So, callback functions should be set to receive messages like error, BOS(Begin Of Stream) and EOS(End Of Stream)
3080 - Player is a pipelined architecture and basic pipeline is made when mm_player_realize() is called.
3081 - The following is a sample code to create, realize player and set the url and display id.
3084 MMHandleType g_player = 0;
3085 char **g_err_attr_name;
3088 int ret = MM_ERROR_NONE;
3090 int initialize_video_player(char *filename)
3092 if (mm_player_create(&g_player) != MM_ERROR_NONE)
3094 printf("failed to create player\n");
3097 if (mm_player_set_attribute(g_player,
3099 "profile_uri", filename, strlen(filename),
3100 "display_overlay", (void*)&ad.xid, sizeof(ad.xid),
3101 NULL) != MM_ERROR_NONE)
3103 printf("failed to set %s attribute\n", *g_err_attr_name);
3104 free(g_err_attr_name);
3107 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
3109 if (mm_player_realize(g_player) != MM_ERROR_NONE)
3111 printf("failed to realize player\n");
3115 int msg_callback(int message, MMMessageParamType *param, void *user_param)
3119 case MM_MESSAGE_ERROR:
3123 case MM_MESSAGE_END_OF_STREAM:
3127 case MM_MESSAGE_STATE_CHANGED:
3131 case MM_MESSAGE_BEGIN_OF_STREAM:
3143 Set message callback
3145 - The application must confirm some information or player status from messages of callback. It must be registered before beginning playback.
3147 - The Followings messages are typically used
3151 <tr> <td> MM_MESSAGE_ERROR </td> </tr>
3152 <tr> <td> MM_MESSAGE_STATE_CHANGED </td> </tr>
3153 <tr> <td>MM_MESSAGE_BEGIN_OF_STREAM </td> </tr>
3154 <tr> <td>MM_MESSAGE_END_OF_STREAM </td> </tr>
3155 <tr> <td>MM_MESSAGE_UPDATE_SUBTITLE </td> </tr>
3156 <tr> <td>MM_MESSAGE_BUFFERING </td> </tr>
3162 - In the case of MM_MESSAGE_ERROR, application can determine the specific error case from the code value of message parameter.
3164 - The Followings error codes are typically used.
3169 <tr> <td>MM_ERROR_PLAYER_INTERNAL </td> </tr>
3170 <tr> <td>MM_ERROR_PLAYER_CODEC_NOT_FOUND </td> </tr>
3171 <tr> <td>MM_ERROR_PLAYER_NOT_SUPPORTED_FORMAT </td> </tr>
3172 <tr> <td>MM_ERROR_PLAYER_NOT_INITIALIZED </td> </tr>
3173 <tr> <td>MM_ERROR_PLAYER_FILE_NOT_FOUND </td> </tr>
3177 - Refer to the appendix for more message and error details
3179 - The following is a sample code of message callback implementation.
3182 void video_player_message_callback(int message, void *param, void *user_param)
3184 struct appdata *ad = (struct appdata *)user_param;
3185 MMMessageParamType* msg_param = (MMMessageParamType*)param;
3189 case MM_MESSAGE_ERROR:
3190 parse_video_player_error_code(msg_param->code, ad);
3193 case MM_MESSAGE_BEGIN_OF_STREAM:
3194 // can update video player UI
3197 case MM_MESSAGE_END_OF_STREAM:
3198 // can close and destroy the player
3199 ecore_idler_add(video_player_close_handler, ad);
3209 void parse_video_player_error_code(int error_code, struct appdata *app_data)
3213 case MM_ERROR_PLAYER_CODEC_NOT_FOUND:
3214 // can show up error popup
3217 case MM_ERROR_PLAYER_INTERNAL:
3218 // can show up error popup and close player
3219 ecore_idler_add(video_player_close_handler, app_data);
3229 int video_player_close_handler (void *data)
3231 struct appdata *ad = (struct appdata *)data;
3233 close_video_player (ad);
3237 bool close_video_player (void *data)
3239 struct appdata *ad = (struct appdata *)data;
3241 video_player_mgr_unrealize(ad);
3242 video_player_mgr_destroy(ad);
3245 bool video_player_mgr_unrealize (void *data)
3247 struct appdata *ad = (struct appdata *)data;
3249 if (mm_player_unrealize(ad->player_handle) != MM_ERROR_NONE)
3255 bool video_player_mgr_destroy (void *data)
3257 struct appdata *ad = (struct appdata *)data;
3259 if (mm_player_destroy(ad-> player_handle) != MM_ERROR_NONE)
3266 @defgroup Player_uc2 Get and set attributes
3270 <h2 class="pg">Get and set attributes</h2>
3272 - There are many useful attributes in the player which the Application can set or get to control the player.
3273 - Those are constructed when the player is created and handled by string id.
3274 - Supported types are int, double, string and data. And, there is variable parameter in related APIs.
3275 - In the case of the int and double types, a name/value pair should be set. For the string and data types, the name/value pair should be followed by the size.
3276 - Finally, application can get the information of each attribute using mm_player_get_attribute_info().
3277 - The following is a sample code.
3280 /***********************
3281 // get content duration
3282 /***********************
3287 char **g_err_attr_name;
3289 if (mm_player_get_attribute(g_player, &g_err_attr_name, "content_duration", &duration, NULL) != MM_ERROR_NONE)
3291 printf("failed to set %s attribute\n", *g_err_attr_name);
3292 free(g_err_attr_name);
3296 pirntf("file duration is = %d\n", duration);
3300 /***********************
3301 // set content duration
3302 /***********************
3305 char **g_err_attr_name;
3307 if (mm_player_get_attribute(g_player, &g_err_attr_name, "content_duration", &duration, NULL) != MM_ERROR_NONE)
3309 printf("failed to set %s attribute\n", g_err_attr_name);
3310 free(g_err_attr_name);
3313 pirntf("duration is = %d\n", duration);
3315 /***********************
3316 // get attribute info
3317 /***********************
3321 MMPlayerAttrsInfo method_info = { 0, };
3323 if (mm_player_get_attribute_info (g_player, "display_method", &method_info, NULL) != MM_ERROR_NONE)
3325 printf("failed to get info \n");
3328 printf("type:%d \n", method_info.type); // int, double
3329 printf("flag:%d \n", method_info.flag); // readable, writable..
3330 printf("validity type:%d \n", method_info.validity_type);//range, array..
3332 if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE)
3334 printf("range min=%d\n", method_info.int_range.min );
3335 printf("range max=%\n", method_info.int_range.max );
3340 @defgroup Player_uc3 Unrealize and play next file
3344 <h2 class="pg">Unrealize and play next file</h2>
3345 - Player should be unrealized first in order to play another file.
3346 - If player is unrealized, all the related variables and codecs are removed.
3347 - So, it is necessary to set new attributes and reconstruct the player.
3348 - The following is a sample code to play another mp3 file.
3350 void play_next_audio_file(char *next_filename)
3352 if (mm_player_unrealize(g_player) != MM_ERROR_NONE)
3354 printf("failed to unrealize\n");
3358 if (mm_player_set_attribute(g_player,
3360 "profile_uri", next_filename, strlen(filename),
3361 NULL) != MM_ERROR_NONE)
3363 printf("failed to set %s attribute\n", g_err_attr_name);
3364 free(g_err_attr_name);
3367 if (mm_player_realize(g_player) != MM_ERROR_NONE)
3369 printf("failed to destroy\n");
3373 if (mm_player_start(g_player) != MM_ERROR_NONE)
3375 printf("failed to destroy\n");
3383 @defgroup Player_uc4 Destroy player
3387 <h2 class="pg">Destroy player</h2>
3389 - The created player should be destroyed when application is closed.
3390 - So, if mm_player_destroy() is called, all allocated resources and the player handle are released.
3392 @defgroup Player_uc5 Play and end of playback
3396 <h2 class="pg">Play and end of playback</h2>
3398 - Applications can play music or video using the mm_player_start() function when player is in the ready state. After starting, the appropriate codecs will be generated internally to play it.
3399 - The result of the start function is returned asynchronously through the message callback which was previously registered.
3400 - Playback is confirmed to the application with the MM_BEGIN_OF_STREAM(BOS) message.
3401 - The MM_MESSAGE_END_OF_STREAM(EOS) is sent at the end of contents playback.
3403 @defgroup Player_uc6 Pause and resume
3407 <h2 class="pg">Pause and resume</h2>
3409 - Player can be paused during playing video or audio contents. It can also be resumed again.
3410 - The result of the pause or resume functions are returned asynchronously. So the result is confirmed to the application by the MM_MESSAGE_STATE_CHANGED message in the message callback.
3411 - Both apis may be used synchronously in the case of local playback.
3412 - The following is a sample code for when the player is paused and the result is checked for streaming data.
3415 void pause_video_player()
3417 if (mm_player_pause(g_player) != MM_ERROR_NONE)
3419 printf("failed to pause\n");
3423 int msg_callback(int message, MMMessageParamType *param, void *user_param)
3427 case MM_MESSAGE_ERROR:
3431 case MM_MESSAGE_STATE_CHANGED:
3432 if (param->state.current == MM_PLAYER_STATE_PAUSED)
3433 printf("player is paused. So, application can resume it again.\n");
3443 @defgroup Player_uc7 Change the volume during playback
3447 <h3 class="pg">Change the volume during playback</h3>
3449 - The range of volume level is from 0 to 9. Each macro is MM_VOLUME_LEVEL_MIN and MM_VOLUME_LEVEL_MAX. The default volume level is 7.
3450 - Volume can be controlled during playback but, if volume is set before playing, it can be saved and applied at running time.
3451 - The following is a sample code to set MM_VOLUME_LEVEL_MAX volume and get it.
3454 int change_video_player_volume()
3456 MMPlayerVolumeType volume;
3459 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
3460 volume.level[i] = MM_VOLUME_LEVEL_MAX;
3462 if (mm_player_set_volume(g_player, &volume) != MM_ERROR_NONE)
3464 printf("failed to set volume\n");
3468 if (mm_player_get_volume(g_player, format, &pos) != MM_ERROR_NONE)
3470 printf("failed to get volume\n");
3474 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
3475 printf("channel[%d] = %d \n", i, volume.level[i]);
3479 @defgroup Player_uc8 Seeking position
3483 <h3 class="pg">Seeking position</h3>
3485 - Player supports time and percent format to get or set position of stream.
3486 - The position unit is in milliseconds.
3487 - The following is a sample code to get and set the player position.
3490 gboolean change_video_player_position()
3492 int format = MM_PLAYER_POS_FORMAT_TIME;
3493 int pos = 15000; // 15sec
3495 if (mm_player_set_position(g_player, format, pos) != MM_ERROR_NONE)
3500 if (mm_player_get_position(g_player, format, &pos) != MM_ERROR_NONE)
3504 printf("current pos = %d (msec)\n", pos);
3511 @defgroup Player_uc9 Show subtitle
3515 <h3 class="pg">Show subtitle</h3>
3517 - Player framework can support a separate subtitle file. The filepath of subtitle should be sent through mm_player_set_attribute() before realizing the player.
3521 if (mm_player_set_attribute(g_player,
3523 "subtitle_uri",subtitle_path,strlen(subtitle_path),
3524 NULL) != MM_ERROR_NONE)
3526 printf("failed to set %s\n", *g_err_name);
3531 - Application shall select the option of whether to show the subtitle or not.
3534 if (mm_player_set_subtitle_silent(g_player, TRUE) != MM_ERROR_NONE)
3535 printf("failed to set subtitle silent\n");
3539 - Finally, application should get the parsed text data from message of callback function.
3543 void video_player_message_callback(int message, void *param, void *user_param)
3545 struct appdata *ad = (struct appdata *)user_param;
3546 MMMessageParamType* msg_param = (MMMessageParamType*)param;
3550 case MM_MESSAGE_SUBTITLE:
3551 if (msg_param->data != NULL)
3553 ad->subtitle_duration = msg_param->subtitle.duration/1000;
3554 strcpy(ad->subtitle, msg_param->data);
3555 show_video_player_subtitle(ad);
3568 @defgroup MMsession Multimedia session
3569 @ingroup MultiMediaPG
3571 @brief <sub class="ref">Also see</sub> Use Cases of @ref MMsession_UC
3573 <h2 class="pg">Multimedia session</h2>
3575 Role of Multimedia Session is to manage "operation policy" between multimedia applications in multi-tasking scenario
3577 Multimedia Session provides functions to determine type of application's policy.
3579 Application developer can define applications' session type as "shared", "exclusive" or "replace".
3581 "Shared" type means the audio session is shared with other applications, if possible. The audio resources can be used by other applications.
3583 "Exclusive" type means using the audio session exclusively. Other applications are not allowed to use multimedia resources during this time.
3585 "Replace" type means this will make stop previous session but allows sharing session with following application.
3588 The following are supported functions :
3590 - int mm_session_init(int sessiontype)
3592 - int mm_session_finish(void)
3595 @defgroup MMsession_uc1 Initializing Session
3596 @ingroup MMsession_UC
3600 Initializing Session
3602 - To define current application's multimedia session policy.
3604 - Policy can be one of SHARE, EXCLUSIVE or REPLACE.
3606 - The following is a sample code
3614 // Init session policy to MEDIA
3616 err = mm_session_init (MM_SESSION_TYPE_MEDIA);
3620 if (err != MM_ERROR_NONE)
3626 // Multimedia API manipulation (player, camcorder, etc.)
3630 @defgroup MMsession_uc2 Finisihing Session
3631 @ingroup MMsession_UC
3636 - To finish current application's multimedia session policy
3638 - This API is not mandatory except internal call application.
3640 - This API can be also useful when application's multimedia session should be changed at runtime.
3642 - The following is a sample code
3649 // Init session policy to MEDIA
3651 err = mm_session_init (MM_SESSION_TYPE_MEDIA);
3655 if (err != MM_ERROR_NONE)
3665 // Change policy to EXCLUSIVE
3667 err = mm_session_finish();
3671 // Init session policy to EXCLUSIVE
3673 err = mm_session_init (MM_SESSION_TYPE_EXCLUSIVE);
3677 // Do something else
3681 @defgroup MM_Fileinfo Fileinfo
3682 @ingroup MultiMediaPG
3684 <h2 class="pg">Fileinfo</h2>
3685 @brief <sub class="ref">Also see</sub> Use Cases of @ref Fileinfo_UC
3687 Fileinfo module provides APIs to extract media property information and meta data from media content. These values can be used to display detailed information of the media content without playing it.
3691 For convenience, the file module provides an additional two APIs (mm_file_get_content_attr_from_memory, mm_file_get_tag_attr_from_memory) which manipulate the source data from memory instead of the file. They act the same as normal APIs (mm_file_get_content_attr, mm_file_get_tag_attr).
3695 For performance, the file module provides an additional two APIs (mm_file_get_stream_info, mm_file_get_content_attr_simple) which extract the audio/video track count without time consuming operations.
3699 The following are supported functions
3700 - int mm_file_get_content_attr (MMHandleType *attrs, const char *filename)
3702 - int mm_file_get_content_attr_from_memory (MMHandleType *attrs, const void *data, unsigned int size, int format)
3704 - int mm_file_get_content_attr_simple (MMHandleType *attrs, const char *filename)
3706 - int mm_file_free_content_attr (MMHandleType attrs)
3708 - int mm_file_get_tag_attr ((MMHandleType *attrs, const char *filename)
3710 - int mm_file_get_tag_attr_from_memory ((MMHandleType *attrs, const void *data, unsigned int size, int format)
3712 - int mm_file_free_tag_attr ((MMHandleType attrs)
3714 - int mm_file_get_stream_info (const char *filename, int *audio_stream_num, int *video_stream_num)
3719 @defgroup Fileinfo_uc1 Extracting Media Property Information
3720 @ingroup Fileinfo_UC
3723 <h3 class="pg">Extracting Media Property Information </h3>
3725 Media property information can be extracted using the following steps:
3727 - Get attributes handle containing media information using mm_file_get_content_attr API
3729 - Use attributes functions with handle to get value
3731 - Free allocated media information using mm_file_free_content_attr API
3735 The following is a sample code
3744 err = mm_file_get_content_attr(&attrs, filename);
3746 if (err != MM_ERROR_NONE)
3750 printf("error occurred to extract media information\n");
3758 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_DURATION, &val);
3760 if (err == MM_ERROR_NONE)
3762 printf("duration: %d\n", val);
3766 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_VIDEO_CODEC, &val);
3768 if (err == MM_ERROR_NONE)
3770 printf("video codec id: %d\n", val);
3774 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_VIDEO_BITRATE, &val);
3776 if (err == MM_ERROR_NONE)
3778 printf("video bitrate: %d\n", val);
3782 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_VIDEO_FPS, &val);
3784 if (err == MM_ERROR_NONE)
3786 printf("fps: %d\n", val);
3790 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_VIDEO_WIDTH, &val);
3792 if (err == MM_ERROR_NONE)
3794 printf("width: %d\n", val);
3798 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_VIDEO_HEIGHT, &val);
3800 if (err == MM_ERROR_NONE)
3802 printf("height: %d\n", val);
3806 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_VIDEO_THUMBNAIL, &data, &size);
3808 if (err == MM_ERROR_NONE)
3810 printf("thumbnail: %p, %d bytes\n", data, size);
3814 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_VIDEO_TRACK_ID, &val);
3816 if (err == MM_ERROR_NONE)
3818 printf("video track id: %d\n", val);
3822 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_VIDEO_TRACK_NUM, &val);
3824 if (err == MM_ERROR_NONE)
3826 printf("video tracks: %d\n", val);
3830 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_AUDIO_CODEC, &val);
3832 if (err == MM_ERROR_NONE)
3834 printf("audio codec id: %d\n", val);
3838 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_AUDIO_BITRATE, &val);
3840 if (err == MM_ERROR_NONE)
3842 printf("audio bitrate: %d\n", val);
3846 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_AUDIO_CHANNELS, &val);
3848 if (err == MM_ERROR_NONE)
3850 printf("channels: %d\n", val);
3854 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_AUDIO_SAMPLERATE, &val);
3856 if (err == MM_ERROR_NONE)
3858 printf("sampling rate: %d\n", val);
3862 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_AUDIO_TRACK_ID, &val);
3864 if (err == MM_ERROR_NONE)
3866 printf("audio track id: %d\n", val);
3870 err = mm_attrs_get_int(attrs, MM_FILE_CONTENT_AUDIO_TRACK_NUM, &val);
3872 if (err == MM_ERROR_NONE)
3874 printf("audio tracks: %d\n", val);
3878 err = mm_file_free_content_attr (attr);
3881 @defgroup Fileinfo_uc2 Extracting Media Meta(Tag) data
3882 @ingroup Fileinfo_UC
3885 <h3 class="pg">Extracting Media Meta(Tag) data</h3>
3887 Media meta data can be extracted using the following steps:
3889 - Get attributes handle containing meta data using mm_file_get_tag_attr API
3891 - Use attributes functions with handle to get value
3893 - Free allocated meta data using mm_file_free_tag_attr API
3897 The following is a sample code
3911 err = mm_file_get_tag_attr (&attrs, filename);
3913 if (err != MM_ERROR_NONE)
3917 printf("error occurred to extract meta data\n");
3925 err = mm_attrs_get_string(attrs, MM_FILE_TAG_ARTIST, &str, &size);
3927 if (err == MM_ERROR_NONE && str)
3929 printf("artist: %s\n", str);
3933 err = mm_attrs_get_string(attrs, MM_FILE_TAG_TITLE, &str, &size);
3935 if (err == MM_ERROR_NONE && str)
3937 printf("title: %s\n", str);
3941 err = mm_attrs_get_string(attrs, MM_FILE_TAG_ALBUM, &str, &size);
3943 if (err == MM_ERROR_NONE && str)
3945 printf("album: %s\n", str);
3949 err = mm_attrs_get_string(attrs, MM_FILE_TAG_COPYRIGHT, &str, &size);
3951 if (err == MM_ERROR_NONE && str)
3953 printf("copyright: %s\n", str);
3957 err = mm_attrs_get_string(attrs, MM_FILE_TAG_DATE, &str, &size);
3959 if (err == MM_ERROR_NONE && str)
3961 printf("date: %s\n", str);
3965 err = mm_attrs_get_string(attrs, MM_FILE_TAG_DESCRIPTION, &str, &size);
3967 if (err == MM_ERROR_NONE && str)
3969 printf("description: %s\n", str);
3973 err = mm_attrs_get_data(attrs, MM_FILE_TAG_ARTWORK, &data, &size);
3975 err |= mm_attrs_get_int(attrs, MM_FILE_TAG_ARTWORK_SIZE, &size);
3977 if (err == MM_ERROR_NONE && data && size > 0)
3979 printf("artwork: %p, %d\n", data, size);
3983 err = mm_attrs_get_string(attrs, MM_FILE_TAG_TRACK_NUM, &str, &size);
3985 if (err == MM_ERROR_NONE && str)
3987 printf("track: %s\n", str);
3991 err = mm_attrs_get_string(attrs, MM_FILE_TAG_CLASSIFICATION, &str, &size);
3993 if (err == MM_ERROR_NONE && str)
3995 printf("classification: %s\n", str);
3999 err = mm_attrs_get_string(attrs, MM_FILE_TAG_RATING, &str, &size);
4001 if (err == MM_ERROR_NONE && str)
4003 printf("rating: %s\n", str);
4007 err = mm_attrs_get_double(attrs, MM_FILE_TAG_LONGITUDE, &fval);
4009 if (err == MM_ERROR_NONE)
4011 printf("longitude: %4.4f\n", fval);
4015 err = mm_attrs_get_double(attrs, MM_FILE_TAG_LATIDUE, &fval);
4017 if (err == MM_ERROR_NONE)
4019 printf("latidue: %4.4f\n", fval);
4023 err = mm_attrs_get_double(attrs, MM_FILE_TAG_ALTIDUE, &fval);
4025 if (err == MM_ERROR_NONE)
4027 printf("altidue: %4.4f\n", fval);
4031 err = mm_file_free_tag_attr (attr);
4035 @defgroup Fileinfo_uc3 Extracting Stream information
4036 @ingroup Fileinfo_UC
4039 <h3 class="pg">Extracting Stream information</h3>
4041 Number of streams can be extracted using the following steps:
4043 - Get the number of streams using mm_file_get_stream_info API
4045 - Detect as video file if number of video streams is more than one.
4049 The following is a sample code
4060 err = mm_file_get_stream_info (filename, &audio_num, &video_num);
4062 if (err != MM_ERROR_NONE)
4066 printf("error occurred to extract stream information\n");
4074 printf("content has %d audio streams\n", audio_num);
4076 printf("content has %d video streams\n", video_num);
4079 @defgroup MM_Sound Sound
4080 @ingroup MultiMediaPG
4083 <h2 class="pg">Sound</h2>
4084 @brief <sub class="ref">Also see</sub> Use Cases of @ref Sound_UC
4086 The Sound module has the following features:
4088 Play or capture PCM data with given memory buffer
4090 Play audio file with simple API ( uncompressed WAV file only)
4092 Control volume and audio routing information
4094 The following are supported functions :
4096 - int mm_sound_pcm_capture_close (MMSoundPcmHandle_t handle)
4098 - int mm_sound_pcm_capture_open (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format)
4100 - int mm_sound_pcm_capture_read (MMSoundPcmHandle_t handle, void *buffer, const unsigned int length)
4102 - int mm_sound_pcm_play_close (MMSoundPcmHandle_t handle)
4104 - int mm_sound_pcm_play_open (MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, const volume_type_t volume)
4106 - int mm_sound_pcm_play_write (MMSoundPcmHandle_t handle, void *ptr, unsigned int length_byte)
4108 - int mm_sound_play_dtmf (MMSoundDtmf_t num, const volume_type_t vol_type, const sound_time_msec_t time)
4110 - int mm_sound_play_sound (const char *filename, const volume_type_t volume, mm_sound_stop_callback_func callback, void *data, int *handle)
4112 - int mm_sound_stop_sound (int handle)
4114 - int mm_sound_volume_add_callback (volume_type_t type, volume_callback_fn func, void *user_data)
4116 - int mm_sound_volume_get_current_playing_type (volume_type_t *type)
4118 - int mm_sound_volume_get_step (volume_type_t type, int *step)
4120 - int mm_sound_volume_get_value (volume_type_t type, unsigned int *value)
4122 - int mm_sound_volume_primary_type_clear ()
4124 - int mm_sound_volume_primary_type_set (volume_type_t type)
4126 - int mm_sound_volume_remove_callback (volume_type_t type)
4128 - int mm_sound_volume_set_value (volume_type_t type, const unsigned int value)
4130 - int mm_sound_route_add_change_callback (audio_route_policy_changed_callback_fn func, void *user_data)
4132 - int mm_sound_route_get_system_policy (system_audio_route_t *route)
4134 - int mm_sound_route_is_a2dp_on (char **bt_name)
4136 - int mm_sound_route_remove_change_callback (void)
4138 - int mm_sound_route_set_system_policy (system_audio_route_t route)
4141 @defgroup Sound_uc1 Capture PCM data
4145 <h3 class="pg">Capture PCM data</h3>
4147 - Application can capture PCM data
4149 - The following is a sample code
4154 bool g_stop_pcm_capturing = FALSE;
4155 int capture_pcm_data()
4157 char *buffer = NULL;
4161 MMSoundPcmHandle_t handle;
4163 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
4166 printf("Can not open capture handle\n");
4170 buffer = alloca(size);
4173 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
4176 printf("read fail\n");
4179 if( g_stop_pcm_capturing ) {
4183 mm_sound_pcm_capture_close(handle);
4192 @defgroup Sound_uc2 Play sound file
4196 <h3 class="pg">Play sound file</h3>
4198 - Start playing sound file
4199 - Stop playing sound file
4200 - Uncompressed WAV file only
4205 void sound_stop_cb(void* data)
4207 struct appdata* ad = (appdata*) data;
4208 printf("Stop callback\n");
4209 ad->snd_handle = -1;
4212 int play_file(void* data)
4214 struct appdata* ad = (struct appdata*) data;
4215 char filename[] ="/opt/media/Sound/testfile.wav";
4216 volume_type_t volume = VOLUME_TYPE_SYSTEM;
4218 int *snd_handle = NULL;
4220 snd_handle = &ad->snd_handle;
4222 ret = mm_sound_play_sound(filename, volume, sound_stop_cb, (void*)ad, snd_handle);
4225 printf("play file failed\n");
4230 printf("play file success\n");
4236 int stop_file(void* data)
4239 struct appdata* ad = (struct appdata*) data;
4241 if(ad->snd_handle != -1)
4243 ret = mm_sound_stop_sound(ad->snd_handle);
4246 printf("Stop sound failed\n");
4251 printf("Stop sound success\n");
4258 @defgroup Sound_uc3 Control Volume
4263 <h3 class="pg">Control Volume</h3>
4265 Basically volume of SLP system is controlled by System process.
4266 But in some case, application should control volume by itself.
4267 - If application does not want to be hidden by System Volume UI.
4268 - If application want to use Volume H/W key for special purpose.
4270 Sample code to control Media type volume
4275 Eina_Bool volume_key_cb(void *data, int type, void *event_info)
4277 struct appdata* ad = (struct appdata*)data;
4278 Ecore_Event_Key *kd = (Ecore_Event_Key*) event_info;
4282 if(0 == strcmp(kd->keyname, KEY_VOLUMEUP))
4284 ret = mm_sound_volume_get_value(ad->vol_type, &cur_vol);
4287 printf("Can not get volume value\n");
4291 if(cur_vol == ad->max_vol)
4297 ret = mm_sound_volume_set_value(ad->vol_type, ++cur_vol);
4300 printf("Can not set volume value\n");
4305 else if(0 == strcmp(kd->keyname, KEY_VOLUMEDOWN))
4307 ret = mm_sound_volume_get_value(ad->vol_type, &cur_vol);
4310 printf("Can not get volume value\n");
4314 if(0 == ad->max_vol)
4320 ret = mm_sound_volume_set_value(ad->vol_type, --cur_vol);
4323 printf("Can not set volume value\n");
4335 int do_key_grab(void* data)
4337 struct appdata* ad = (struct appdata*)data;
4341 // grab key and add event handler
4342 if( utilx_grab_key(ad->disp, ad->win, KEY_VOLUMEUP, TOP_POSITION_GRAB) < 0)
4344 printf("grab Volume up key fail\n");
4347 if( utilx_grab_key(ad->disp, ad->win, KEY_VOLUMEDOWN, TOP_POSITION_GRAB) < 0)
4349 printf("grab Volume down key fail\n");
4353 ad->key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, volume_key_cb, ad);
4355 //get max volume of type
4356 ad->vol_type = VOLUME_TYPE_MEDIA;
4357 ret = mm_sound_volume_get_step(ad->vol_type, &vol_max);
4360 printf("Volume get step fail\n");
4364 ad->vol_max = vol_max;
4372 @defgroup MM_OpenAL OpenAL
4373 @ingroup MultiMediaPG
4377 <h2 class="pg">OpenAL</h2>
4379 OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications. OpenAL in SLP only supports playback fucntion.
4383 OpenAL is opensource and if you need further information, see official website : http://connect.creativelabs.com/openal/default.aspx
4386 Specification and Reference
4388 - http://connect.creativelabs.com/openal/Documentation/Forms/AllItems.aspx
4391 @defgroup MM_Radio Radio
4392 @ingroup MultiMediaPG
4395 <h2 class="pg">Radio</h2>
4396 @brief <sub class="ref">Also see</sub> Use Cases of @ref Radio_UC
4398 This section describes APIs of the Multimedia FM radio library. Radio library is used for listening to FM radio, scanning all possible frequencies and seeking one frequency from current state, controling relative volume and frequency.
4402 Radio can have 5 states, and each state can be changed by calling the following functions as described.
4417 mm_radio_create() <td>
4422 mm_radio _destroy() <td>
4427 mm_radio_realize() <td>
4432 mm_radio_unrealize() <td>
4437 mm_radio_start() <td>
4442 mm_radio_stop() <td>
4447 mm_radio_scan_start() <td>
4452 mm_radio_scan_stop() <td>
4457 Mm_radio_seek() <td>
4463 @image html SLP_MultimediaFW_PG_image004.png
4465 The following are supported functions in the radio module.
4467 - int mm_radio_get_state(MMHandleType hradio, MMRadioStateType *state)
4469 - int mm_radio_set_frequency(MMHandleType hradio, int freq)
4471 - int mm_radio_get_frequency(MMHandleType hradio, int *pFreq)
4473 - int mm_radio_set_sound_path(MMHandleType hradio, MMRadioOuputType path)
4475 - int mm_radio_get_sound_path (MMHandleType hrado, MMRadioOuputType *pPath)
4477 - int mm_radio_set_message_callback(MMHandleType radio, MMMessageCallback callback, void *user_param)
4480 @defgroup Radio_uc1 Create and initialize radio
4484 <h3 class="pg">Create and initialize radio</h3>
4486 - Application can create the radio handle using mm_radio_create().
4488 - And, callback function must be set to get messages from radio engine using mm_radio_set_message_callback().
4490 - The followings messages are used.
4494 <td> <b>MESSAGE TYPE</b> </td>
4495 <td> <b>DESCRIPTION</b> </td>
4497 <td> MM_MESSAGE_RADIO_SCAN_START
4498 <td> Radio frequency scanning initiated
4500 <td> MM_MESSAGE_RADIO_SCAN_INFO
4501 <td> Founded radio frequency report. check message parameters
4503 <td> MM_MESSAGE_RADIO_SCAN_FINISH
4504 <td> Radio frequency scanning has finished
4506 <td> MM_MESSAGE_RADIO_SCAN_STOP
4507 <td> Radio frequency scanning has stopped
4509 <td> MM_MESSAGE_RADIO_SEEK_START
4510 <td> Radio seeking has established
4512 <td> MM_MESSAGE_RADIO_SEEK_FINISH
4513 <td> Radio seeking has finished
4518 - The resources can be allocated by mm_radio_realize(). And, radio device is opened.
4521 MMHandleType g_radio = 0;
4523 static int __msg_callback(int message, void *pParam, void *user_param)
4525 MMMessageParamType* param = (MMMessageParamType*)pParam;
4526 MMHandleType radio = (MMHandleType *) user_param;
4530 printf("incomming message : %d\n", message);
4534 case MM_MESSAGE_STATE_CHANGED:
4535 printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n"
4536 , param->state.current, param->state.previous);
4539 case MM_MESSAGE_RADIO_SCAN_START:
4540 printf("MM_MESSAGE_RADIO_SCAN_START\n");
4543 case MM_MESSAGE_RADIO_SCAN_INFO:
4544 printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency);
4547 case MM_MESSAGE_RADIO_SCAN_STOP:
4548 printf("MM_MESSAGE_RADIO_SCAN_STOP\n");
4551 case MM_MESSAGE_RADIO_SCAN_FINISH:
4552 printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n");
4555 case MM_MESSAGE_RADIO_SEEK_START:
4556 printf("MM_MESSAGE_RADIO_SEEK_START\n");
4559 case MM_MESSAGE_RADIO_SEEK_FINISH:
4560 printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency);
4564 printf("ERROR : unknown message received!\n");
4572 int init_radio(void)
4574 int ret = MM_ERROR_NONE;
4576 mm_radio_create(&g_radio);
4577 mm_radio_set_message_callback( radio, (MMMessageCallback)__msg_callback,(void*) g_radio);
4578 mm_radio_realize(g_radio);
4579 mm_radio_unrealize(g_radio);
4580 mm_radio_destroy(g_radio);
4586 @defgroup Radio_uc2 Destroy and close
4590 <h3 class="pg">Destroy and close</h3>
4592 - The created radio should be destroyed when application is closed.
4594 - So, if mm_radio_unrealize() is called, radio device would be closed.
4596 - And, all allocated resources and the player handle are released by mm_radio_destroy().
4599 gboolean release_radio(void)
4601 if (mm_radio_unrealize(g_radio) != MM_ERROR_NONE)
4603 printf("failed to unrealize\n");
4607 if (mm_radio_ destroy (g_radio) != MM_ERROR_NONE)
4609 printf("failed to destroy\n");
4619 <b>Start and stop</b>
4621 - Application can start radio with mm_radio_start() and stop it with mm_radio_stop().
4623 - And, the frequency should be set before calling start.
4627 gboolean start_radio(void)
4629 if (mm_radio_ set_frequency (g_radio, 1077) != MM_ERROR_NONE)
4631 printf("failed to set freq\n");
4636 if (mm_radio_start(g_radio) != MM_ERROR_NONE)
4638 printf("failed to start\n");
4647 gboolean stop_radio(void)
4649 if (mm_radio_stop(g_radio) != MM_ERROR_NONE)
4651 printf("failed to stop\n");
4659 @defgroup Radio_uc3 Seek frequency
4663 <h3 class="pg">Seek frequency</h3>
4665 - Application can seek the effective frequency of radio in playing state by mm_radio_seek().
4667 - After calling it, application have to check the state with MM_MESSAGE_RADIO_SEEK_START and MM_MESSAGE_RADIO_SEEK_FINISH which are sent through message callback.
4669 - And, if seek is finished, the frequency is sent through message parameter of callback function when MM_MESSAGE_RADIO_SEEK_FINISH is posted.
4673 gboolean seek_radio_frequency(void)
4675 if (mm_radio_seek (g_radio) != MM_ERROR_NONE)
4677 printf("failed to seek\n");
4685 @defgroup Radio_uc4 Scan frequencies
4689 <h3 class="pg">Scan frequencies</h3>
4691 - Application can scan the effective frequency of radio in playing state by mm_radio_scan_start().
4693 - After calling it, application have to check the state with MM_MESSAGE_RADIO_SCAN_START , MM_MESSAGE_RADIO_SCAN_INFO, MM_MESSAGE_RADIO_SCAN_FINISH which are sent through message callback.
4695 - And, if frequency is found, it's sent through message parameter of callback function when . MM_MESSAGE_RADIO_SCAN_INFO is posted.
4697 - Finally, scanning can be stopped by mm_radio_scan_stop(). So, MM_MESSAGE_RADIO_SCAN_STOP will be sent.
4705 @defgroup Radio_uc5 Set/Get sound path
4710 <h3 class="pg">Set/Get sound path</h3>
4712 - Applications can set/get sound path by mm_radio_set_sound_path() and mm_radio_get_sound_path().
4714 - The sound path type is followings .
4718 <tr> <td>SOUND PATH TYPE </td> <td>DESCRIPTION </td> </tr>
4719 <tr> <td>MM_RADIO_OUTPUT_AUTO </td> <td>Automatic output mode, but not used yet </td> </tr>
4720 <tr> <td>MM_RADIO_OUTPUT_SPEAKER </td> <td> </td> </tr>
4721 <tr> <td> </td> <td> </td> </tr>
4727 * @defgroup MultiMediaPG MultiMedia Camcorder,Player,Sound and Radio
4730 * @defgroup MM_UC Use Cases
4732 * @defgroup Camcorder_UC Camcorder
4733 * @defgroup Player_UC Player
4734 * @defgroup Sound_UC Sound
4735 * @defgroup MMsession_UC Multimedia session
4736 @brief <sub class="ref">Also see</sub> Feature description of @ref MMsession
4737 * @defgroup Fileinfo_UC Fileinfo
4738 @brief <sub class="ref">Also see</sub> Feature description of @ref Fileinfo
4739 * @defgroup Radio_UC Radio
4740 @brief <sub class="ref">Also see</sub> Feature description of @ref Radio