int mv_engine_config_foreach_supported_attribute(mv_supported_attribute_cb callback, void *user_data);
/**
+ * @brief Gets timestamp from mv_source.
+ *
+ * @since_tizen 8.0
+ * @param[in] source The handle to the source
+ * @param[out] timestamp The nano seconds(ns) timestamp
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see mv_source_set_timestamp()
+ */
+int mv_source_get_timestamp(mv_source_h source, uint64_t *timestamp);
+
+/**
+ * @brief Sets timestamp to mv_source.
+ *
+ * @since_tizen 8.0
+ * @param[in] source The handle to the source
+ * @param[in] timestamp The nano seconds(ns) timestamp
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see mv_source_get_timestamp()
+ */
+int mv_source_set_timestamp(mv_source_h source, uint64_t timestamp);
+
+/**
* @}
*/
--- /dev/null
+/*
+ * Copyright (c) 2023 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 __TIZEN_MEDIAVISION_COMMON_INTERNAL_H__
+#define __TIZEN_MEDIAVISION_COMMON_INTERNAL_H__
+
+#include <mv_common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @internal
+ * @brief Gets private timestamp from mv_source.
+ *
+ * @since_tizen 8.0
+ * @param[in] source The handle to the source
+ * @param[out] priv The private timestamp (user specific timestamp)
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see mv_source_set_priv_timestamp()
+ */
+int mv_source_get_priv_timestamp(mv_source_h source, void **priv);
+
+/**
+ * @internal
+ * @brief Sets private timestamp to mv_source.
+ *
+ * @since_tizen 8.0
+ * @param[in] source The handle to the source
+ * @param[in] priv The private timestamp (user specific timestamp)
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see mv_source_get_priv_timestamp()
+ */
+int mv_source_set_priv_timestamp(mv_source_h source, void *priv);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIAVISION_COMMON_INTERNAL_H__ */
unsigned int imageSize { 0 };
unsigned int bytePerLine { 0 };
};
+struct Timestamp {
+ uint64_t timestamp;
+ void *priv;
+};
/**
* @class MediaSource
unsigned int getWidthStride();
+ const Timestamp &getTimestamp();
+
+ void setTimestamp(const Timestamp ×tamp);
+
private:
std::vector<Plane> _plane;
unsigned int _width { 0 }; /**< The image width */
unsigned int _height { 0 }; /**< The image height */
mv_colorspace_e _colorspace { MEDIA_VISION_COLORSPACE_INVALID }; /**< The image colorspace */
media_packet_h _packet { nullptr };
+ Timestamp _timestamp { 0, nullptr };
};
} /* Common */
return _plane[0].bytePerLine;
}
+const Timestamp &MediaSource::getTimestamp()
+{
+ return _timestamp;
+}
+
+void MediaSource::setTimestamp(const Timestamp ×tamp)
+{
+ _timestamp = timestamp;
+}
+
} /* Common */
} /* MediaVision */
#include "EngineConfig.h"
#include <mv_private.h>
+#include <mv_common_internal.h>
#include <new>
#include <memory>
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;
+}
\ No newline at end of file
Name: capi-media-vision
Summary: Media Vision library for Tizen Native API
-Version: 0.28.2
+Version: 0.28.3
Release: 0
Group: Multimedia/Framework
License: Apache-2.0 and BSD-3-Clause
#include <gtest/gtest.h>
#include <mv_common.h>
+#include <mv_common_internal.h>
TEST(MediaPKT, Format)
{
ASSERT_EQ(media_format_unref(media_fmt), MEDIA_FORMAT_ERROR_NONE);
ASSERT_EQ(mv_destroy_source(mv_source), MEDIA_VISION_ERROR_NONE);
ASSERT_EQ(tbm_surface_destroy(surface), TBM_SURFACE_ERROR_NONE);
-}
\ No newline at end of file
+}
+
+TEST(MvSource, Timestamp)
+{
+ mv_source_h mv_source;
+ uint64_t timestamp;
+ ASSERT_EQ(mv_create_source(&mv_source), MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_source_get_timestamp(mv_source, ×tamp), MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(timestamp, 0);
+ ASSERT_EQ(mv_source_set_timestamp(mv_source, 2), MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_source_get_timestamp(mv_source, ×tamp), MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(timestamp, 2);
+ ASSERT_EQ(mv_destroy_source(mv_source), MEDIA_VISION_ERROR_NONE);
+}
+
+TEST(MvSource, TimestampPrivate)
+{
+ struct CustomTimestamp {
+ int a, b;
+ };
+ CustomTimestamp customTimestamp { 1, 2 };
+ CustomTimestamp *pCustomTimestamp = nullptr;
+ mv_source_h mv_source;
+ ASSERT_EQ(mv_create_source(&mv_source), MEDIA_VISION_ERROR_NONE);
+
+ ASSERT_EQ(mv_source_get_priv_timestamp(mv_source, nullptr), MEDIA_VISION_ERROR_INVALID_PARAMETER);
+ ASSERT_EQ(mv_source_set_priv_timestamp(mv_source, nullptr), MEDIA_VISION_ERROR_INVALID_PARAMETER);
+
+ ASSERT_EQ(mv_source_set_priv_timestamp(mv_source, (void *) &customTimestamp), MEDIA_VISION_ERROR_NONE);
+ customTimestamp.a = -1;
+ ASSERT_EQ(mv_source_get_priv_timestamp(mv_source, (void **) &pCustomTimestamp), MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(pCustomTimestamp->a, -1);
+ ASSERT_EQ(mv_destroy_source(mv_source), MEDIA_VISION_ERROR_NONE);
+}