media_streamer_s *ms_streamer = (media_streamer_s *) user_data;
GstElement *src_element = NULL;
GstElement *found_element = NULL;
- media_streamer_node_s *found_node = NULL;
+ media_streamer_node_s *node = NULL;
GstPad *src_pad = NULL;
ms_debug_fenter();
g_object_ref(src_element);
g_value_set_boolean(ret, FALSE);
- found_node = (media_streamer_node_s *) g_hash_table_lookup(ms_streamer->nodes_table, GST_ELEMENT_NAME(src_element));
- if (!found_node) {
+ node = (media_streamer_node_s *) g_hash_table_lookup(ms_streamer->nodes_table,
+ GST_ELEMENT_NAME(src_element));
+ if (!node) {
/* If we fail to find corresponding node inside streamer
then apparently this element doesn't require resources. */
- ms_debug("Failed to find corresponding node [%s] inside streamer", GST_ELEMENT_NAME(src_element));
+ ms_debug("Could not find corresponding node [%s] inside streamer, skip it", GST_ELEMENT_NAME(src_element));
g_value_set_boolean(ret, TRUE);
+ g_object_unref(src_element);
return TRUE;
}
GST_ELEMENT_NAME(element));
if (!node) {
/* If we fail to find corresponding node inside streamer
- then apparently this element doesn't require resources */
- ms_info("Failed to find corresponding node [%s] inside streamer", GST_ELEMENT_NAME(element));
+ then apparently this element doesn't require resources. */
+ ms_debug("Could not find corresponding node [%s] inside streamer, skip it", GST_ELEMENT_NAME(element));
g_value_set_boolean(ret, TRUE);
g_object_unref(element);
return TRUE;
if (!node) {
/* If we fail to find corresponding node inside streamer
then apparently this element doesn't require resources. */
- ms_debug("Failed to find corresponding node [%s] inside streamer", GST_ELEMENT_NAME(element));
+ ms_debug("Could not find corresponding node [%s] inside streamer, skip it", GST_ELEMENT_NAME(element));
g_value_set_boolean(ret, TRUE);
g_object_unref(element);
return TRUE;
media_streamer_s *ms_streamer = (media_streamer_s *) user_data;
media_streamer_node_s *node = NULL;
GstElement *element = NULL;
+ gboolean allowed = FALSE;
ms_debug_fenter();
ms_retvm_if(ms_streamer->nodes_table == NULL, FALSE, "ms_streamer->nodes_table is NULL");
ms_retvm_if(ret == NULL, FALSE, "ret is NULL");
- g_value_set_boolean(ret, FALSE);
-
element = GST_ELEMENT(g_value_get_object(item));
g_object_ref(element);
GST_ELEMENT_NAME(element));
if (!node) {
/* If we fail to find corresponding node inside streamer
- then apparently this element doesn't require resources */
- ms_info("Failed to find corresponding node [%s] inside streamer", GST_ELEMENT_NAME(element));
+ then apparently this element doesn't require resources. */
+ ms_debug("Could not find corresponding node [%s] inside streamer, skip it", GST_ELEMENT_NAME(element));
g_value_set_boolean(ret, TRUE);
g_object_unref(element);
return TRUE;
}
- if (MEDIA_STREAMER_ERROR_NONE != ms_node_policy_check(node)) {
+ if (ms_node_policy_check(node, &allowed)) {
ms_error("Failed to check policy for node [%s]", node->name);
+ /* Note that it should be TRUE(allowed) if the DPM API failed. */
+ g_value_set_boolean(ret, TRUE);
g_object_unref(element);
return FALSE;
}
- g_value_set_boolean(ret, TRUE);
+ g_value_set_boolean(ret, allowed);
g_object_unref(element);
ms_debug_fleave();
- return TRUE;
+ return allowed;
}
subtype = node->subtype;
- ms_debug("Checking policy for node type %d, subtype %d", node->type, subtype);
+ ms_debug("Checking DPM policy for node type %d, subtype %d", node->type, subtype);
/* Check for node types */
switch (subtype) {
*policy = POLICY_TYPE_MIC;
break;
default:
+ *policy = POLICY_TYPE_NONE;
break;
}
interrupted_cb(MEDIA_STREAMER_INTERRUPTED_BY_SECURITY,
streamer->interrupted_cb.user_data);
} else {
- ms_info("Interuption will not be handled because interrupted_cb is NULL");
+ ms_info("Interruption will not be handled because interrupted_cb is NULL");
}
g_mutex_unlock(&streamer->mutex_lock);
ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
- /* Check if node require policy manager */
__ms_node_get_dpm_check_needed(node, &policy);
if (POLICY_TYPE_NONE == policy) {
- ms_info("No policy is needed for %p node type [%d] subtype [%d]",
+ ms_info("No need to check DPM restriction state for node [%p] type [%d] subtype [%d]",
node, node->type, node->subtype);
return MEDIA_STREAMER_ERROR_NONE;
}
- if (node->dpm_handle) {
- if (node->policy_changed_cb_id > 0)
- dpm_remove_policy_changed_cb(node->dpm_handle, node->policy_changed_cb_id);
- else
- ms_info("invalid dpm cb id");
+ ms_retvm_if(node->dpm_handle == NULL, MEDIA_STREAMER_ERROR_INVALID_OPERATION, "DPM handle is NULL");
- ms_debug("DPM released");
- }
+ if (node->policy_changed_cb_id > 0)
+ dpm_remove_policy_changed_cb(node->dpm_handle, node->policy_changed_cb_id);
+ else
+ ms_info("invalid dpm cb id");
+
+ ms_debug("DPM released");
dpm_manager_destroy(node->dpm_handle);
node->dpm_handle = NULL;
return ret;
}
-int ms_node_policy_check(media_streamer_node_s *node)
+int ms_node_policy_check(media_streamer_node_s *node, gboolean *allowed)
{
media_streamer_policy_type_e policy = POLICY_TYPE_NONE;
- int ret = MEDIA_STREAMER_ERROR_NONE;
int dpm_state = DPM_ALLOWED;
int dpm_ret = DPM_ERROR_NONE;
ms_debug_fenter();
ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+ ms_retvm_if(allowed == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "allowed is NULL");
+
+ *allowed = TRUE;
- /* Check if node require policy manager */
__ms_node_get_dpm_check_needed(node, &policy);
if (POLICY_TYPE_NONE == policy) {
- ms_info("No policy is needed for %p node type [%d] subtype [%d]",
+ ms_info("No need to check DPM restriction state for node [%p] type [%d] subtype [%d]",
node, node->type, node->subtype);
return MEDIA_STREAMER_ERROR_NONE;
}
- if (node->dpm_handle == NULL) {
- ms_error("DPM manager handle is NULL");
- return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
- }
+ ms_retvm_if(node->dpm_handle == NULL, MEDIA_STREAMER_ERROR_INVALID_OPERATION, "DPM handle is NULL");
switch (policy) {
case POLICY_TYPE_CAMERA:
break;
}
- if (dpm_ret == DPM_ERROR_NONE) {
- ms_info("DPM state - %d", dpm_state);
- if (dpm_state == DPM_DISALLOWED) {
- ms_error("Policy disallowed by DPM");
- return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
- }
- } else {
- ms_info("get DPM state failed, continue too work");
+ if (dpm_ret != DPM_ERROR_NONE) {
+ ms_error("Failed to get DPM restriction state");
+ return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+ }
+
+ ms_info("DPM state - %d", dpm_state);
+ if (dpm_state == DPM_DISALLOWED) {
+ ms_error("Policy disallowed by DPM");
+ *allowed = FALSE;
}
ms_debug_fleave();
- return ret;
+ return MEDIA_STREAMER_ERROR_NONE;
}