add MM_ERROR_PLAYER_DRM_OUTPUT_PROTECTION
authorYounghwan Ahn <younghwan_.an@samsung.com>
Thu, 28 Mar 2013 09:24:31 +0000 (18:24 +0900)
committerYounghwan Ahn <younghwan_.an@samsung.com>
Thu, 28 Mar 2013 09:24:31 +0000 (18:24 +0900)
Change-Id: Ibc9fa09c4d10985e15e4ab83d81e5bb179457a05

include/mm_attrs_private.h
include/mm_error.h
mm_attrs.c
mm_attrs_private.c
packaging/libmm-common.spec

index b492938..141afd2 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdbool.h>
 #include <mm_types.h>
 #include <mm_attrs.h>
+#include <pthread.h>
 
 #ifdef __cplusplus
        extern "C" {
@@ -41,6 +42,9 @@
                (t) == MMF_VALUE_SPEC_DOUBLE_ARRAY || \
                (t) == MMF_VALUE_SPEC_DOUBLE_RANGE)
 
+#define MM_ATTRS_WRITE_LOCK(attrs)             do { pthread_mutex_lock(&attrs->write_lock); } while (0)
+#define MM_ATTRS_WRITE_UNLOCK(attrs)   do { pthread_mutex_unlock(&attrs->write_lock); } while (0)
+
 enum mmf_value_type {
        MMF_VALUE_TYPE_INT = MM_ATTRS_TYPE_INT,
        MMF_VALUE_TYPE_DOUBLE=MM_ATTRS_TYPE_DOUBLE,
@@ -126,6 +130,7 @@ struct mmf_attrs {
        mmf_attribute_t *items;
        mmf_attrs_commit_func_t commit_func;
        void *commit_param;
+       pthread_mutex_t write_lock;
 };
 
 struct mmf_attrs_list {
index c0e8527..25a6777 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 
+
 #ifndef __MM_ERROR_H__
 #define __MM_ERROR_H__
 
 #define MM_ERROR_PLAYER_DRM_EXPIRED                                    (MM_ERROR_PLAYER_CLASS | 0x1a)          /**< Expired license */
 #define MM_ERROR_PLAYER_DRM_FUTURE_USE                                 (MM_ERROR_PLAYER_CLASS | 0x1b)          /**< License for future use */
 #define MM_ERROR_PLAYER_DRM_NOT_AUTHORIZED                             (MM_ERROR_PLAYER_CLASS | 0x1c)          /**< Not authorized */
+#define MM_ERROR_PLAYER_DRM_OUTPUT_PROTECTION                          (MM_ERROR_PLAYER_CLASS | 0x1d)          /**< Output protected */
 
 #define MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_AUDIO                    (MM_ERROR_PLAYER_CLASS | 0x22)          /**< Unsupported audio  */
 #define MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_VIDEO                    (MM_ERROR_PLAYER_CLASS | 0x23)          /**< Unsupported video  */
index 715b013..e24cdd0 100644 (file)
@@ -231,18 +231,23 @@ int mm_attrs_set_string(MMHandleType h, int idx, const char *string, int size)
 
        return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
+       MM_ATTRS_WRITE_LOCK(attrs);
 
        if (mmf_attribute_check_flags(item, MM_ATTRS_FLAG_WRITABLE))
        {
                int ret = 0;
                ret = mmf_attribute_set_string(item, string, size);
 
+               MM_ATTRS_WRITE_UNLOCK(attrs);
+
                if (ret == 0)
                        return MM_ERROR_NONE;
                else
                        return MM_ERROR_COMMON_INVALID_ARGUMENT;
        }
 
+       MM_ATTRS_WRITE_UNLOCK(attrs);
+
        return MM_ERROR_COMMON_INVALID_PERMISSION;
 }
 
@@ -252,12 +257,18 @@ int mm_attrs_get_string(MMHandleType h, int idx,char **sval, int *size)
        mmf_attrs_t *attrs = (mmf_attrs_t *) h;
        return_val_if_fail(attrs && idx >= 0 && idx < attrs->count && sval, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
+       MM_ATTRS_WRITE_LOCK(attrs);
+
        if (!(attrs->items[idx].flags & MM_ATTRS_FLAG_READABLE)) {
                mmf_debug(MMF_DEBUG_LOG, "Access denied.\n");
+               MM_ATTRS_WRITE_UNLOCK(attrs);
                return MM_ERROR_COMMON_INVALID_PERMISSION;
        }
 
        *sval = mmf_value_get_string(&attrs->items[idx].value,size);
+
+       MM_ATTRS_WRITE_UNLOCK(attrs);
+
        return MM_ERROR_NONE;
 }
 
index d37905c..ab5afa0 100644 (file)
@@ -513,6 +513,12 @@ MMHandleType mmf_attrs_new(int count)
        attrs->count = count;
        attrs->items = (mmf_attribute_t *) malloc (sizeof(mmf_attribute_t) * count);
        memset(attrs->items, 0, sizeof(mmf_attribute_t) * count);
+
+       if (pthread_mutex_init(&attrs->write_lock, NULL) != 0) {
+               mmf_debug(MMF_DEBUG_ERROR, "mutex init failed");
+               return 0;
+       }
+
        return (MMHandleType) attrs;
 }
 
@@ -554,6 +560,7 @@ void mmf_attrs_free(MMHandleType h)
                        free(attrs->items);
                        attrs->items = NULL;
                }
+               pthread_mutex_destroy(&attrs->write_lock);
                free(attrs);
        }
 }
@@ -618,6 +625,8 @@ int mmf_attrs_commit(MMHandleType h)
        int i;
        int ret = 0;
 
+       MM_ATTRS_WRITE_LOCK(attrs);
+
        for (i = 0; i < attrs->count; ++i) {
                if (mmf_attribute_is_modified(&attrs->items[i])) {
                        if (attrs->commit_func) {
@@ -636,6 +645,9 @@ int mmf_attrs_commit(MMHandleType h)
                        }
                }
        }
+
+       MM_ATTRS_WRITE_UNLOCK(attrs);
+
        return ret;
 }
 
@@ -647,6 +659,8 @@ int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name)
 
        return_val_if_fail(h, -1);
 
+       MM_ATTRS_WRITE_LOCK(attrs);
+
        for (i = 0; i < attrs->count; ++i) {
                if (mmf_attribute_is_modified(&attrs->items[i])) {
                        if (attrs->commit_func) {
@@ -671,6 +685,9 @@ int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name)
                        }
                }
        }
+
+       MM_ATTRS_WRITE_UNLOCK(attrs);
+
        return ret;
 }
 
index 52664ce..3ca0200 100644 (file)
@@ -1,7 +1,7 @@
 Name:       libmm-common
 Summary:    Multimedia Framework Common Lib
 Version:    0.2.53
-Release:    1
+Release:    2
 Group:      TO_BE/FILLED_IN
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz