Add media codec sync APIs for internal
[platform/core/api/mediacodec.git] / include / media_codec_sync_private.h
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __TIZEN_MEDIA_CODEC_SYNC_PRIVATE_H__
18 #define __TIZEN_MEDIA_CODEC_SYNC_PRIVATE_H__
19
20 #include <glib.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <gst/gst.h>
24 #include <gst/allocators/gsttizenmemory.h>
25 #include <gst/app/gstappsrc.h>
26 #include <media_codec_private.h>
27 #include <media_codec_sync_internal.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 enum {
34         MEDIACODECSYNC_PIPELINE = 0,
35         MEDIACODECSYNC_ELEMENT_APPSRC,
36         MEDIACODECSYNC_ELEMENT_CAPS,
37         MEDIACODECSYNC_ELEMENT_QUE,
38         MEDIACODECSYNC_ELEMENT_SINK,
39         MEDIACODECSYNC_ELEMENT_NUM
40 };
41
42 #define AUDIO_FORMAT_TABLE_SIZE 15
43 #define VIDEO_FORMAT_TABLE_SIZE 8
44
45 typedef struct _format_table {
46         media_format_mimetype_e mime_type;
47         char *format_string;
48 } format_table;
49
50 typedef struct _packet_info {
51         bool has_tbm_surface;
52         void *data;
53         uint64_t data_size;
54         uint64_t dts;
55         uint64_t pts;
56         uint64_t duration;
57 } packet_info;
58
59 typedef struct _mediacodecsync_s {
60         GMutex lock;
61         media_format_h audio_format;
62         media_format_h video_format;
63
64         GstAllocator *allocator;
65         GstClock *clock;
66         GstElement *audio_pipe[MEDIACODECSYNC_ELEMENT_NUM];
67         GstElement *video_pipe[MEDIACODECSYNC_ELEMENT_NUM];
68         GstCaps *video_caps;
69         GstVideoInfo video_info;
70
71         mediacodecsync_buffer_used_cb buffer_used_cb;
72         void *buffer_used_cb_userdata;
73
74         mediacodecsync_state_e state;
75 } mediacodecsync_s;
76
77 typedef struct _GstMCSBuffer {
78         GstBuffer *gst_buffer;
79         int type;
80         mediacodecsync_s *handle;
81         media_packet_h packet;
82 } GstMCSBuffer;
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif /* __TIZEN_MEDIA_CODEC_SYNC_PRIVATE_H__ */