Code clean-up.
[platform/adaptation/emulator/gst-plugins-emulator.git] / src / gstmaruinterface.h
1 /*
2  * GStreamer codec plugin for Tizen Emulator.
3  *
4  * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  * KiTae Kim <kt920.kim@samsung.com>
8  * SeokYeon Hwang <syeon.hwang@samsung.com>
9  * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the
23  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  *
29  */
30
31 #ifndef __GST_MARU_INTERFACE_H__
32 #define __GST_MARU_INTERFACE_H__
33
34 #include "gstmaru.h"
35
36 #define MAX_TS_MASK 0xff
37
38 typedef struct
39 {
40   gint idx;
41   GstClockTime timestamp;
42   GstClockTime duration;
43   gint64 offset;
44 } GstTSInfo;
45
46 typedef struct _GstMaruDec
47 {
48   GstElement element;
49
50   GstPad *srcpad;
51   GstPad *sinkpad;
52
53   CodecContext *context;
54   CodecDevice *dev;
55
56   union {
57     struct {
58       gint width, height;
59       gint clip_width, clip_height;
60       gint par_n, par_d;
61       gint fps_n, fps_d;
62       gint old_fps_n, old_fps_d;
63       gboolean interlaced;
64
65       enum PixelFormat pix_fmt;
66     } video;
67     struct {
68       gint channels;
69       gint samplerate;
70       gint depth;
71     } audio;
72   } format;
73
74   gboolean opened;
75   gboolean discont;
76   gboolean clear_ts;
77
78   /* tracking DTS/PTS */
79   GstClockTime next_out;
80
81   /* Qos stuff */
82   gdouble proportion;
83   GstClockTime earliest_time;
84   gint64 processed;
85   gint64 dropped;
86
87
88   /* GstSegment can be used for two purposes:
89    * 1. performing seeks (handling seek events)
90    * 2. tracking playback regions (handling newsegment events)
91    */
92   GstSegment segment;
93
94   GstTSInfo ts_info[MAX_TS_MASK + 1];
95   gint ts_idx;
96
97   /* reverse playback queue */
98   GList *queued;
99
100 } GstMaruDec;
101
102 int
103 codec_init (CodecContext *ctx, CodecElement *codec, CodecDevice *dev);
104
105 void
106 codec_deinit (CodecContext *ctx, CodecDevice *dev);
107
108 int
109 codec_decode_video (CodecContext *ctx, uint8_t *in_buf, int in_size,
110                     gint idx, gint64 in_offset, GstBuffer **out_buf,
111                     int *got_picture_ptr, CodecDevice *dev);
112
113
114 int
115 codec_decode_audio (CodecContext *ctx, int16_t *samples,
116                     int *frame_size_ptr, uint8_t *in_buf,
117                     int in_size, CodecDevice *dev);
118
119 int
120 codec_encode_video (CodecContext *ctx, uint8_t*out_buf,
121                     int out_size, uint8_t *in_buf,
122                     int in_size, int64_t in_timestamp,
123                     CodecDevice *dev);
124
125 int
126 codec_encode_audio (CodecContext *ctx, uint8_t *out_buf,
127                     int out_size, uint8_t *in_buf,
128                     int in_size, CodecDevice *dev);
129
130 void
131 codec_picture_copy (CodecContext *ctx, uint8_t *pict,
132                 uint32_t pict_size, CodecDevice *dev);
133
134 void
135 codec_flush_buffers (CodecContext *ctx, CodecDevice *dev);
136
137 GstFlowReturn
138 codec_buffer_alloc_and_copy (GstPad *pad, guint64 offset,
139                     guint size, GstCaps *caps, GstBuffer **buf);
140
141 #endif /* __GST_MARU_INTERFACE_H__ */