static void update_in_rates (GstQueue2 * queue, gboolean force);
static GstMessage *gst_queue2_get_buffering_message (GstQueue2 * queue);
static void gst_queue2_post_buffering (GstQueue2 * queue);
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
-static gboolean change_current_range(GstQueue2 * queue, GstQueue2Range *req_range, guint64 offset, guint length);
-#endif
typedef enum
{
g_slice_free_chain (GstQueue2Range, queue->ranges, next);
queue->ranges = NULL;
queue->current = NULL;
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- queue->read = NULL;
-#endif
}
/* find a range that contains @offset or NULL when nothing does */
/* get rid of all the current ranges */
clean_ranges (queue);
/* make a range for offset 0 */
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- queue->current = queue->read = add_range (queue, 0, TRUE);
-#else
queue->current = add_range (queue, 0, TRUE);
-#endif
}
/* calculate the diff between running time on the sink and src of the queue.
if (segment->format == GST_FORMAT_BYTES) {
if (!QUEUE_IS_USING_QUEUE (queue) && is_sink) {
/* start is where we'll be getting from and as such writing next */
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- queue->current = queue->read = add_range (queue, segment->start, TRUE);
-#else
queue->current = add_range (queue, segment->start, TRUE);
-#endif
}
}
update_buffering (GstQueue2 * queue)
{
gint buffering_level, percent;
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- GstQueue2Range *range;
-
- if (queue->read)
- range = queue->read;
- else
- range = queue->current;
-#endif
/* Ensure the variables used to calculate buffering state are up-to-date. */
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- if (range)
- update_cur_level (queue, range);
-#else
if (queue->current)
update_cur_level (queue, queue->current);
-#endif
+
update_in_rates (queue, FALSE);
if (!get_buffering_level (queue, NULL, &buffering_level))
* cause data to be written to the wrong offset in the file or ring buffer.
* We still do the add_range call to switch the current range to the
* requested range, or create one if one doesn't exist yet. */
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- queue->current = queue->read = add_range (queue, offset, FALSE);
-#else
queue->current = add_range (queue, offset, FALSE);
-#endif
}
return res;
return threshold;
}
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
-/* check the buffered data size, not to change range repeatedly.
- * changing range cause the new http connection and it makes buffering state frequently. */
-static gboolean
-change_current_range(GstQueue2 * queue, GstQueue2Range *req_range, guint64 offset, guint length)
-{
- guint64 curr_level = 0;
- guint64 curr_min_level = 0;
-
- if (queue->current->writing_pos > queue->current->reading_pos)
- curr_level = queue->current->writing_pos - queue->current->reading_pos;
-
- /* FIXME, find a good threshold based on the incoming rate and content bitrate. */
- curr_min_level = MIN((queue->max_level.bytes*0.05), get_seek_threshold(queue));
-
- GST_DEBUG_OBJECT(queue, " curr[w%"G_GUINT64_FORMAT", r%"G_GUINT64_FORMAT
- ", d%"G_GUINT64_FORMAT", m%"G_GUINT64_FORMAT
- "] u[%"G_GUINT64_FORMAT"][EOS:%d]",
- queue->current->writing_pos, queue->current->reading_pos,
- curr_level, curr_min_level,
- queue->upstream_size, queue->is_eos);
-
- /* FIXME, find a good threshold based on the incoming rate and content bitrate. */
- if ((queue->is_eos) ||
- (queue->upstream_size > 0 && queue->current->writing_pos >= queue->upstream_size) ||
- (curr_level >= curr_min_level)) {
- GST_DEBUG_OBJECT (queue, "Range Switching");
- return TRUE;
- } else {
- GST_DEBUG_OBJECT (queue, "keep receiving data without range switching.");
- return FALSE;
- }
-}
-#endif
-
/* see if there is enough data in the file to read a full buffer */
static gboolean
gst_queue2_have_data (GstQueue2 * queue, guint64 offset, guint length)
{
GstQueue2Range *range;
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- gboolean need_to_seek = TRUE;
-#endif
+
GST_DEBUG_OBJECT (queue, "looking for offset %" G_GUINT64_FORMAT ", len %u",
offset, length);
if ((range = find_range (queue, offset))) {
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- queue->read = range;
-#endif
if (queue->current != range) {
GST_DEBUG_OBJECT (queue, "switching ranges, do seek to range position");
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- if (QUEUE_IS_USING_TEMP_FILE(queue) && !QUEUE_IS_USING_RING_BUFFER(queue))
- need_to_seek = change_current_range(queue, range, offset, length);
-
- if (need_to_seek == TRUE)
- perform_seek_to_offset (queue, range->writing_pos);
-#else
perform_seek_to_offset (queue, range->writing_pos);
-#endif
}
GST_INFO_OBJECT (queue, "cur_level.bytes %u (max %" G_GUINT64_FORMAT ")",
GST_INFO_OBJECT (queue, "not found in any range off %" G_GUINT64_FORMAT
" len %u", offset, length);
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- queue->read = queue->current;
-#endif
-
/* we don't have the range, see how far away we are */
if (!queue->is_eos && queue->current) {
guint64 threshold = get_seek_threshold (queue);
guint64 level;
/* calculate how far away the offset is */
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- if (queue->read->writing_pos > rpos)
- level = queue->read->writing_pos - rpos;
-#else
if (queue->current->writing_pos > rpos)
level = queue->current->writing_pos - rpos;
-#endif
else
level = 0;
GST_DEBUG_OBJECT (queue,
"reading %" G_GUINT64_FORMAT ", writing %" G_GUINT64_FORMAT
", level %" G_GUINT64_FORMAT ", max %" G_GUINT64_FORMAT,
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- rpos, queue->read->writing_pos, level, max_size);
-#else
rpos, queue->current->writing_pos, level, max_size);
-#endif
if (level >= max_size) {
/* we don't have the data but if we have a ring buffer that is full, we
if (read_length == 0) {
if (QUEUE_IS_USING_RING_BUFFER (queue)) {
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- GST_DEBUG_OBJECT (queue,
- "update current position [%" G_GUINT64_FORMAT "-%"
- G_GUINT64_FORMAT "]", rpos, queue->read->max_reading_pos);
- update_cur_pos (queue, queue->read, rpos);
-#else
GST_DEBUG_OBJECT (queue,
"update current position [%" G_GUINT64_FORMAT "-%"
G_GUINT64_FORMAT "]", rpos, queue->current->max_reading_pos);
update_cur_pos (queue, queue->current, rpos);
-#endif
GST_QUEUE2_SIGNAL_DEL (queue);
}
}
/* set range reading_pos to actual reading position for this read */
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- queue->read->reading_pos = rpos;
-#else
queue->current->reading_pos = rpos;
-#endif
+
/* configure how much and from where to read */
if (QUEUE_IS_USING_RING_BUFFER (queue)) {
file_offset =
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- (queue->read->rb_offset + (rpos -
- queue->read->offset)) % rb_size;
-#else
(queue->current->rb_offset + (rpos -
queue->current->offset)) % rb_size;
-#endif
+
if (file_offset + read_length > rb_size) {
block_length = rb_size - file_offset;
} else {
block_length = read_length;
remaining -= read_return;
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- rpos = (queue->read->reading_pos += read_return);
- update_cur_pos (queue, queue->read, queue->read->reading_pos);
-#else
rpos = (queue->current->reading_pos += read_return);
update_cur_pos (queue, queue->current, queue->current->reading_pos);
-#endif
}
GST_QUEUE2_SIGNAL_DEL (queue);
GST_DEBUG_OBJECT (queue, "%u bytes left to read", remaining);
GstBuffer *buffer = NULL;
guint64 reading_pos;
-#ifdef TIZEN_FEATURE_QUEUE2_MODIFICATION
- reading_pos = queue->read->reading_pos;
-#else
+
reading_pos = queue->current->reading_pos;
-#endif
ret =
gst_queue2_create_read (queue, reading_pos, DEFAULT_BUFFER_SIZE,