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.0
40 #define MAX_DECODEBIN_BUFFER_BYTES (32 * 1024 * 1024) // byte
41 #define MAX_DECODEBIN_BUFFER_TIME 15 // sec
43 #define DEFAULT_BUFFER_SIZE_BYTES 4194304 // 4 MBytes
44 #define DEFAULT_PLAYING_TIME 10 // 10 sec
46 #define DEFAULT_BUFFERING_TIME 3.0 // 3sec
47 #define DEFAULT_BUFFER_LOW_PERCENT 1.0 // 1%
48 #define DEFAULT_BUFFER_HIGH_PERCENT 99.0 // 15%
50 #define DEFAULT_FILE_BUFFER_PATH "/opt/media"
52 #define STREAMING_USE_FILE_BUFFER
53 #define STREAMING_USE_MEMORY_BUFFER
55 #define GET_BYTE_FROM_BIT(bit) (bit/8)
56 #define GET_BIT_FROM_BYTE(byte) (byte*8)
57 #define CALC_PERCENT(a,b) ((gdouble)(a) * 100 / (gdouble)(b))
58 #define GET_PERCENT(a, b, c, d) \
61 if (((a) > 0) && ((b) > 0)) \
63 d = CALC_PERCENT(a, b); \
67 debug_warning ("set default per info\n"); \
73 #define PLAYER_BUFFER_CAST(handle) ((streaming_buffer_t *)(handle))
74 #define PLAYER_STREAM_CAST(sr) ((mm_player_streaming_t *)(sr))
76 #define GET_CURRENT_BUFFERING_BYTE(handle) (PLAYER_BUFFER_CAST(handle)->buffering_bytes)
77 #define GET_CURRENT_BUFFERING_TIME(handle) (PLAYER_BUFFER_CAST(handle)->buffering_time)
79 #define IS_MUXED_BUFFERING_MODE(sr) (PLAYER_STREAM_CAST(sr)->streaming_buffer_type == BUFFER_TYPE_MUXED)?(TRUE):(FALSE)
80 #define IS_DEMUXED_BUFFERING_MODE(sr) (PLAYER_STREAM_CAST(sr)->streaming_buffer_type == BUFFER_TYPE_DEMUXED)?(TRUE):(FALSE)
82 #define GET_NEW_BUFFERING_BYTE(size) ((size) < MAX_DECODEBIN_BUFFER_BYTES)?(size):(MAX_DECODEBIN_BUFFER_BYTES)
87 BUFFER_TYPE_MUXED = BUFFER_TYPE_DEFAULT, /* queue2 */
88 BUFFER_TYPE_DEMUXED, /* multi Q in decodebin */
94 MMPlayerBufferingMode mode;
95 gboolean is_pre_buffering;
99 }streaming_requirement_t;
103 GstElement* buffer; /* buffering element of playback pipeline */
105 guint buffering_bytes;
106 gdouble buffering_time; // mq : max buffering time value till now
107 gdouble buffer_high_percent;
108 gdouble buffer_low_percent;
115 gboolean buffering_monitor;
117 gdouble buffering_time; // DEFAULT_BUFFERING_TIME
118 }streaming_default_t;
122 BufferType streaming_buffer_type;
123 streaming_buffer_t buffer_handle[BUFFER_TYPE_MAX]; /* front buffer : queue2 */
125 streaming_requirement_t buffering_req;
126 streaming_default_t default_val;
128 gboolean is_buffering;
129 gboolean is_buffering_done; /* get info from bus sync callback */
131 gint buffering_percent;
133 guint buffer_max_bitrate;
134 guint buffer_avg_bitrate;
135 gboolean need_update;
138 }mm_player_streaming_t;
141 mm_player_streaming_t *__mm_player_streaming_create (void);
142 void __mm_player_streaming_initialize (mm_player_streaming_t* streaming_player);
143 void __mm_player_streaming_deinitialize (mm_player_streaming_t* streaming_player);
144 void __mm_player_streaming_destroy(mm_player_streaming_t* streaming_player);
145 void __mm_player_streaming_set_queue2( mm_player_streaming_t* streamer,
147 gboolean use_buffering,
148 guint buffering_bytes,
149 gdouble buffering_time,
151 gdouble high_percent,
154 guint64 content_size);
155 void __mm_player_streaming_set_multiqueue( mm_player_streaming_t* streamer,
157 gboolean use_buffering,
158 guint buffering_bytes,
159 gdouble buffering_time,
161 gdouble high_percent);
162 void __mm_player_streaming_sync_property(mm_player_streaming_t* streamer, GstElement* decodebin);
163 void __mm_player_streaming_buffering( mm_player_streaming_t* streamer,
164 GstMessage *buffering_msg,
165 guint64 content_size,
168 void __mm_player_streaming_set_content_bitrate(mm_player_streaming_t* streaming_player, guint max_bitrate, guint avg_bitrate);