*/
#include "BarcodeUtils.h"
-#include "mv_common_c.h"
+#include "mv_common.h"
#include <mv_private.h>
unsigned int size = 0;
mv_colorspace_e colorspace = MEDIA_VISION_COLORSPACE_INVALID;
- err = mv_source_get_colorspace_c(mvSource, &colorspace);
+ err = mv_source_get_colorspace(mvSource, &colorspace);
if (err != MEDIA_VISION_ERROR_NONE) {
LOGE("Can't determine mv_source_h colorspace to convert"
" to ZBar colorspace. Conversion failed");
return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
}
- err = mv_source_get_buffer_c(mvSource, &buffer, &size);
+ err = mv_source_get_buffer(mvSource, &buffer, &size);
if (err != MEDIA_VISION_ERROR_NONE) {
LOGE("Can't get mv_source_h buffer to convert to ZBar image. Conversion failed");
return err;
}
- err = mv_source_get_height_c(mvSource, &height);
+ err = mv_source_get_height(mvSource, &height);
if (err != MEDIA_VISION_ERROR_NONE) {
LOGE("Can't get mv_source_h height for conversion. Conversion failed");
return err;
}
- err = mv_source_get_width_c(mvSource, &width);
+ err = mv_source_get_width(mvSource, &width);
if (err != MEDIA_VISION_ERROR_NONE) {
LOGE("Can't get mv_source_h width for conversion. Conversion failed");
return err;
#include "mv_barcode_generate_open.h"
-#include "mv_common_c.h"
+#include "mv_common.h"
#include "BarcodeGenerator.h"
#include <mv_private.h>
"Buffer size = %ui x %ui; Channels = %ui; Message = %s",
imageWidth, imageHeight, imageChannels, messageStr.c_str());
- error = mv_source_fill_by_buffer_c(image, imageBuffer, imageBufferSize, imageWidth, imageHeight,
- MEDIA_VISION_COLORSPACE_RGB888);
+ error = mv_source_fill_by_buffer(image, imageBuffer, imageBufferSize, imageWidth, imageHeight,
+ MEDIA_VISION_COLORSPACE_RGB888);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Meidiavision source fill by generated buffer failed");
+++ /dev/null
-/**
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MEDIA_VISION_COMMON_C_H__
-#define __MEDIA_VISION_COMMON_C_H__
-
-#include "mv_common.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @file mv_common_c.h
- * @brief This file contains the Media Vision Common module API.
- */
-
-/**
- * @brief Creates a source handle.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @remarks You must release @a source by using @ref mv_destroy_source_c().
- * @param [out] source A new handle to the source
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @see mv_destroy_source_c()
- */
-int mv_create_source_c(mv_source_h *source);
-
-/**
- * @brief Destroys the source handle and releases all its resources.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] source The handle to the source to be destroyed
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_create_source_c()
- */
-int mv_destroy_source_c(mv_source_h source);
-
-/**
- * @brief Fills the media source based on the media packet.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in,out] source The handle to the source
- * @param [in] media_packet The handle to the media packet from which
- * will be filled the source
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported media format
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @pre Create a source handle by calling @ref mv_create_source_c()
- *
- * @see mv_create_source_c()
- * @see mv_destroy_source_c()
- */
-int mv_source_fill_by_media_packet_c(mv_source_h source, media_packet_h media_packet);
-
-/**
- * @brief Fills the media source based on the buffer and metadata.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in,out] source The handle to the source
- * @param [in] data_buffer The buffer of image data
- * @param [in] buffer_size The buffer size
- * @param [in] image_width The image width
- * @param [in] image_height The image height
- * @param [in] image_colorspace The image colorspace
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @pre Create a source handle by calling @ref mv_create_source_c()
- *
- * @see mv_source_clear_c()
- */
-int mv_source_fill_by_buffer_c(mv_source_h source, unsigned char *data_buffer, unsigned int buffer_size,
- unsigned int image_width, unsigned int image_height, mv_colorspace_e image_colorspace);
-
-/**
- * @brief Clears the buffer of the media source.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] source The handle to the source
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_source_fill_by_buffer_c()
- */
-int mv_source_clear_c(mv_source_h source);
-
-/**
- * @brief Gets buffer of the media source.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @remarks Note that the retrieved buffer will be destroyed when
- * @ref mv_destroy_source_c() or @ref mv_source_clear_c() function
- * is called for the @a source.
- *
- * @param [in] source The handle to the source
- * @param [out] data_buffer The buffer of the source
- * @param [out] buffer_size The size of buffer
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_source_get_width_c()
- * @see mv_source_get_height_c()
- * @see mv_source_get_colorspace_c()
- */
-int mv_source_get_buffer_c(mv_source_h source, unsigned char **data_buffer, unsigned int *buffer_size);
-
-/**
- * @brief Gets height of the media source.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] source The handle to the source
- * @param [out] image_height The height of the source
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_source_get_width_c()
- * @see mv_source_get_colorspace_c()
- * @see mv_source_get_buffer_c()
- */
-int mv_source_get_height_c(mv_source_h source, unsigned int *image_height);
-
-/**
- * @brief Gets width of the media source.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] source The handle to the source
- * @param [out] image_width The width of the source
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_source_get_height_c()
- * @see mv_source_get_colorspace_c()
- * @see mv_source_get_buffer_c()
- */
-int mv_source_get_width_c(mv_source_h source, unsigned int *image_width);
-
-/**
- * @brief Gets colorspace of the media source.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] source The handle to the source
- * @param [out] image_colorspace The colorspace of the source
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_source_get_width_c()
- * @see mv_source_get_height_c()
- * @see mv_source_get_buffer_c()
- */
-int mv_source_get_colorspace_c(mv_source_h source, mv_colorspace_e *image_colorspace);
-
-/**
- * @brief Creates the handle to the configuration of engine.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [out] engine_cfg The handle to the engine to be created
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @see mv_engine_config_h
- * @see mv_destroy_engine_config_c()
- * @see mv_engine_config_set_double_attribute_c()
- * @see mv_engine_config_set_int_attribute_c()
- * @see mv_engine_config_set_bool_attribute_c()
- * @see mv_engine_config_set_string_attribute_c()
- * @see mv_engine_config_get_double_attribute_c()
- * @see mv_engine_config_get_int_attribute_c()
- * @see mv_engine_config_get_bool_attribute_c()
- * @see mv_engine_config_get_string_attribute_c()
- */
-int mv_create_engine_config_c(mv_engine_config_h *engine_cfg);
-
-/**
- * @brief Destroys the engine configuration handle and releases all its
- * resources.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] engine_cfg The handle to the engine configuration
- * to be destroyed
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_engine_config_h
- * @see mv_create_engine_config_c()
- */
-int mv_destroy_engine_config_c(mv_engine_config_h engine_cfg);
-
-/**
- * @brief Sets the double attribute to the configuration.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] engine_cfg Engine configuration for which @a value has
- * to be set
- * @param [in] name String key of the attribute will be used for
- * storing the @a value into configuration
- * dictionary
- * @param [in] value The double value of the attribute
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_engine_config_get_double_attribute_c()
- * @see mv_engine_config_set_int_attribute_c()
- * @see mv_engine_config_set_bool_attribute_c()
- * @see mv_engine_config_set_string_attribute_c()
- */
-int mv_engine_config_set_double_attribute_c(mv_engine_config_h engine_cfg, const char *name, double value);
-
-/**
- * @brief Sets the integer attribute to the configuration.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] engine_cfg Engine configuration for which @a value has
- * to be set
- * @param [in] name String key of the attribute will be used for
- * storing the @a value into configuration
- * dictionary
- * @param [in] value The integer value of the attribute
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_engine_config_get_int_attribute_c()
- * @see mv_engine_config_set_double_attribute_c()
- * @see mv_engine_config_set_bool_attribute_c()
- * @see mv_engine_config_set_string_attribute_c()
- */
-int mv_engine_config_set_int_attribute_c(mv_engine_config_h engine_cfg, const char *name, int value);
-
-/**
- * @brief Sets the boolean attribute to the configuration.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] engine_cfg Engine configuration for which @a value has
- * to be set
- * @param [in] name String key of the attribute will be used for
- * storing the @a value into configuration
- * dictionary
- * @param [in] value The boolean value of the attribute
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_engine_config_get_bool_attribute_c()
- * @see mv_engine_config_set_double_attribute_c()
- * @see mv_engine_config_set_int_attribute_c()
- * @see mv_engine_config_set_string_attribute_c()
- */
-int mv_engine_config_set_bool_attribute_c(mv_engine_config_h engine_cfg, const char *name, bool attribute);
-
-/**
- * @brief Sets the string attribute to the configuration.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] engine_cfg Engine configuration for which @a value has
- * to be set
- * @param [in] name String key of the attribute will be used for
- * storing the @a value into configuration
- * dictionary
- * @param [in] value The string value of the attribute
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_engine_config_get_string_attribute_c()
- * @see mv_engine_config_set_double_attribute_c()
- * @see mv_engine_config_set_int_attribute_c()
- * @see mv_engine_config_set_bool_attribute_c()
- */
-int mv_engine_config_set_string_attribute_c(mv_engine_config_h engine_cfg, const char *name, const char *value);
-
-/**
- * @brief Sets the array of string attribute to the configuration.
- *
- * @since_tizen 5.5
- * @param [in] engine_cfg Engine configuration for which @a values has
- * to be set
- * @param [in] name String key of the attribute will be used for
- * storing the @a values into configuration
- * dictionary
- * @param [in] values The string values of the attribute
- * @param [in] size The number of string @values
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see mv_engine_config_get_array_string_attribute_c()
- */
-int mv_engine_config_set_array_string_attribute_c(mv_engine_config_h engine_cfg, const char *name, const char **values,
- unsigned int size);
-
-/**
- * @brief Gets the double attribute from the configuration dictionary.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] engine_cfg Engine configuration from which @a value
- * has to be gotten
- * @param [in] name String key of the attribute will be used for
- * getting the @a value from the
- * configuration dictionary
- * @param [out] value The attribute to be filled with double value
- * from dictionary
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE Parameter key isn't available
- *
- * @see mv_engine_config_set_double_attribute_c()
- * @see mv_engine_config_get_int_attribute_c()
- * @see mv_engine_config_get_bool_attribute_c()
- * @see mv_engine_config_get_string_attribute_c()
- */
-int mv_engine_config_get_double_attribute_c(mv_engine_config_h engine_cfg, const char *name, double *value);
-
-/**
- * @brief Gets the integer attribute from the configuration dictionary.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] engine_cfg Engine configuration from which @a value
- * has to be gotten
- * @param [in] name String key of the attribute will be used for
- * getting the @a value from the
- * configuration dictionary
- * @param [out] value The attribute to be filled with integer value
- * from dictionary
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE Parameter key isn't available
- *
- * @see mv_engine_config_set_int_attribute_c()
- * @see mv_engine_config_get_double_attribute_c()
- * @see mv_engine_config_get_bool_attribute_c()
- * @see mv_engine_config_get_string_attribute_c()
- */
-int mv_engine_config_get_int_attribute_c(mv_engine_config_h engine_cfg, const char *name, int *value);
-
-/**
- * @brief Gets the boolean attribute from the configuration dictionary.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @param [in] engine_cfg Engine configuration from which @a value
- * has to be gotten
- * @param [in] name String key of the attribute will be used for
- * getting the @a value from the
- * configuration dictionary
- * @param [out] value The attribute to be filled with boolean value
- * from dictionary
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE Parameter key isn't available
- *
- * @see mv_engine_config_set_bool_attribute_c()
- * @see mv_engine_config_get_double_attribute_c()
- * @see mv_engine_config_get_int_attribute_c()
- * @see mv_engine_config_get_string_attribute_c()
- */
-int mv_engine_config_get_bool_attribute_c(mv_engine_config_h engine_cfg, const char *name, bool *value);
-
-/**
- * @brief Gets the string attribute from the configuration dictionary.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @remarks Function allocates memory required for output @a value, so
- * it has to be removed by the user himself.
- * @param [in] engine_cfg Engine configuration from which @a value
- * has to be gotten
- * @param [in] name String key of the attribute will be used for
- * getting the @a value from the
- * configuration dictionary
- * @param [out] value The attribute to be filled with string value
- * from dictionary
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE Parameter key isn't available
- *
- * @see mv_engine_config_set_string_attribute_c()
- * @see mv_engine_config_get_double_attribute_c()
- * @see mv_engine_config_get_int_attribute_c()
- * @see mv_engine_config_get_bool_attribute_c()
- */
-int mv_engine_config_get_string_attribute_c(mv_engine_config_h engine_cfg, const char *name, char **value);
-
-/**
- * @brief Gets the array of string attribute from the configuration dictionary.
- *
- * @since_tizen 5.5
- * @remarks Function allocates memory required for output @a values, so
- * it has to be removed by the user himself.
- * @param [in] engine_cfg Engine configuration from which @a values
- * has to be gotten
- * @param [in] name String key of the attribute will be used for
- * getting the @a values from the
- * configuration dictionary
- * @param [out] values The attribute to be filled with string value
- * from dictionary
- * @param [out] size The number of elements in @a values
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE Parameter key isn't available
- *
- * @see mv_engine_config_set_array_string_attribute_c()
- */
-int mv_engine_config_get_array_string_attribute_c(mv_engine_config_h engine_cfg, const char *name, char ***values,
- int *size);
-
-/**
- * @brief Traverses the list of supported attribute names and types.
- * @details Using this function names of supported attributes can be obtained.
- * Names of the attributes can be used with @ref mv_engine_config_h
- * related getters and setters to get/set appropriate attribute values.
- *
- * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
- * @remarks If @a callback is called zero times after
- * @ref mv_engine_config_foreach_supported_attribute() call, then
- * engine configuration is not supported and setting of attributes will
- * cause no effect. In this case for all Media Vision functions which
- * require @ref mv_engine_config_h handle as in parameter this
- * parameter can be set NULL.
- * @remarks If @a callback is called at least once, then attribute names and
- * types obtained in the @ref mv_supported_attribute_cb callback can be
- * changed after mv_engine_config_h handle creation (with
- * @ref mv_create_engine_config_c() function) by corresponding setters.
- * Although, if attributes aren't changed by setters, then default
- * values will be used.\n
- * Changing of attribute values will affect internal functionality
- * provided by concrete library underlying Media Vision API.
- * @param [in] callback The iteration callback function
- * @param [in] user_data The user data to be passed to the callback function
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * (@a callback can't be NULL)
- * @retval #MEDIA_VISION_ERROR_NO_DATA Can't determine list of supported attributes
- *
- * @see mv_engine_config_set_double_attribute_c()
- * @see mv_engine_config_set_int_attribute_c()
- * @see mv_engine_config_set_bool_attribute_c()
- * @see mv_engine_config_set_string_attribute_c()
- * @see mv_engine_config_get_double_attribute_c()
- * @see mv_engine_config_get_int_attribute_c()
- * @see mv_engine_config_get_bool_attribute_c()
- * @see mv_engine_config_get_string_attribute_c()
- */
-int mv_engine_config_foreach_supported_attribute_c(mv_supported_attribute_cb callback, void *user_data);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MEDIA_VISION_COMMON_C_H__ */
+++ /dev/null
-/**
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "mv_common.h"
-#include "mv_common_c.h"
-
-int mv_create_source(mv_source_h *source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_create_source_c(source);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_destroy_source(mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_destroy_source_c(source);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_source_fill_by_media_packet(mv_source_h source, media_packet_h media_packet)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_INSTANCE_CHECK(media_packet);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_source_fill_by_media_packet_c(source, media_packet);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_source_fill_by_buffer(mv_source_h source, unsigned char *data_buffer, unsigned int buffer_size,
- unsigned int image_width, unsigned int image_height, mv_colorspace_e image_colorspace)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_NULL_ARG_CHECK(data_buffer);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_source_fill_by_buffer_c(source, data_buffer, buffer_size, image_width, image_height, image_colorspace);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_source_clear(mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_source_clear_c(source);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_source_get_buffer(mv_source_h source, unsigned char **data_buffer, unsigned int *buffer_size)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_NULL_ARG_CHECK(data_buffer);
- MEDIA_VISION_NULL_ARG_CHECK(buffer_size);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_source_get_buffer_c(source, data_buffer, buffer_size);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_source_get_height(mv_source_h source, unsigned int *image_height)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_NULL_ARG_CHECK(image_height);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_source_get_height_c(source, image_height);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_source_get_width(mv_source_h source, unsigned int *image_width)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_NULL_ARG_CHECK(image_width);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_source_get_width_c(source, image_width);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_source_get_colorspace(mv_source_h source, mv_colorspace_e *image_colorspace)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_NULL_ARG_CHECK(image_colorspace);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_source_get_colorspace_c(source, image_colorspace);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_create_engine_config(mv_engine_config_h *engine_cfg)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(engine_cfg);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_create_engine_config_c(engine_cfg);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_destroy_engine_config(mv_engine_config_h engine_cfg)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_destroy_engine_config_c(engine_cfg);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_set_double_attribute(mv_engine_config_h engine_cfg, const char *name, double value)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_set_double_attribute_c(engine_cfg, name, value);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_set_int_attribute(mv_engine_config_h engine_cfg, const char *name, int value)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_set_int_attribute_c(engine_cfg, name, value);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_set_bool_attribute(mv_engine_config_h engine_cfg, const char *name, bool value)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_set_bool_attribute_c(engine_cfg, name, value);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_set_string_attribute(mv_engine_config_h engine_cfg, const char *name, const char *value)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
- MEDIA_VISION_NULL_ARG_CHECK(value);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_set_string_attribute_c(engine_cfg, name, value);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_set_array_string_attribute(mv_engine_config_h engine_cfg, const char *name, const char **values,
- unsigned int size)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
- MEDIA_VISION_NULL_ARG_CHECK(values);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_engine_config_set_array_string_attribute_c(engine_cfg, name, values, size);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_get_double_attribute(mv_engine_config_h engine_cfg, const char *name, double *value)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
- MEDIA_VISION_NULL_ARG_CHECK(value);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_get_double_attribute_c(engine_cfg, name, value);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_get_int_attribute(mv_engine_config_h engine_cfg, const char *name, int *value)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
- MEDIA_VISION_NULL_ARG_CHECK(value);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_get_int_attribute_c(engine_cfg, name, value);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_get_bool_attribute(mv_engine_config_h engine_cfg, const char *name, bool *value)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
- MEDIA_VISION_NULL_ARG_CHECK(value);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_get_bool_attribute_c(engine_cfg, name, value);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_get_string_attribute(mv_engine_config_h engine_cfg, const char *name, char **value)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
- MEDIA_VISION_NULL_ARG_CHECK(value);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_get_string_attribute_c(engine_cfg, name, value);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_get_array_string_attribute(mv_engine_config_h engine_cfg, const char *name, char ***values,
- int *size)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
- MEDIA_VISION_NULL_ARG_CHECK(name);
- MEDIA_VISION_NULL_ARG_CHECK(values);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_get_array_string_attribute_c(engine_cfg, name, values, size);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_engine_config_foreach_supported_attribute(mv_supported_attribute_cb callback, void *user_data)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(callback);
-
- MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_engine_config_foreach_supported_attribute_c(callback, user_data);
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
--- /dev/null
+/**
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <new>
+#include <memory>
+#include <string.h>
+#include <stdlib.h>
+#include <stdexcept>
+
+#include <media_packet.h>
+#include <mv_common.h>
+#include <mv_common_internal.h>
+#include <mv_private.h>
+
+#include "MediaSource.h"
+#include "EngineConfig.h"
+
+int mv_create_source(mv_source_h *source)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(source);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ LOGD("Creating media vision source");
+ (*source) = (static_cast<mv_source_h>(new (std::nothrow) MediaVision::Common::MediaSource()));
+
+ if (*source == NULL) {
+ LOGE("Failed to create media vision source");
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+ LOGD("Media vision source [%p] has been created", *source);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_destroy_source(mv_source_h source)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ LOGD("Destroying media vision source [%p]", source);
+ delete (static_cast<MediaVision::Common::MediaSource *>(source));
+ LOGD("Media vision source has been destroyed");
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_fill_by_media_packet(mv_source_h source, media_packet_h media_packet)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_INSTANCE_CHECK(media_packet);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ bool is_video = false;
+ unsigned int ind = 0;
+ uint32_t plane_num = 0;
+ int image_width = 0;
+ int image_height = 0;
+
+ media_format_h format = NULL;
+ media_format_mimetype_e mimetype = MEDIA_FORMAT_I420;
+ unsigned char *data_buffer = NULL;
+ mv_colorspace_e image_colorspace = MEDIA_VISION_COLORSPACE_INVALID;
+
+ int ret = media_packet_is_video(media_packet, &is_video);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_is_video() failed, mv_source_h fill skipped");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!is_video) {
+ LOGE("Media packet isn't video, mv_source_h fill skipped");
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
+ }
+
+ ret = media_packet_get_format(media_packet, &format);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_get_format() failed, mv_source_h fill skipped");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = media_format_get_video_info(format, &mimetype, &image_width, &image_height, NULL, NULL);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ if (media_format_unref(format) != MEDIA_PACKET_ERROR_NONE)
+ LOGE("media_format_unref() failed, mv_source_h fill skipped");
+
+ LOGE("media_format_get_video_info() failed, mv_source_h fill skipped");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+ ret = media_format_unref(format);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_format_unref() failed, mv_source_h fill skipped");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (mimetype > MEDIA_FORMAT_H261 && mimetype <= MEDIA_FORMAT_MPEG4_ASP) {
+ LOGE("Media format mimetype is not the raw video, mv_source_h fill skipped");
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
+ }
+
+ switch (mimetype) {
+ case MEDIA_FORMAT_I420:
+ image_colorspace = MEDIA_VISION_COLORSPACE_I420;
+ break;
+ case MEDIA_FORMAT_NV12:
+ image_colorspace = MEDIA_VISION_COLORSPACE_NV12;
+ break;
+ case MEDIA_FORMAT_YV12:
+ image_colorspace = MEDIA_VISION_COLORSPACE_YV12;
+ break;
+ case MEDIA_FORMAT_NV21:
+ image_colorspace = MEDIA_VISION_COLORSPACE_NV21;
+ break;
+ case MEDIA_FORMAT_YUYV:
+ image_colorspace = MEDIA_VISION_COLORSPACE_YUYV;
+ break;
+ case MEDIA_FORMAT_UYVY:
+ image_colorspace = MEDIA_VISION_COLORSPACE_UYVY;
+ break;
+ case MEDIA_FORMAT_422P:
+ image_colorspace = MEDIA_VISION_COLORSPACE_422P;
+ break;
+ case MEDIA_FORMAT_RGB565:
+ image_colorspace = MEDIA_VISION_COLORSPACE_RGB565;
+ break;
+ case MEDIA_FORMAT_RGB888:
+ image_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
+ break;
+ case MEDIA_FORMAT_RGBA:
+ image_colorspace = MEDIA_VISION_COLORSPACE_RGBA;
+ break;
+ default:
+ LOGE("Format of the media packet buffer is not supported by media "
+ "vision source (media_format_h mimetype=%i)",
+ mimetype);
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
+ }
+
+ ret = media_packet_get_number_of_video_planes(media_packet, &plane_num);
+ if (plane_num <= 0 || ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("invalid plane_num [%d] is returned", plane_num);
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+ LOGI("%d planes with color_space [%d]", plane_num, image_colorspace);
+
+ MediaVision::Common::MediaSource *mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
+ try {
+ mediaSource->setFormat((unsigned int) (image_width), (unsigned int) (image_height), image_colorspace,
+ media_packet);
+ } catch (const std::exception &e) {
+ return MEDIA_VISION_ERROR_INTERNAL;
+ }
+
+ for (ind = 0; ind < plane_num; ++ind) {
+ ret = media_packet_get_video_stride_width(media_packet, ind, &image_width);
+ if (image_width <= 0 || ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("invalid plane width [%d]", image_width);
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = media_packet_get_video_stride_height(media_packet, ind, &image_height);
+ if (image_height <= 0 || ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("invalid plane width [%d]", image_height);
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = media_packet_get_video_plane_data_ptr(media_packet, ind, (void **) &data_buffer);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_get_video_plane_data_ptr() plane[%d] failed, mv_source_h fill skipped", ind);
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+ MediaVision::Common::Plane plane { data_buffer, (unsigned int) (image_width * image_height),
+ (unsigned int) (image_width) };
+ mediaSource->addPlane(plane);
+ }
+
+ LOGD("Media source has been filled from media packet");
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_fill_by_buffer(mv_source_h source, unsigned char *data_buffer, unsigned int buffer_size,
+ unsigned int image_width, unsigned int image_height, mv_colorspace_e image_colorspace)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_NULL_ARG_CHECK(buffer_size);
+ MEDIA_VISION_NULL_ARG_CHECK(data_buffer);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ if (!(static_cast<MediaVision::Common::MediaSource *>(source))
+ ->fill(data_buffer, buffer_size, image_width, image_height, image_colorspace)) {
+ LOGE("mv_source_h filling from buffer failed");
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ LOGD("Media source has been filled from buffer");
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_clear(mv_source_h source)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ LOGD("Clear media vision source [%p]", source);
+ (static_cast<MediaVision::Common::MediaSource *>(source))->clear();
+ LOGD("Media vision source [%p] has been cleared", source);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_get_buffer(mv_source_h source, unsigned char **data_buffer, unsigned int *buffer_size)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_NULL_ARG_CHECK(data_buffer);
+ MEDIA_VISION_NULL_ARG_CHECK(buffer_size);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ LOGD("Get media vision source [%p] buffer and buffer size to be returned", source);
+ *data_buffer = (static_cast<MediaVision::Common::MediaSource *>(source))->getBuffer();
+ *buffer_size = (static_cast<MediaVision::Common::MediaSource *>(source))->getBufferSize();
+ LOGD("Media vision source [%p] buffer (%p) and buffer size (%ui) has been returned", source, data_buffer,
+ *buffer_size);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_get_height(mv_source_h source, unsigned int *image_height)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_NULL_ARG_CHECK(image_height);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ LOGD("Get media vision source [%p] height to be returned", source);
+ *image_height = (static_cast<MediaVision::Common::MediaSource *>(source))->getHeight();
+ LOGD("Media vision source [%p] height (%ui) has been returned", source, *image_height);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_get_width(mv_source_h source, unsigned int *image_width)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_NULL_ARG_CHECK(image_width);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ LOGD("Get media vision source [%p] width to be returned", source);
+ *image_width = (static_cast<MediaVision::Common::MediaSource *>(source))->getWidth();
+ LOGD("Media vision source [%p] width (%ui) has been returned", source, *image_width);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_get_colorspace(mv_source_h source, mv_colorspace_e *image_colorspace)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_NULL_ARG_CHECK(image_colorspace);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ LOGD("Get media vision source [%p] colorspace to be returned", source);
+ *image_colorspace = (static_cast<MediaVision::Common::MediaSource *>(source))->getColorspace();
+ LOGD("Media vision source [%p] colorspace (%i) has been returned", source, *image_colorspace);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_create_engine_config(mv_engine_config_h *engine_cfg)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(engine_cfg);
+ MEDIA_VISION_FUNCTION_ENTER();
+ LOGD("Creating media vision engine config");
+ try {
+ (*engine_cfg) = static_cast<mv_engine_config_h>(new MediaVision::Common::EngineConfig());
+ } catch (...) {
+ LOGE("Failed to create mv_engine_config_h handle");
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+ LOGD("Media vision engine config [%p] has been created", *engine_cfg);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_destroy_engine_config(mv_engine_config_h engine_cfg)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ LOGD("Destroying media vision engine config [%p]", engine_cfg);
+ delete (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg));
+ LOGD("Media vision engine config has been destroyed");
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_engine_config_set_double_attribute(mv_engine_config_h engine_cfg, const char *name, double value)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->setAttribute(std::string(name), value);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to set attribute [%s] with value %f. Error code (0x%08x)", name, value, ret);
+ return ret;
+ }
+
+ LOGD("Attribute [%s] (value %f) has been set", name, value);
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_set_int_attribute(mv_engine_config_h engine_cfg, const char *name, int value)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->setAttribute(std::string(name), value);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to set attribute [%s] with value %i. Error code (0x%08x)", name, value, ret);
+ return ret;
+ }
+
+ LOGD("Attribute [%s] (value %i) has been set", name, value);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_set_bool_attribute(mv_engine_config_h engine_cfg, const char *name, bool value)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->setAttribute(std::string(name), value);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to set attribute [%s] with value %s. Error code (0x%08x)", name, value ? "TRUE" : "FALSE", ret);
+ return ret;
+ }
+
+ LOGD("Attribute [%s] (value %s) has been set", name, value ? "TRUE" : "FALSE");
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_set_string_attribute(mv_engine_config_h engine_cfg, const char *name, const char *value)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_NULL_ARG_CHECK(value);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
+ ->setAttribute(std::string(name), std::string(value));
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to set attribute [%s] with value %s. Error code (0x%08x)", name, value, ret);
+ return ret;
+ }
+
+ LOGD("Attribute [%s] (value %s) has been set", name, value);
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_set_array_string_attribute(mv_engine_config_h engine_cfg, const char *name, const char **values,
+ unsigned int size)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_NULL_ARG_CHECK(values);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ unsigned int elmIdx = 0;
+ std::vector<std::string> arrayValues;
+ for (elmIdx = 0; elmIdx < size; elmIdx++) {
+ arrayValues.push_back(std::string(values[elmIdx]));
+ }
+
+ if (arrayValues.size() != size) {
+ LOGE("Fail to set attribute: size is %d, but actual %zd", size, arrayValues.size());
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret =
+ (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->setAttribute(std::string(name), arrayValues);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to set attribute [%s]. Error code (0x%08x)", name, ret);
+ return ret;
+ }
+
+ LOGD("Attribute [%s] has been set", name);
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_get_double_attribute(mv_engine_config_h engine_cfg, const char *name, double *value)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_NULL_ARG_CHECK(value);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret =
+ (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->getDoubleAttribute(std::string(name), value);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
+ return ret;
+ }
+
+ LOGD("Attribute [%s] (value %f) has been gotten", name, *value);
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_get_int_attribute(mv_engine_config_h engine_cfg, const char *name, int *value)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_NULL_ARG_CHECK(value);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
+ ->getIntegerAttribute(std::string(name), value);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
+ return ret;
+ }
+
+ LOGD("Attribute [%s] (value %i) has been gotten", name, *value);
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_get_bool_attribute(mv_engine_config_h engine_cfg, const char *name, bool *value)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_NULL_ARG_CHECK(value);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
+ ->getBooleanAttribute(std::string(name), value);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
+ return ret;
+ }
+
+ LOGD("Attribute [%s] (value %s) has been gotten", name, *value ? "TRUE" : "FALSE");
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_get_string_attribute(mv_engine_config_h engine_cfg, const char *name, char **value)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_NULL_ARG_CHECK(value);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ std::string attributeValue;
+ int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
+ ->getStringAttribute(std::string(name), &attributeValue);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
+ return ret;
+ }
+
+ LOGD("Convert string to char*");
+ int stringSize = attributeValue.size();
+ (*value) = (char *) malloc(sizeof(char) * (stringSize + 1));
+ if ((*value) == NULL) {
+ LOGE("Failed to convert string to char*");
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ try {
+ size_t copiedSize = attributeValue.copy(*value, stringSize);
+ if (copiedSize != attributeValue.size()) {
+ LOGE("Conversion from string to char* failed");
+ free(*value);
+ (*value) = NULL;
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+ } catch (std::out_of_range &e) {
+ LOGE("Conversion from string to char* failed");
+ free(*value);
+ (*value) = NULL;
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+ (*value)[stringSize] = '\0';
+
+ LOGD("Attribute [%s] (value %s) has been gotten", name, *value);
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_get_array_string_attribute(mv_engine_config_h engine_cfg, const char *name, char ***values,
+ int *size)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(engine_cfg);
+ MEDIA_VISION_NULL_ARG_CHECK(name);
+ MEDIA_VISION_NULL_ARG_CHECK(values);
+ MEDIA_VISION_NULL_ARG_CHECK(size);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ std::vector<std::string> attributeValue;
+ int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
+ ->getStringAttribute(std::string(name), &attributeValue);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
+ return ret;
+ }
+
+ int attributeSize = attributeValue.size();
+ LOGD("Allocating %d arrays", attributeSize);
+
+ (*values) = (char **) malloc(sizeof(char *) * attributeSize);
+ if ((*values) == NULL) {
+ LOGE("Failed allocation");
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+ (*size) = attributeSize;
+
+ int stringSize = 0;
+ for (int idx = 0; idx < attributeSize; ++idx) {
+ stringSize = attributeValue[idx].size();
+ LOGI("Converting %s with length %d to char*", attributeValue[idx].c_str(), stringSize);
+ (*values)[idx] = (char *) malloc(sizeof(char) * (stringSize + 1));
+ if ((*values)[idx] == NULL) {
+ LOGE("Failed to convert string to char*");
+
+ for (int start = idx - 1; start >= 0; --start) {
+ free((*values)[start]);
+ ((*values)[start]) = NULL;
+ }
+
+ free(*values);
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (attributeValue[idx].copy((*values)[idx], stringSize) != attributeValue[idx].size()) {
+ LOGE("Conversion from string to char* failed");
+
+ for (int start = idx; start >= 0; --start) {
+ free((*values)[start]);
+ ((*values)[start]) = NULL;
+ }
+
+ free(*values);
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+ ((*values)[idx])[stringSize] = '\0';
+
+ LOGD("Attribute [%s] (value[%d] %s) has been gotten", name, idx, (*values)[idx]);
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_engine_config_foreach_supported_attribute(mv_supported_attribute_cb callback, void *user_data)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(callback);
+ MEDIA_VISION_NULL_ARG_CHECK(user_data);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ using namespace MediaVision::Common;
+ std::unique_ptr<EngineConfig> config;
+
+ try {
+ config = std::make_unique<EngineConfig>();
+ } catch (int &exception) {
+ return exception;
+ }
+
+ DictDblConstIter dblDictIter = config->getDefaultDblDict().begin();
+
+ while (dblDictIter != config->getDefaultDblDict().end()) {
+ if (!callback(MV_ENGINE_CONFIG_ATTR_TYPE_DOUBLE, dblDictIter->first.c_str(), user_data)) {
+ LOGD("Attribute names/types traverse has been stopped by the user");
+ return MEDIA_VISION_ERROR_NONE;
+ }
+ ++dblDictIter;
+ }
+
+ DictIntConstIter intDictIter = config->getDefaultIntDict().begin();
+
+ while (intDictIter != config->getDefaultIntDict().end()) {
+ if (!callback(MV_ENGINE_CONFIG_ATTR_TYPE_INTEGER, intDictIter->first.c_str(), user_data)) {
+ LOGD("Attribute names/types traverse has been stopped by the user");
+ return MEDIA_VISION_ERROR_NONE;
+ }
+ ++intDictIter;
+ }
+
+ DictBoolConstIter boolDictIter = config->getDefaultBoolDict().begin();
+
+ while (boolDictIter != config->getDefaultBoolDict().end()) {
+ if (!callback(MV_ENGINE_CONFIG_ATTR_TYPE_BOOLEAN, boolDictIter->first.c_str(), user_data)) {
+ LOGD("Attribute names/types traverse has been stopped by the user");
+ return MEDIA_VISION_ERROR_NONE;
+ }
+ ++boolDictIter;
+ }
+
+ DictStrConstIter strDictIter = config->getDefaultStrDict().begin();
+
+ while (strDictIter != config->getDefaultStrDict().end()) {
+ if (!callback(MV_ENGINE_CONFIG_ATTR_TYPE_STRING, strDictIter->first.c_str(), user_data)) {
+ LOGD("Attribute names/types traverse has been stopped by the user");
+ return MEDIA_VISION_ERROR_NONE;
+ }
+ ++strDictIter;
+ }
+
+ LOGD("Attribute names/types has been gotten");
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_get_timestamp(mv_source_h source, uint64_t *timestamp)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+
+ try {
+ auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
+ auto mediaTimestamp = mediaSource->getTimestamp();
+ *timestamp = mediaTimestamp.timestamp;
+ } catch (const std::exception &e) {
+ LOGE("%s", e.what());
+ return MEDIA_VISION_ERROR_INTERNAL;
+ }
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_set_timestamp(mv_source_h source, uint64_t timestamp)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+
+ try {
+ auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
+ auto mediaTimestamp = mediaSource->getTimestamp();
+ mediaTimestamp.timestamp = timestamp;
+ mediaSource->setTimestamp(mediaTimestamp);
+ } catch (const std::exception &e) {
+ LOGE("%s", e.what());
+ return MEDIA_VISION_ERROR_INTERNAL;
+ }
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_get_priv_timestamp(mv_source_h source, void **priv)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_NULL_ARG_CHECK(priv);
+
+ try {
+ auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
+ auto mediaTimestamp = mediaSource->getTimestamp();
+ *priv = mediaTimestamp.priv;
+ } catch (const std::exception &e) {
+ LOGE("%s", e.what());
+ return MEDIA_VISION_ERROR_INTERNAL;
+ }
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_source_set_priv_timestamp(mv_source_h source, void *priv)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_NULL_ARG_CHECK(priv);
+
+ try {
+ auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
+ auto mediaTimestamp = mediaSource->getTimestamp();
+ mediaTimestamp.priv = priv;
+ mediaSource->setTimestamp(mediaTimestamp);
+ } catch (const std::exception &e) {
+ LOGE("%s", e.what());
+ return MEDIA_VISION_ERROR_INTERNAL;
+ }
+ return MEDIA_VISION_ERROR_NONE;
+}
+++ /dev/null
-/**
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_common_c.h"
-
-#include "MediaSource.h"
-#include "EngineConfig.h"
-
-#include <mv_private.h>
-#include <mv_common_internal.h>
-
-#include <new>
-#include <memory>
-#include <string.h>
-#include <stdlib.h>
-#include <stdexcept>
-#include <media_packet.h>
-
-int mv_create_source_c(mv_source_h *source_ptr)
-{
- if (source_ptr == NULL)
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-
- LOGD("Creating media vision source");
- (*source_ptr) = (static_cast<mv_source_h>(new (std::nothrow) MediaVision::Common::MediaSource()));
-
- if (*source_ptr == NULL) {
- LOGE("Failed to create media vision source");
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
- LOGD("Media vision source [%p] has been created", *source_ptr);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_destroy_source_c(mv_source_h source)
-{
- if (!source) {
- LOGE("Media source can't be destroyed because handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- LOGD("Destroying media vision source [%p]", source);
- delete (static_cast<MediaVision::Common::MediaSource *>(source));
- LOGD("Media vision source has been destroyed");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_fill_by_media_packet_c(mv_source_h source, media_packet_h media_packet)
-{
- if (!source || !media_packet) {
- LOGE("Media source can't be filled by media_packet handle because "
- "one of the source or media_packet handles is NULL. "
- "source = %p; media_packet = %p",
- source, media_packet);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- bool is_video = false;
- unsigned int ind = 0;
- uint32_t plane_num = 0;
- int image_width = 0;
- int image_height = 0;
-
- media_format_h format = NULL;
- media_format_mimetype_e mimetype = MEDIA_FORMAT_I420;
- unsigned char *data_buffer = NULL;
- mv_colorspace_e image_colorspace = MEDIA_VISION_COLORSPACE_INVALID;
-
- int ret = media_packet_is_video(media_packet, &is_video);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_is_video() failed, mv_source_h fill skipped");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (!is_video) {
- LOGE("Media packet isn't video, mv_source_h fill skipped");
- return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
- }
-
- ret = media_packet_get_format(media_packet, &format);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_get_format() failed, mv_source_h fill skipped");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- ret = media_format_get_video_info(format, &mimetype, &image_width, &image_height, NULL, NULL);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- if (media_format_unref(format) != MEDIA_PACKET_ERROR_NONE)
- LOGE("media_format_unref() failed, mv_source_h fill skipped");
-
- LOGE("media_format_get_video_info() failed, mv_source_h fill skipped");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
- ret = media_format_unref(format);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_format_unref() failed, mv_source_h fill skipped");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (mimetype > MEDIA_FORMAT_H261 && mimetype <= MEDIA_FORMAT_MPEG4_ASP) {
- LOGE("Media format mimetype is not the raw video, mv_source_h fill skipped");
- return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
- }
-
- switch (mimetype) {
- case MEDIA_FORMAT_I420:
- image_colorspace = MEDIA_VISION_COLORSPACE_I420;
- break;
- case MEDIA_FORMAT_NV12:
- image_colorspace = MEDIA_VISION_COLORSPACE_NV12;
- break;
- case MEDIA_FORMAT_YV12:
- image_colorspace = MEDIA_VISION_COLORSPACE_YV12;
- break;
- case MEDIA_FORMAT_NV21:
- image_colorspace = MEDIA_VISION_COLORSPACE_NV21;
- break;
- case MEDIA_FORMAT_YUYV:
- image_colorspace = MEDIA_VISION_COLORSPACE_YUYV;
- break;
- case MEDIA_FORMAT_UYVY:
- image_colorspace = MEDIA_VISION_COLORSPACE_UYVY;
- break;
- case MEDIA_FORMAT_422P:
- image_colorspace = MEDIA_VISION_COLORSPACE_422P;
- break;
- case MEDIA_FORMAT_RGB565:
- image_colorspace = MEDIA_VISION_COLORSPACE_RGB565;
- break;
- case MEDIA_FORMAT_RGB888:
- image_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
- break;
- case MEDIA_FORMAT_RGBA:
- image_colorspace = MEDIA_VISION_COLORSPACE_RGBA;
- break;
- default:
- LOGE("Format of the media packet buffer is not supported by media "
- "vision source (media_format_h mimetype=%i)",
- mimetype);
- return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
- }
-
- ret = media_packet_get_number_of_video_planes(media_packet, &plane_num);
- if (plane_num <= 0 || ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("invalid plane_num [%d] is returned", plane_num);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
- LOGI("%d planes with color_space [%d]", plane_num, image_colorspace);
-
- MediaVision::Common::MediaSource *mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
- try {
- mediaSource->setFormat((unsigned int) (image_width), (unsigned int) (image_height), image_colorspace,
- media_packet);
- } catch (const std::exception &e) {
- return MEDIA_VISION_ERROR_INTERNAL;
- }
-
- for (ind = 0; ind < plane_num; ++ind) {
- ret = media_packet_get_video_stride_width(media_packet, ind, &image_width);
- if (image_width <= 0 || ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("invalid plane width [%d]", image_width);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- ret = media_packet_get_video_stride_height(media_packet, ind, &image_height);
- if (image_height <= 0 || ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("invalid plane width [%d]", image_height);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- ret = media_packet_get_video_plane_data_ptr(media_packet, ind, (void **) &data_buffer);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_get_video_plane_data_ptr() plane[%d] failed, mv_source_h fill skipped", ind);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
- MediaVision::Common::Plane plane { data_buffer, (unsigned int) (image_width * image_height),
- (unsigned int) (image_width) };
- mediaSource->addPlane(plane);
- }
-
- LOGD("Media source has been filled from media packet");
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_fill_by_buffer_c(mv_source_h source, unsigned char *data_buffer, unsigned int buffer_size,
- unsigned int image_width, unsigned int image_height, mv_colorspace_e image_colorspace)
-{
- if (!source || buffer_size == 0 || data_buffer == NULL) {
- LOGE("Media source can't be filled by buffer because "
- "one of the source or data_buffer is NULL or buffer_size = 0. "
- "source = %p; data_buffer = %p; buffer_size = %u",
- source, data_buffer, buffer_size);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (!(static_cast<MediaVision::Common::MediaSource *>(source))
- ->fill(data_buffer, buffer_size, image_width, image_height, image_colorspace)) {
- LOGE("mv_source_h filling from buffer failed");
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
-
- LOGD("Media source has been filled from buffer");
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_clear_c(mv_source_h source)
-{
- if (!source) {
- LOGE("Media source can't be cleared because source handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- LOGD("Clear media vision source [%p]", source);
- (static_cast<MediaVision::Common::MediaSource *>(source))->clear();
- LOGD("Media vision source [%p] has been cleared", source);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_get_buffer_c(mv_source_h source, unsigned char **buffer, unsigned int *size)
-{
- if (!source) {
- LOGE("Impossible to get buffer for NULL mv_source_h handle");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- LOGD("Get media vision source [%p] buffer and buffer size to be returned", source);
- *buffer = (static_cast<MediaVision::Common::MediaSource *>(source))->getBuffer();
- *size = (static_cast<MediaVision::Common::MediaSource *>(source))->getBufferSize();
- LOGD("Media vision source [%p] buffer (%p) and buffer size (%ui) has been returned", source, buffer, *size);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_get_height_c(mv_source_h source, unsigned int *height)
-{
- if (!source) {
- LOGE("Impossible to get height for NULL mv_source_h handle");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- LOGD("Get media vision source [%p] height to be returned", source);
- *height = (static_cast<MediaVision::Common::MediaSource *>(source))->getHeight();
- LOGD("Media vision source [%p] height (%ui) has been returned", source, *height);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_get_width_c(mv_source_h source, unsigned int *width)
-{
- if (!source) {
- LOGE("Impossible to get width for NULL mv_source_h handle");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- LOGD("Get media vision source [%p] width to be returned", source);
- *width = (static_cast<MediaVision::Common::MediaSource *>(source))->getWidth();
- LOGD("Media vision source [%p] width (%ui) has been returned", source, *width);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_get_colorspace_c(mv_source_h source, mv_colorspace_e *colorspace)
-{
- if (!source) {
- LOGE("Impossible to get colorspace for NULL mv_source_h handle");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- LOGD("Get media vision source [%p] colorspace to be returned", source);
- *colorspace = (static_cast<MediaVision::Common::MediaSource *>(source))->getColorspace();
- LOGD("Media vision source [%p] colorspace (%i) has been returned", source, *colorspace);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_create_engine_config_c(mv_engine_config_h *engine_cfg)
-{
- if (engine_cfg == NULL) {
- LOGE("Impossible to create mv_engine_config_h handle");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- LOGD("Creating media vision engine config");
- try {
- (*engine_cfg) = static_cast<mv_engine_config_h>(new MediaVision::Common::EngineConfig());
- } catch (...) {
- LOGE("Failed to create mv_engine_config_h handle");
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
- LOGD("Media vision engine config [%p] has been created", *engine_cfg);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_destroy_engine_config_c(mv_engine_config_h engine_cfg)
-{
- if (!engine_cfg) {
- LOGE("Impossible to destroy NULL mv_engine_config_h handle");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- LOGD("Destroying media vision engine config [%p]", engine_cfg);
- delete (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg));
- LOGD("Media vision engine config has been destroyed");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_engine_config_set_double_attribute_c(mv_engine_config_h engine_cfg, const char *name, double value)
-{
- if (!engine_cfg || name == NULL) {
- LOGE("Impossible to set attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p;",
- engine_cfg, name);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->setAttribute(std::string(name), value);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to set attribute [%s] with value %f. Error code (0x%08x)", name, value, ret);
- return ret;
- }
-
- LOGD("Attribute [%s] (value %f) has been set", name, value);
- return ret;
-}
-
-int mv_engine_config_set_int_attribute_c(mv_engine_config_h engine_cfg, const char *name, int value)
-{
- if (!engine_cfg || name == NULL) {
- LOGE("Impossible to set attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p;",
- engine_cfg, name);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->setAttribute(std::string(name), value);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to set attribute [%s] with value %i. Error code (0x%08x)", name, value, ret);
- return ret;
- }
-
- LOGD("Attribute [%s] (value %i) has been set", name, value);
-
- return ret;
-}
-
-int mv_engine_config_set_bool_attribute_c(mv_engine_config_h engine_cfg, const char *name, bool value)
-{
- if (!engine_cfg || name == NULL) {
- LOGE("Impossible to set attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p;",
- engine_cfg, name);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->setAttribute(std::string(name), value);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to set attribute [%s] with value %s. Error code (0x%08x)", name, value ? "TRUE" : "FALSE", ret);
- return ret;
- }
-
- LOGD("Attribute [%s] (value %s) has been set", name, value ? "TRUE" : "FALSE");
- return ret;
-}
-
-int mv_engine_config_set_string_attribute_c(mv_engine_config_h engine_cfg, const char *name, const char *value)
-{
- if (!engine_cfg || name == NULL || value == NULL) {
- LOGE("Impossible to set attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p; value = %p;",
- engine_cfg, name, value);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
- ->setAttribute(std::string(name), std::string(value));
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to set attribute [%s] with value %s. Error code (0x%08x)", name, value, ret);
- return ret;
- }
-
- LOGD("Attribute [%s] (value %s) has been set", name, value);
- return ret;
-}
-
-int mv_engine_config_set_array_string_attribute_c(mv_engine_config_h engine_cfg, const char *name, const char **values,
- unsigned int size)
-{
- if (!engine_cfg || name == NULL || values == NULL) {
- LOGE("Impossible to set attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p; values = %p;",
- engine_cfg, name, values);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- unsigned int elmIdx = 0;
- std::vector<std::string> arrayValues;
- for (elmIdx = 0; elmIdx < size; elmIdx++) {
- arrayValues.push_back(std::string(values[elmIdx]));
- }
-
- if (arrayValues.size() != size) {
- LOGE("Fail to set attribute: size is %d, but actual %zd", size, arrayValues.size());
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int ret =
- (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->setAttribute(std::string(name), arrayValues);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to set attribute [%s]. Error code (0x%08x)", name, ret);
- return ret;
- }
-
- LOGD("Attribute [%s] has been set", name);
- return ret;
-}
-
-int mv_engine_config_get_double_attribute_c(mv_engine_config_h engine_cfg, const char *name, double *value)
-{
- if (!engine_cfg || name == NULL || value == NULL) {
- LOGE("Impossible to get attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p; value = %p;",
- engine_cfg, name, value);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int ret =
- (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))->getDoubleAttribute(std::string(name), value);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
- return ret;
- }
-
- LOGD("Attribute [%s] (value %f) has been gotten", name, *value);
- return ret;
-}
-
-int mv_engine_config_get_int_attribute_c(mv_engine_config_h engine_cfg, const char *name, int *value)
-{
- if (!engine_cfg || name == NULL || value == NULL) {
- LOGE("Impossible to get attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p; value = %p;",
- engine_cfg, name, value);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
- ->getIntegerAttribute(std::string(name), value);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
- return ret;
- }
-
- LOGD("Attribute [%s] (value %i) has been gotten", name, *value);
- return ret;
-}
-
-int mv_engine_config_get_bool_attribute_c(mv_engine_config_h engine_cfg, const char *name, bool *value)
-{
- if (!engine_cfg || name == NULL || value == NULL) {
- LOGE("Impossible to get attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p; value = %p;",
- engine_cfg, name, value);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
- ->getBooleanAttribute(std::string(name), value);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
- return ret;
- }
-
- LOGD("Attribute [%s] (value %s) has been gotten", name, *value ? "TRUE" : "FALSE");
- return ret;
-}
-
-int mv_engine_config_get_string_attribute_c(mv_engine_config_h engine_cfg, const char *name, char **value)
-{
- if (!engine_cfg || name == NULL || value == NULL) {
- LOGE("Impossible to get attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p; value = %p;",
- engine_cfg, name, value);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- std::string attributeValue;
- int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
- ->getStringAttribute(std::string(name), &attributeValue);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
- return ret;
- }
-
- LOGD("Convert string to char*");
- int stringSize = attributeValue.size();
- (*value) = (char *) malloc(sizeof(char) * (stringSize + 1));
- if ((*value) == NULL) {
- LOGE("Failed to convert string to char*");
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
-
- try {
- size_t copiedSize = attributeValue.copy(*value, stringSize);
- if (copiedSize != attributeValue.size()) {
- LOGE("Conversion from string to char* failed");
- free(*value);
- (*value) = NULL;
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
- } catch (std::out_of_range &e) {
- LOGE("Conversion from string to char* failed");
- free(*value);
- (*value) = NULL;
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
- (*value)[stringSize] = '\0';
-
- LOGD("Attribute [%s] (value %s) has been gotten", name, *value);
- return ret;
-}
-
-int mv_engine_config_get_array_string_attribute_c(mv_engine_config_h engine_cfg, const char *name, char ***values,
- int *size)
-{
- if (!engine_cfg || name == NULL || values == NULL) {
- LOGE("Impossible to get attribute. One of the required parameters is "
- "NULL. engine_cfg = %p; name = %p; values = %p;",
- engine_cfg, name, values);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- std::vector<std::string> attributeValue;
- int ret = (static_cast<MediaVision::Common::EngineConfig *>(engine_cfg))
- ->getStringAttribute(std::string(name), &attributeValue);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get attribute [%s]. Error code (0x%08x)", name, ret);
- return ret;
- }
-
- int attributeSize = attributeValue.size();
- LOGD("Allocating %d arrays", attributeSize);
-
- (*values) = (char **) malloc(sizeof(char *) * attributeSize);
- if ((*values) == NULL) {
- LOGE("Failed allocation");
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
- (*size) = attributeSize;
-
- int stringSize = 0;
- for (int idx = 0; idx < attributeSize; ++idx) {
- stringSize = attributeValue[idx].size();
- LOGI("Converting %s with length %d to char*", attributeValue[idx].c_str(), stringSize);
- (*values)[idx] = (char *) malloc(sizeof(char) * (stringSize + 1));
- if ((*values)[idx] == NULL) {
- LOGE("Failed to convert string to char*");
-
- for (int start = idx - 1; start >= 0; --start) {
- free((*values)[start]);
- ((*values)[start]) = NULL;
- }
-
- free(*values);
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
-
- if (attributeValue[idx].copy((*values)[idx], stringSize) != attributeValue[idx].size()) {
- LOGE("Conversion from string to char* failed");
-
- for (int start = idx; start >= 0; --start) {
- free((*values)[start]);
- ((*values)[start]) = NULL;
- }
-
- free(*values);
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
- ((*values)[idx])[stringSize] = '\0';
-
- LOGD("Attribute [%s] (value[%d] %s) has been gotten", name, idx, (*values)[idx]);
- }
-
- return ret;
-}
-
-int mv_engine_config_foreach_supported_attribute_c(mv_supported_attribute_cb callback, void *user_data)
-{
- if (NULL == callback) {
- LOGE("Impossible to traverse supported by Media Vision engine "
- "configuration attributes. Callback is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- using namespace MediaVision::Common;
- std::unique_ptr<EngineConfig> config;
-
- try {
- config = std::make_unique<EngineConfig>();
- } catch (int &exception) {
- return exception;
- }
-
- DictDblConstIter dblDictIter = config->getDefaultDblDict().begin();
-
- while (dblDictIter != config->getDefaultDblDict().end()) {
- if (!callback(MV_ENGINE_CONFIG_ATTR_TYPE_DOUBLE, dblDictIter->first.c_str(), user_data)) {
- LOGD("Attribute names/types traverse has been stopped by the user");
- return MEDIA_VISION_ERROR_NONE;
- }
- ++dblDictIter;
- }
-
- DictIntConstIter intDictIter = config->getDefaultIntDict().begin();
-
- while (intDictIter != config->getDefaultIntDict().end()) {
- if (!callback(MV_ENGINE_CONFIG_ATTR_TYPE_INTEGER, intDictIter->first.c_str(), user_data)) {
- LOGD("Attribute names/types traverse has been stopped by the user");
- return MEDIA_VISION_ERROR_NONE;
- }
- ++intDictIter;
- }
-
- DictBoolConstIter boolDictIter = config->getDefaultBoolDict().begin();
-
- while (boolDictIter != config->getDefaultBoolDict().end()) {
- if (!callback(MV_ENGINE_CONFIG_ATTR_TYPE_BOOLEAN, boolDictIter->first.c_str(), user_data)) {
- LOGD("Attribute names/types traverse has been stopped by the user");
- return MEDIA_VISION_ERROR_NONE;
- }
- ++boolDictIter;
- }
-
- DictStrConstIter strDictIter = config->getDefaultStrDict().begin();
-
- while (strDictIter != config->getDefaultStrDict().end()) {
- if (!callback(MV_ENGINE_CONFIG_ATTR_TYPE_STRING, strDictIter->first.c_str(), user_data)) {
- LOGD("Attribute names/types traverse has been stopped by the user");
- return MEDIA_VISION_ERROR_NONE;
- }
- ++strDictIter;
- }
-
- LOGD("Attribute names/types has been gotten");
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_get_timestamp(mv_source_h source, uint64_t *timestamp)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- try {
- auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
- auto mediaTimestamp = mediaSource->getTimestamp();
- *timestamp = mediaTimestamp.timestamp;
- } catch (const std::exception &e) {
- LOGE("%s", e.what());
- return MEDIA_VISION_ERROR_INTERNAL;
- }
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_set_timestamp(mv_source_h source, uint64_t timestamp)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- try {
- auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
- auto mediaTimestamp = mediaSource->getTimestamp();
- mediaTimestamp.timestamp = timestamp;
- mediaSource->setTimestamp(mediaTimestamp);
- } catch (const std::exception &e) {
- LOGE("%s", e.what());
- return MEDIA_VISION_ERROR_INTERNAL;
- }
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_get_priv_timestamp(mv_source_h source, void **priv)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_NULL_ARG_CHECK(priv);
-
- try {
- auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
- auto mediaTimestamp = mediaSource->getTimestamp();
- *priv = mediaTimestamp.priv;
- } catch (const std::exception &e) {
- LOGE("%s", e.what());
- return MEDIA_VISION_ERROR_INTERNAL;
- }
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_source_set_priv_timestamp(mv_source_h source, void *priv)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_NULL_ARG_CHECK(priv);
-
- try {
- auto mediaSource = static_cast<MediaVision::Common::MediaSource *>(source);
- auto mediaTimestamp = mediaSource->getTimestamp();
- mediaTimestamp.priv = priv;
- mediaSource->setTimestamp(mediaTimestamp);
- } catch (const std::exception &e) {
- LOGE("%s", e.what());
- return MEDIA_VISION_ERROR_INTERNAL;
- }
- return MEDIA_VISION_ERROR_NONE;
-}
#ifndef __MEDIA_VISION_FACE_EXPRESSION_RECOGNIZER_H__
#define __MEDIA_VISION_FACE_EXPRESSION_RECOGNIZER_H__
-#include "mv_common_c.h"
+#include "mv_common.h"
#include "mv_face_open.h"
#include <opencv2/objdetect.hpp>
#ifndef __MEDIA_VISION_FACE_EYE_CONDITION_H__
#define __MEDIA_VISION_FACE_EYE_CONDITION_H__
-#include <mv_common_c.h>
+#include <mv_common.h>
#include <mv_face.h>
#include <opencv2/imgproc.hpp>
#include <opencv2/core.hpp>
-#include "mv_common_c.h"
+#include "mv_common.h"
/**
* @file FaceUtil.h
}
int algType = 0;
- mv_engine_config_get_int_attribute_c(working_cfg, "MV_FACE_RECOGNITION_MODEL_TYPE", &algType);
+ mv_engine_config_get_int_attribute(working_cfg, "MV_FACE_RECOGNITION_MODEL_TYPE", &algType);
if (0 < algType && 4 > algType)
recognitionParams.mRecognitionAlgType = (FaceRecognitionModelType) algType;
/* set face detection model */
char *haarcascadeFilepath;
- error = mv_engine_config_get_string_attribute_c(engine_cfg, "MV_FACE_DETECTION_MODEL_FILE_PATH",
- &haarcascadeFilepath);
+ error = mv_engine_config_get_string_attribute(engine_cfg, "MV_FACE_DETECTION_MODEL_FILE_PATH",
+ &haarcascadeFilepath);
if (error == MEDIA_VISION_ERROR_NONE) {
LOGI("Haarcascade file was set as default");
haarcascadeFilePathStr = std::string(haarcascadeFilepath);
}
/* Set roi to be detected */
- error = mv_engine_config_get_int_attribute_c(engine_cfg, MV_FACE_DETECTION_ROI_X, &roi.x);
+ error = mv_engine_config_get_int_attribute(engine_cfg, MV_FACE_DETECTION_ROI_X, &roi.x);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Error occurred during face detection roi (x) receiving."
" (%i)",
error);
- error = mv_engine_config_get_int_attribute_c(engine_cfg, MV_FACE_DETECTION_ROI_Y, &roi.y);
+ error = mv_engine_config_get_int_attribute(engine_cfg, MV_FACE_DETECTION_ROI_Y, &roi.y);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Error occurred during face detection roi (y) receiving."
" (%i)",
error);
- error = mv_engine_config_get_int_attribute_c(engine_cfg, MV_FACE_DETECTION_ROI_WIDTH, &roi.width);
+ error = mv_engine_config_get_int_attribute(engine_cfg, MV_FACE_DETECTION_ROI_WIDTH, &roi.width);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Error occurred during face detection roi (width) receiving."
" (%i)",
error);
- error = mv_engine_config_get_int_attribute_c(engine_cfg, MV_FACE_DETECTION_ROI_HEIGHT, &roi.height);
+ error = mv_engine_config_get_int_attribute(engine_cfg, MV_FACE_DETECTION_ROI_HEIGHT, &roi.height);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Error occurred during face detection roi (height) receiving."
" (%i)",
error);
/* Set minimum size to be detected */
- error = mv_engine_config_get_int_attribute_c(engine_cfg, MV_FACE_DETECTION_MIN_SIZE_WIDTH, &minWidth);
+ error = mv_engine_config_get_int_attribute(engine_cfg, MV_FACE_DETECTION_MIN_SIZE_WIDTH, &minWidth);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Error occurred during face detection minimum width receiving."
" (%i)",
error);
- error = mv_engine_config_get_int_attribute_c(engine_cfg, MV_FACE_DETECTION_MIN_SIZE_HEIGHT, &minHeight);
+ error = mv_engine_config_get_int_attribute(engine_cfg, MV_FACE_DETECTION_MIN_SIZE_HEIGHT, &minHeight);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Error occurred during face detection minimum height receiving."
" (%i)",
#include "mv_image_open.h"
#include "mv_private.h"
-#include "mv_common_c.h"
+#include "mv_common.h"
#include "ImageConfig.h"
#include "Features/FeatureExtractor.h"
featuresExtractingParams = DefaultConfiguration::getInstance().getObjectFeaturesExtractingParams();
- mv_engine_config_get_double_attribute_c(working_cfg, MV_IMAGE_RECOGNITION_OBJECT_SCALE_FACTOR,
- &featuresExtractingParams.ORB.mScaleFactor);
+ mv_engine_config_get_double_attribute(working_cfg, MV_IMAGE_RECOGNITION_OBJECT_SCALE_FACTOR,
+ &featuresExtractingParams.ORB.mScaleFactor);
- mv_engine_config_get_int_attribute_c(working_cfg, MV_IMAGE_RECOGNITION_OBJECT_MAX_KEYPOINTS_NUM,
- &featuresExtractingParams.ORB.mMaximumFeaturesNumber);
+ mv_engine_config_get_int_attribute(working_cfg, MV_IMAGE_RECOGNITION_OBJECT_MAX_KEYPOINTS_NUM,
+ &featuresExtractingParams.ORB.mMaximumFeaturesNumber);
if (NULL == engine_cfg)
mv_destroy_engine_config(working_cfg);
featuresExtractingParams = DefaultConfiguration::getInstance().getSceneFeaturesExtractingParams();
- mv_engine_config_get_double_attribute_c(working_cfg, MV_IMAGE_RECOGNITION_SCENE_SCALE_FACTOR,
- &featuresExtractingParams.ORB.mScaleFactor);
+ mv_engine_config_get_double_attribute(working_cfg, MV_IMAGE_RECOGNITION_SCENE_SCALE_FACTOR,
+ &featuresExtractingParams.ORB.mScaleFactor);
- mv_engine_config_get_int_attribute_c(working_cfg, MV_IMAGE_RECOGNITION_SCENE_MAX_KEYPOINTS_NUM,
- &featuresExtractingParams.ORB.mMaximumFeaturesNumber);
+ mv_engine_config_get_int_attribute(working_cfg, MV_IMAGE_RECOGNITION_SCENE_MAX_KEYPOINTS_NUM,
+ &featuresExtractingParams.ORB.mMaximumFeaturesNumber);
if (NULL == engine_cfg)
mv_destroy_engine_config(working_cfg);
recognitionParams = DefaultConfiguration::getInstance().getRecognitionParams();
- mv_engine_config_get_int_attribute_c(working_cfg, MV_IMAGE_RECOGNITION_MIN_MATCH_NUM,
- &recognitionParams.mMinMatchesNumber);
+ mv_engine_config_get_int_attribute(working_cfg, MV_IMAGE_RECOGNITION_MIN_MATCH_NUM,
+ &recognitionParams.mMinMatchesNumber);
- mv_engine_config_get_double_attribute_c(working_cfg, MV_IMAGE_RECOGNITION_REQ_MATCH_PART,
- &recognitionParams.mRequiredMatchesPart);
+ mv_engine_config_get_double_attribute(working_cfg, MV_IMAGE_RECOGNITION_REQ_MATCH_PART,
+ &recognitionParams.mRequiredMatchesPart);
- mv_engine_config_get_double_attribute_c(working_cfg, MV_IMAGE_RECOGNITION_TOLERANT_MATCH_PART_ERR,
- &recognitionParams.mTolerantMatchesPartError);
+ mv_engine_config_get_double_attribute(working_cfg, MV_IMAGE_RECOGNITION_TOLERANT_MATCH_PART_ERR,
+ &recognitionParams.mTolerantMatchesPartError);
if (NULL == engine_cfg)
mv_destroy_engine_config(working_cfg);
stabilizationParams = DefaultConfiguration::getInstance().getStabilizationParams();
- mv_engine_config_get_bool_attribute_c(working_cfg, MV_IMAGE_TRACKING_USE_STABLIZATION,
- &stabilizationParams.mIsEnabled);
+ mv_engine_config_get_bool_attribute(working_cfg, MV_IMAGE_TRACKING_USE_STABLIZATION,
+ &stabilizationParams.mIsEnabled);
- mv_engine_config_get_int_attribute_c(working_cfg, MV_IMAGE_TRACKING_HISTORY_AMOUNT, &_history_amount);
+ mv_engine_config_get_int_attribute(working_cfg, MV_IMAGE_TRACKING_HISTORY_AMOUNT, &_history_amount);
stabilizationParams.mHistoryAmount = static_cast<size_t>(static_cast<unsigned int>(_history_amount));
- mv_engine_config_get_double_attribute_c(working_cfg, MV_IMAGE_TRACKING_STABLIZATION_TOLERANT_SHIFT,
- &stabilizationParams.mTolerantShift);
+ mv_engine_config_get_double_attribute(working_cfg, MV_IMAGE_TRACKING_STABLIZATION_TOLERANT_SHIFT,
+ &stabilizationParams.mTolerantShift);
- mv_engine_config_get_double_attribute_c(working_cfg, MV_IMAGE_TRACKING_STABLIZATION_SPEED,
- &stabilizationParams.mStabilizationSpeed);
+ mv_engine_config_get_double_attribute(working_cfg, MV_IMAGE_TRACKING_STABLIZATION_SPEED,
+ &stabilizationParams.mStabilizationSpeed);
- mv_engine_config_get_double_attribute_c(working_cfg, MV_IMAGE_TRACKING_STABLIZATION_ACCELERATION,
- &stabilizationParams.mStabilizationAcceleration);
+ mv_engine_config_get_double_attribute(working_cfg, MV_IMAGE_TRACKING_STABLIZATION_ACCELERATION,
+ &stabilizationParams.mStabilizationAcceleration);
if (NULL == engine_cfg)
mv_destroy_engine_config(working_cfg);
extractStabilizationParams(working_cfg, trackingParams.mStabilizationParams);
- mv_engine_config_get_double_attribute_c(working_cfg, MV_IMAGE_TRACKING_EXPECTED_OFFSET,
- &trackingParams.mExpectedOffset);
+ mv_engine_config_get_double_attribute(working_cfg, MV_IMAGE_TRACKING_EXPECTED_OFFSET,
+ &trackingParams.mExpectedOffset);
if (NULL == engine_cfg)
mv_destroy_engine_config(working_cfg);