4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7 * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 #ifndef __MM_PLAYER_STREAMING_H__
24 #define __MM_PLAYER_STREAMING_H__
31 #include "mm_player.h"
33 #define MAX_FILE_BUFFER_NAME_LEN 256
35 #define MIN_BUFFER_PERCENT 0.0
36 #define MAX_BUFFER_PERCENT 100.0
37 #define MIN_BUFFERING_TIME 3.0
38 #define MAX_BUFFERING_TIME (10*1000) /* ms */
40 #define MAX_DECODEBIN_BUFFER_BYTES (32 * 1024 * 1024) /* byte */
41 #define MAX_DECODEBIN_BUFFER_TIME (15*1000) /* ms */
42 #define MAX_DECODEBIN_ADAPTIVE_BUFFER_BYTES (2 * 1024 * 1024) /* byte */
43 #define MAX_DECODEBIN_ADAPTIVE_BUFFER_TIME (5*1000) /* ms */
45 #define DEFAULT_BUFFER_SIZE_BYTES 4194304 /* 4 MBytes */
46 #define DEFAULT_PLAYING_TIME (10*1000) /* ms */
47 #define DEFAULT_ADAPTIVE_PLAYING_TIME (3*1000) /* ms */
49 #define DEFAULT_BUFFERING_TIME (3*1000) /* ms */
50 #define DEFAULT_BUFFER_HIGH_PERCENT 99.0
51 #define DEFAULT_RING_BUFFER_SIZE (20*1024*1024) /* 20MBytes */
53 #define STREAMING_USE_FILE_BUFFER
54 #define STREAMING_USE_MEMORY_BUFFER
56 #define GET_BYTE_FROM_BIT(bit) (bit/8)
57 #define GET_BIT_FROM_BYTE(byte) (byte*8)
58 #define CALC_PERCENT(a, b) ((gdouble)(a) * 100 / (gdouble)(b))
59 #define GET_PERCENT(a, b, c, d) \
61 if (((a) > 0) && ((b) > 0)) { \
62 d = CALC_PERCENT(a, b); \
64 LOGW("set default per info\n"); \
70 #define PLAYER_BUFFER_CAST(handle) ((streaming_buffer_t *)(handle))
71 #define PLAYER_STREAM_CAST(sr) ((mm_player_streaming_t *)(sr))
73 #define GET_CURRENT_BUFFERING_BYTE(handle) (PLAYER_BUFFER_CAST(handle)->buffering_bytes)
74 #define GET_CURRENT_BUFFERING_TIME(handle) (PLAYER_BUFFER_CAST(handle)->buffering_time)
76 #define IS_MUXED_BUFFERING_MODE(sr) (PLAYER_STREAM_CAST(sr)->streaming_buffer_type == BUFFER_TYPE_MUXED) ? (TRUE) : (FALSE)
77 #define IS_DEMUXED_BUFFERING_MODE(sr) (PLAYER_STREAM_CAST(sr)->streaming_buffer_type == BUFFER_TYPE_DEMUXED) ? (TRUE) : (FALSE)
79 #define GET_NEW_BUFFERING_BYTE(size) ((size) < MAX_DECODEBIN_BUFFER_BYTES) ? (size) : (MAX_DECODEBIN_BUFFER_BYTES)
80 #define GET_MAX_BUFFER_BYTES(sr) ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming) ? (MAX_DECODEBIN_ADAPTIVE_BUFFER_BYTES) : (MAX_DECODEBIN_BUFFER_BYTES))
81 #define GET_MAX_BUFFER_TIME(sr) ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming) ? (MAX_DECODEBIN_ADAPTIVE_BUFFER_TIME) : (MAX_DECODEBIN_BUFFER_TIME))
82 #define GET_DEFAULT_PLAYING_TIME(sr) ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming) ? (DEFAULT_ADAPTIVE_PLAYING_TIME) : (DEFAULT_PLAYING_TIME))
86 BUFFER_TYPE_MUXED = BUFFER_TYPE_DEFAULT, /* queue2 */
87 BUFFER_TYPE_DEMUXED, /* multi Q in decodebin */
92 MUXED_BUFFER_TYPE_MEM_QUEUE, /* push mode in queue2 */
93 MUXED_BUFFER_TYPE_MEM_RING_BUFFER, /* pull mode in queue2 */
94 MUXED_BUFFER_TYPE_FILE, /* pull mode in queue2 */
95 MUXED_BUFFER_TYPE_MAX,
99 MM_PLAYER_BUFFERING_DEFAULT = 0x00,
100 MM_PLAYER_BUFFERING_IN_PROGRESS = 0x01,
101 MM_PLAYER_BUFFERING_ABORT = 0x02,
102 MM_PLAYER_BUFFERING_COMPLETE = 0x04,
103 } MMPlayerBufferingState;
106 MMPlayerBufferingMode mode;
107 gboolean is_pre_buffering;
108 gint prebuffer_time; /* ms */
109 gint rebuffer_time; /* ms */
110 } streaming_requirement_t;
113 GstElement* buffer; /* buffering element of playback pipeline */
115 guint buffering_bytes;
116 gint buffering_time; // mq : max buffering time value till now
117 gdouble buffer_high_percent;
118 gdouble buffer_low_percent;
121 } streaming_buffer_t;
124 gboolean buffering_monitor;
126 gint buffering_time; // DEFAULT_BUFFERING_TIME
127 } streaming_default_t;
130 BufferType streaming_buffer_type;
131 streaming_buffer_t buffer_handle[BUFFER_TYPE_MAX]; /* front buffer : queue2 */
133 streaming_requirement_t buffering_req;
134 streaming_default_t default_val;
136 MMPlayerBufferingState buffering_state;
137 gboolean is_adaptive_streaming;
139 gint buffering_percent;
140 guint buffer_max_bitrate;
141 guint buffer_avg_bitrate;
142 gboolean need_update;
144 gint ring_buffer_size;
145 } mm_player_streaming_t;
148 mm_player_streaming_t *__mm_player_streaming_create(void);
149 void __mm_player_streaming_initialize(mm_player_streaming_t* streaming_player);
150 void __mm_player_streaming_deinitialize(mm_player_streaming_t* streaming_player);
151 void __mm_player_streaming_destroy(mm_player_streaming_t* streaming_player);
152 void __mm_player_streaming_set_queue2(mm_player_streaming_t* streamer,
154 gboolean use_buffering,
155 guint buffering_bytes,
157 MuxedBufferType type,
159 guint64 content_size);
160 void __mm_player_streaming_set_multiqueue(mm_player_streaming_t* streamer,
162 gint buffering_time);
163 void __mm_player_streaming_sync_property(mm_player_streaming_t* streamer, GstElement* decodebin);
164 void __mm_player_streaming_buffering(mm_player_streaming_t* streamer,
165 GstMessage *buffering_msg,
166 guint64 content_size,
169 void __mm_player_streaming_set_content_bitrate(mm_player_streaming_t* streaming_player, guint max_bitrate, guint avg_bitrate);