Tizen Native API
5.5
|
The Media Content API provides functions, enumerations used in the entire Content Service.
Required Header
#include <media_content.h>
Overview
The Media Content API provides functions and enumerations used in the entire Content Service.
The information about media items i.e. image, audio and video, are managed in the content database and operations that involve database requires an active connection with the media content service.
During media scanning, Media Service extract media information automatically. media information include basic file info like path, size, modified time etc and some metadata like ID3tag, EXIF, thumbnail, etc. (thumbnail extracted only in Internal and SD card storage.)
Since 3.0, a thumbnail is not automatically extracted during media scanning. A thumbnail will be created only when media_info_create_thumbnail() is called by any application.
Media content services do not manage hidden files.
The API provides functions for connecting (media_content_connect()) and disconnecting (media_content_disconnect()) from the media content service.
The API consists of Media Album, Media Bookmark, Media Face, Media Filter, Media Folder, Media Group, Media Information, Media Playlist, Media Tag API.
API | Description |
---|---|
Media Album | Provide information about the media album. |
Media Bookmark | Provide information about the media bookmark. |
Media Face | Provide information about the detected faces from image. |
Media Filter | Provide functions for creating and destroying media filters. Provide functions to get filter properties |
Media Folder | Provide information about folders (e.g. path, name, modification date) stored on the device. Provide information about the media items present in the folders. |
Media Group | Provide information about the media group(e.g. media artist, composer, genre, year). |
Media Information | Provide generic information about media content items (i.e. image, audio, video and others). Provide details about audio files (e.g. name, genre etc) present in the device. Provide details about image files (e.g. width, height, orientation etc) present in the device. Provide details about video files (e.g. width, height, duration etc) present in the device . |
Media Playlist | Provide information about the media playlist. |
Media Tag | Provide information about media tags. Provide functions to insert or delete tag from database. Provide functions to add and remove media item from tags in the database. |
Functions | |
int | media_content_connect (void) |
Connects to the media content service. | |
int | media_content_disconnect (void) |
Disconnects from the media content service. | |
int | media_content_scan_file (const char *path) |
Requests to scan a media file. | |
int | media_content_scan_folder (const char *path, bool is_recursive, media_scan_completed_cb callback, void *user_data) |
Requests to scan a media folder, asynchronously. | |
int | media_content_cancel_scan_folder (const char *path) |
Requests to cancel the media folder scanning. | |
int | media_content_add_db_updated_cb (media_content_db_update_cb callback, void *user_data, media_content_noti_h *noti_handle) |
Subscribes notifications of the media DB change. | |
int | media_content_remove_db_updated_cb (media_content_noti_h noti_handle) |
Removes notifications of the media DB change. | |
Typedefs | |
typedef void * | media_content_noti_h |
The structure type for the Media content noti handle. | |
typedef void(* | media_scan_completed_cb )(media_content_error_e error, void *user_data) |
Called when the media scanning is finished. | |
typedef void(* | media_content_db_update_cb )(media_content_error_e error, int pid, media_content_db_update_item_type_e update_item, media_content_db_update_type_e update_type, media_content_type_e media_type, char *uuid, char *path, char *mime_type, void *user_data) |
Called when the notification of the media DB change is subscribed. | |
Defines | |
#define | MEDIA_CONTENT_ERROR_CLASS TIZEN_ERROR_MEDIA_CONTENT |
Error class. |
Define Documentation
#define MEDIA_CONTENT_ERROR_CLASS TIZEN_ERROR_MEDIA_CONTENT |
Error class.
Class for Media Content error
- Since :
- 2.3
Typedef Documentation
typedef void(* media_content_db_update_cb)(media_content_error_e error, int pid, media_content_db_update_item_type_e update_item, media_content_db_update_type_e update_type, media_content_type_e media_type, char *uuid, char *path, char *mime_type, void *user_data) |
Called when the notification of the media DB change is subscribed.
The following error codes can be received:
MEDIA_CONTENT_ERROR_NONE : Success
- Since :
- 2.3
- Remarks:
- The callback is called in a separate thread(not in the main loop).
- Parameters:
-
[in] error The error code [in] pid The PID which publishes notification [in] update_item The update item of notification [in] update_type The update type of notification [in] media_type The type of the media content (media_content_type_e) [in] uuid The UUID of media or directory, which is updated [in] path The path of the media or directory [in] mime_type The MIME of the media info [in] user_data The user data passed from the foreach function
- Precondition:
- media_content_add_db_updated_cb().
- See also:
- media_content_add_db_updated_cb()
typedef void* media_content_noti_h |
The structure type for the Media content noti handle.
- Since :
- 3.0
typedef void(* media_scan_completed_cb)(media_content_error_e error, void *user_data) |
Called when the media scanning is finished.
The following error codes can be received:
MEDIA_CONTENT_ERROR_NONE : Success
MEDIA_CONTENT_ERROR_INVALID_PARAMETER : Invalid parameter
MEDIA_CONTENT_ERROR_INVALID_OPERATION : Invalid operation
MEDIA_CONTENT_ERROR_PERMISSION_DENIED : Permission denied
MEDIA_CONTENT_ERROR_OUT_OF_MEMORY : Out of memory
MEDIA_CONTENT_ERROR_DB_FAILED : DB Operation failed
MEDIA_CONTENT_ERROR_DB_BUSY : DB Operation busy
MEDIA_CONTENT_ERROR_NETWORK : Network fail
- Since :
- 2.3
- Remarks:
- The callback is called in a separate thread(not in the main loop).
- Parameters:
-
[in] error The error code [in] user_data The user data passed from the foreach function
- Precondition:
- media_content_scan_folder().
- See also:
- media_content_scan_folder()
Enumeration Type Documentation
Enumeration for collations.
- Since :
- 2.3
Enumeration for a media content error.
- Since :
- 2.3
- Enumerator:
Enumeration for the storage type.
- Deprecated:
- Deprecated since 5.0.
This information is used to establish where the folder is.
- Since :
- 2.3
enum media_content_type_e |
Enumeration for the media file format.
- Since :
- 2.3
- Remarks:
- Since 4.0, MEDIA_CONTENT_TYPE_OTHERS is related to the following feature:
http://tizen.org/feature/content.scanning.others
If this feature is not supported on the device, MEDIA_CONTENT_TYPE_OTHERS type file is not scanned.
enum media_group_e |
Enumeration for a media group.
- Since :
- 2.3
- Enumerator:
Function Documentation
int media_content_add_db_updated_cb | ( | media_content_db_update_cb | callback, |
void * | user_data, | ||
media_content_noti_h * | noti_handle | ||
) |
Subscribes notifications of the media DB change.
This function subscribes notifications of the media DB change which are published by the media server or other apps.
media_content_db_update_cb() function will be called when notification of the media DB change is subscribed.
Using this function, multiple callback is possible to register in one process.
- Since :
- 3.0
- Remarks:
- The noti_handle should be released using media_content_remove_db_updated_cb().
If you set the same callback that you previously added, this function returns MEDIA_CONTENT_ERROR_INVALID_OPERATION error.
- Parameters:
-
[in] callback The callback to be invoked when the scanning is finished [in] user_data The user data to be passed to the callback function [out] noti_handle The handle to db updated notification
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
MEDIA_CONTENT_ERROR_NONE Successful MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
int media_content_cancel_scan_folder | ( | const char * | path | ) |
Requests to cancel the media folder scanning.
- Since :
- 2.4
- Parameters:
-
[in] path The folder path
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
MEDIA_CONTENT_ERROR_NONE Successful MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
- Precondition:
- media_content_scan_folder()
int media_content_connect | ( | void | ) |
Connects to the media content service.
Any media content related function call should be invoked after this function call.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
MEDIA_CONTENT_ERROR_NONE Successful MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
- Postcondition:
- media_content_disconnect()
- See also:
- media_content_disconnect()
int media_content_disconnect | ( | void | ) |
Disconnects from the media content service.
This function closes connection to the media content service. Any further media content related operation cannot be performed after this function is called.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
MEDIA_CONTENT_ERROR_NONE Successful MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
- Precondition:
- media_content_connect()
- See also:
- media_content_connect()
int media_content_remove_db_updated_cb | ( | media_content_noti_h | noti_handle | ) |
Removes notifications of the media DB change.
This function unsubscribes notifications of the media DB change which are published by the media server or other apps.
- Since :
- 3.0
- Parameters:
-
[in] noti_handle The handle to db updated notification
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
MEDIA_CONTENT_ERROR_NONE Successful MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- Precondition:
- media_content_add_db_updated_cb()
- See also:
- media_content_add_db_updated_cb()
int media_content_scan_file | ( | const char * | path | ) |
Requests to scan a media file.
This function requests to scan a media file to the media server. If media file is not registered to DB yet, that media file information will be added to the media DB. If it is already registered to the DB, then this tries to refresh information.
If requested file does not exist on file system, information of the media file will be removed from the media DB.
If file information does not exist in DB, this function will be return MEDIA_CONTENT_ERROR_INVALID_PARAMETER.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/content.write
http://tizen.org/privilege/mediastorage
http://tizen.org/privilege/externalstorage
- Remarks:
- You must add privilege http://tizen.org/privilege/content.write. And You add more privilege depending on your choice of contents path.
If you want to access only internal storage by using this function, you should add privilege http://tizen.org/privilege/mediastorage.
Or if you want to access only external storage by using this function, you should add privilege http://tizen.org/privilege/externalstorage.
If you can access both storage, you must add all privilege.
Since 4.0, This function does not allow a symbolic link.
-
Since 4.0, this function is related to the following feature:
http://tizen.org/feature/content.scanning.others
If this feature is not supported on the device, MEDIA_CONTENT_TYPE_OTHERS type file is not scanned.
- Parameters:
-
[in] path The file path
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
MEDIA_CONTENT_ERROR_NONE Successful MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy MEDIA_CONTENT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- This function requires opened connection to content service by media_content_connect().
- See also:
- media_content_connect()
int media_content_scan_folder | ( | const char * | path, |
bool | is_recursive, | ||
media_scan_completed_cb | callback, | ||
void * | user_data | ||
) |
Requests to scan a media folder, asynchronously.
This function requests to scan a media folder to the media server with given completed callback function. media_scan_completed_cb() function will be called when the scanning is finished. The sub folders are also scanned, if there are sub folders in that folder.
If any folder must not be scanned, a blank file ".scan_ignore" has to be created in that folder. After adding or removing a folder from the filesystem, call this function on its source location (this will add or remove an entry from the database).
After moving or renaming a folder in the filesystem, call this function on its source location (this will remove an entry from the database) and call this function again on its destination location (this will add a new entry to the database).
Alternatively, you can call this function on any parent of source location and on any parent of destination location.
You can also call the function once, on a folder which is a parent of both source and destination.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/content.write
http://tizen.org/privilege/mediastorage
http://tizen.org/privilege/externalstorage
- Remarks:
- You must add privilege http://tizen.org/privilege/content.write. And You add more privilege depending on your choice of contents path.
If you want to access only internal storage by using this function, you should add privilege http://tizen.org/privilege/mediastorage.
Or if you want to access only external storage by using this function, you should add privilege http://tizen.org/privilege/externalstorage.
If you can access both storage, you must add all privilege.
Since 4.0, This function does not allow a symbolic link.
- Parameters:
-
[in] path The folder path [in] is_recursive Set true
to scan recursively subdirectories, otherwisefalse
to scan only the current directory[in] callback The callback to be invoked when the scanning is finished [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
MEDIA_CONTENT_ERROR_NONE Successful MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy MEDIA_CONTENT_ERROR_NETWORK Network fail
- Precondition:
- This function requires opened connection to content service by media_content_connect().