It is branch merging of tizen 6.0.
(https://review.tizen.org/gerrit/#/c/platform/core/api/mediastreamrecorder/+/218535/)
[Modification]
- Generates internal header, c file.
- 'streamrecoder_set_mode' and 'streamrecorder_get_mode' goes to internal.
- 'streamrecorder_mode_e' enum goes to internal.
- Adds testsuite for loopback test.
Change-Id: I2ea38514dad5bbf3f57ab0f588c36f89322b921e
Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
--- /dev/null
+
+/*
+* Copyright (c) 2020 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_MEDIA_STREAMRECORDER_INTERNAL_H__
+#define __TIZEN_MEDIA_STREAMRECORDER_INTERNAL_H__
+
+#include <streamrecorder.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ STREAMRECORDER_MODE_STREAM_BUFFER = 0, /**< Recording with media buffer */
+ STREAMRECORDER_MODE_DEVICE_LOOPBACK /**< Recording with device's own screen and audio */
+} streamrecorder_mode_e;
+
+int streamrecorder_set_mode(streamrecorder_h recorder, streamrecorder_mode_e mode);
+int streamrecorder_get_mode(streamrecorder_h recorder, streamrecorder_mode_e *mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_MEDIA_STREAMRECORDER_INTERNAL_H__
+
Name: capi-media-streamrecorder
Summary: A Streamrecorder library in Tizen Native API
-Version: 0.0.25
+Version: 0.0.26
Release: 0
Group: Multimedia/Other
License: Apache-2.0
%files devel
%{_includedir}/media/streamrecorder.h
+%{_includedir}/media/streamrecorder_internal.h
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-media-streamrecorder.so
}
ret = mm_streamrecorder_push_stream_buffer(handle->mm_handle, MM_STREAM_TYPE_VIDEO, pts, video_buf, video_buf->size[0]);
- } else if (mimetype == MEDIA_FORMAT_I420) {
+ } else if (mimetype == MEDIA_FORMAT_I420 || mimetype == MEDIA_FORMAT_BGRA) {
void *buf_data = NULL;
-
+ LOGI("mimetype: [%d]", mimetype);
ret = media_packet_get_video_plane_data_ptr(packet, 0, (void **)&buf_data);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("buffer size get fail");
int streamrecorder_get_audio_channel(streamrecorder_h recorder, int *channel_count)
{
- int ret = STREAMRECORDER_ERROR_NONE;
-
if (recorder == NULL) {
LOGE("NULL pointer handle");
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
- ret = _streamrecorder_get_audio_channel(recorder, channel_count);
- return ret;
-
+ return _streamrecorder_get_audio_channel(recorder, channel_count);
}
static int __mm_streamrecorder_msg_cb(int message, void *param, void *user_data)
--- /dev/null
+/*
+* Copyright (c) 2020 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 <dlog.h>
+#include <mm_streamrecorder.h>
+#include <streamrecorder_private.h>
+#include <streamrecorder_internal.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_STREAMRECORDER"
+
+int streamrecorder_set_mode(streamrecorder_h recorder , streamrecorder_mode_e mode)
+{
+ int ret = MM_ERROR_NONE;
+ streamrecorder_s *handle = (streamrecorder_s *)recorder;
+
+ if (recorder == NULL) {
+ LOGE("NULL pointer handle");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (mode > STREAMRECORDER_MODE_DEVICE_LOOPBACK) {
+ LOGE("invalid mode %d", mode);
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
+ MMSTR_RECORDER_MODE, mode,
+ NULL);
+ return __convert_streamrecorder_error_code(__func__, ret);
+}
+
+int streamrecorder_get_mode(streamrecorder_h recorder, streamrecorder_mode_e *mode)
+{
+ int ret = MM_ERROR_NONE;
+ int mm_mode = 0;
+ streamrecorder_s *handle = (streamrecorder_s *)recorder;
+
+ if (recorder == NULL) {
+ LOGE("NULL pointer handle");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (mode == NULL) {
+ LOGE("mode is NULL");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
+ MMSTR_RECORDER_MODE, &mm_mode,
+ NULL);
+ if (ret == MM_ERROR_NONE) {
+ switch (mm_mode) {
+ case MM_STREAMRECORDER_MODE_STREAM_BUFFER:
+ *mode = STREAMRECORDER_MODE_STREAM_BUFFER;
+ break;
+ case MM_STREAMRECORDER_MODE_DEVICE_LOOPBACK:
+ *mode = STREAMRECORDER_MODE_DEVICE_LOOPBACK;
+ break;
+ default:
+ ret = MM_ERROR_STREAMRECORDER_INTERNAL;
+ break;
+ }
+ }
+ return __convert_streamrecorder_error_code(__func__, ret);
+}
\ No newline at end of file
#include <fcntl.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_STREAMRECORDER"
+
int __convert_streamrecorder_error_code(const char *func, int code)
{
streamrecorder_s *handle = (streamrecorder_s *)recorder;
mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
- MMSTR_RECORDER_MODE, MM_STREAMRECORDER_MODE_MEDIABUFFER,
+ MMSTR_RECORDER_MODE, MM_STREAMRECORDER_MODE_STREAM_BUFFER,
NULL);
mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
- MMSTR_VIDEO_ENABLE, true,
+ MMSTR_VIDEO_ENABLE, TRUE,
NULL);
streamrecorder_s *handle;
handle = (streamrecorder_s *) recorder;
mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
- MMSTR_RECORDER_MODE, MM_STREAMRECORDER_MODE_MEDIABUFFER,
+ MMSTR_RECORDER_MODE, MM_STREAMRECORDER_MODE_STREAM_BUFFER,
NULL);
mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
- MMSTR_AUDIO_ENABLE, true,
+ MMSTR_AUDIO_ENABLE, TRUE,
NULL);
return ret;
NULL);
return __convert_streamrecorder_error_code(__func__, ret);
-}
-
+}
\ No newline at end of file
--- /dev/null
+#include <stdio.h>
+#include <streamrecorder.h>
+#include <streamrecorder_private.h>
+#include <streamrecorder_internal.h>
+#include <time.h>
+#include <glib.h>
+//#define DUMP 1
+#ifdef DUMP
+#include <tdm_helper.h>
+#endif
+
+
+#define DEST_FILE "/tmp/test_with_suite.mp4"
+#define WIDTH 1280
+#define HEIGHT 720
+#define FRAME_RATE 30
+
+#define LOGD(...) do { printf(__VA_ARGS__); putc('\n', stdout); } while (0)
+#define LOGE(...) do { printf(__VA_ARGS__); putc('\n', stdout); } while (0)
+#define LOGW(...) do { printf(__VA_ARGS__); putc('\n', stdout); } while (0)
+
+typedef struct streamrecorder_data streamrecdata;
+
+struct streamrecorder_data {
+ streamrecorder_h streamrecorder;
+};
+
+static streamrecdata sdata;
+
+static void
+streamrecorder_cb_notify(streamrecorder_state_e previous,
+ streamrecorder_state_e current,
+ streamrecorder_notify_e notification,
+ void *data)
+{
+ LOGD("streamrecorder_notify (prev: %d, curr: %d)", previous, current);
+}
+
+static gboolean
+_cb_finish(gpointer user_data)
+{
+ GMainLoop *loop = user_data;
+ streamrecorder_commit(sdata.streamrecorder);
+ g_main_loop_quit(loop);
+ return false;
+}
+
+void _recording_status_cb(unsigned long long elapsed_time, unsigned long long file_size, void *user_data)
+{
+ g_print("elapsed time :%lld, file_size :%lld \r", elapsed_time, file_size);
+}
+
+int
+main(int argc, char *argv[])
+{
+ streamrecorder_state_e state;
+ int err = 0;
+ int ret = 0;
+ streamrecorder_mode_e mode = STREAMRECORDER_MODE_DEVICE_LOOPBACK;
+ sdata.streamrecorder = NULL;
+
+ err = streamrecorder_create(&sdata.streamrecorder);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_create()': %d", err);
+ return -1;
+ }
+
+ err = streamrecorder_get_state(sdata.streamrecorder, &state);
+ if (err == STREAMRECORDER_ERROR_NONE) {
+ if (state == STREAMRECORDER_STATE_CREATED) {
+ LOGD("A state of StreamRecorder is 'Created'");
+ }
+ else
+ LOGD("A state of StreamRecorder is '%d'", state);
+ }
+
+ err = streamrecorder_set_notify_cb(sdata.streamrecorder,
+ streamrecorder_cb_notify,
+ &sdata);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_set_notify_cb()': %d", err);
+ ret = -1;
+ goto end;
+ }
+
+ // err = streamrecorder_enable_source_buffer(sdata.streamrecorder, STREAMRECORDER_SOURCE_VIDEO_AUDIO);
+ // if (err != STREAMRECORDER_ERROR_NONE) {
+ // LOGE("failed 'streamrecorder_enable_source_buffer'");
+ // return 0;
+ // }
+
+ err = streamrecorder_set_mode(sdata.streamrecorder, STREAMRECORDER_MODE_DEVICE_LOOPBACK);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_set_mode'");
+ return 0;
+ }
+
+ err = streamrecorder_get_mode(sdata.streamrecorder, &mode);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_get_mode'");
+ return 0;
+ }
+
+ err = streamrecorder_set_video_resolution(sdata.streamrecorder, WIDTH, HEIGHT);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_set_video_resolution()'");
+ return 0;
+ }
+
+ err = streamrecorder_set_video_framerate(sdata.streamrecorder, FRAME_RATE);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_set_video_framerate()'");
+ return 0;
+ }
+
+
+//no to me
+ err = streamrecorder_set_recording_status_cb(sdata.streamrecorder,
+ _recording_status_cb,
+ NULL);
+ if (err != STREAMRECORDER_ERROR_NONE)
+ {
+ LOGE("failed to set callback for recording status");
+ return 0;
+ }
+ err = streamrecorder_set_filename(sdata.streamrecorder, DEST_FILE);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_set_filename(): %d'", err);
+ return 0;
+ }
+
+ err = streamrecorder_prepare(sdata.streamrecorder);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_prepare()': %d", err);
+ ret = -1;
+ goto end;
+ }
+
+ err = streamrecorder_start(sdata.streamrecorder);
+ if (err != STREAMRECORDER_ERROR_NONE) {
+ LOGE("failed 'streamrecorder_start()': %d", err);
+ ret = -1;
+ goto end;
+ }
+
+ GMainLoop *loop = g_main_loop_new(NULL, FALSE);
+ g_timeout_add_seconds(5, _cb_finish, loop);
+ g_main_loop_run(loop);
+
+ g_main_loop_unref(loop);
+
+end:
+ streamrecorder_destroy(sdata.streamrecorder);
+ sdata.streamrecorder = NULL;
+
+ return ret;
+}