\r
overwrite_buffer<bool> is_running_;\r
governor governor_;\r
-\r
- const int video_index_;\r
- const int audio_index_;\r
\r
public:\r
explicit implementation(input::target_t& target,\r
, start_(start)\r
, length_(length)\r
, frame_number_(0)\r
- , governor_(4)\r
- , video_index_(av_find_best_stream(format_context_.get(), AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0))\r
- , audio_index_(av_find_best_stream(format_context_.get(), AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0))\r
+ , governor_(8)\r
{ \r
loop_ = loop;\r
packets_count_ = 0;\r
{\r
try\r
{\r
- double current_dts = 0;\r
- std::map<int, double> dts;\r
+ int last_stream_index = -1;\r
\r
send(is_running_, true);\r
for(auto packet = read_next_packet(); packet && is_running_.value(); packet = read_next_packet())\r
{ \r
ticket_t ticket;\r
- \r
- if(packet->stream_index > 0 && (packet->stream_index == video_index_ || packet->stream_index == audio_index_))\r
- dts[packet->stream_index] = packet->dts*av_q2d(format_context_->streams[packet->stream_index]->time_base);\r
-\r
- auto it = std::min_element(dts.begin(), dts.end(), [](const std::pair<int, double>& lhs, const std::pair<int, double>& rhs)\r
- {\r
- return lhs.second < rhs.second;\r
- });\r
\r
- if(it != dts.end() && it->second > current_dts)\r
- {\r
+ if((format_context_->nb_streams < 2 || last_stream_index != packet->stream_index) && packet->stream_index == default_stream_index_)\r
ticket = governor_.acquire();\r
- current_dts = it->second;\r
- }\r
+ last_stream_index = packet->stream_index;\r
\r
Concurrency::asend(target_, input::target_element_t(packet, ticket));\r
Context::Yield();\r