OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 56 matching lines...) Loading... |
67 VCMFrameBuffer* PopFrame(uint32_t timestamp); | 67 VCMFrameBuffer* PopFrame(uint32_t timestamp); |
68 VCMFrameBuffer* Front() const; | 68 VCMFrameBuffer* Front() const; |
69 VCMFrameBuffer* Back() const; | 69 VCMFrameBuffer* Back() const; |
70 int RecycleFramesUntilKeyFrame(FrameList::iterator* key_frame_it, | 70 int RecycleFramesUntilKeyFrame(FrameList::iterator* key_frame_it, |
71 UnorderedFrameList* free_frames); | 71 UnorderedFrameList* free_frames); |
72 void CleanUpOldOrEmptyFrames(VCMDecodingState* decoding_state, | 72 void CleanUpOldOrEmptyFrames(VCMDecodingState* decoding_state, |
73 UnorderedFrameList* free_frames); | 73 UnorderedFrameList* free_frames); |
74 void Reset(UnorderedFrameList* free_frames); | 74 void Reset(UnorderedFrameList* free_frames); |
75 }; | 75 }; |
76 | 76 |
| 77 class Vp9SsMap { |
| 78 public: |
| 79 typedef std::map<uint32_t, GofInfoVP9, TimestampLessThan> SsMap; |
| 80 bool Insert(const VCMPacket& packet); |
| 81 void Reset(); |
| 82 |
| 83 // Removes SS data that are older than |timestamp|. |
| 84 // The |timestamp| should be an old timestamp, i.e. packets with older |
| 85 // timestamps should no longer be inserted. |
| 86 void RemoveOld(uint32_t timestamp); |
| 87 |
| 88 bool UpdatePacket(VCMPacket* packet); |
| 89 void UpdateFrames(FrameList* frames); |
| 90 |
| 91 // Public for testing. |
| 92 // Returns an iterator to the corresponding SS data for the input |timestamp|. |
| 93 bool Find(uint32_t timestamp, SsMap::iterator* it); |
| 94 |
| 95 private: |
| 96 // These two functions are called by RemoveOld. |
| 97 // Checks if it is time to do a clean up (done each kSsCleanupIntervalSec). |
| 98 bool TimeForCleanup(uint32_t timestamp) const; |
| 99 |
| 100 // Advances the oldest SS data to handle timestamp wrap in cases where SS data |
| 101 // are received very seldom (e.g. only once in beginning, second when |
| 102 // IsNewerTimestamp is not true). |
| 103 void AdvanceFront(uint32_t timestamp); |
| 104 |
| 105 SsMap ss_map_; |
| 106 }; |
| 107 |
77 class VCMJitterBuffer { | 108 class VCMJitterBuffer { |
78 public: | 109 public: |
79 VCMJitterBuffer(Clock* clock, rtc::scoped_ptr<EventWrapper> event); | 110 VCMJitterBuffer(Clock* clock, rtc::scoped_ptr<EventWrapper> event); |
80 | 111 |
81 ~VCMJitterBuffer(); | 112 ~VCMJitterBuffer(); |
82 | 113 |
83 // Initializes and starts jitter buffer. | 114 // Initializes and starts jitter buffer. |
84 void Start(); | 115 void Start(); |
85 | 116 |
86 // Signals all internal events and stops the jitter buffer. | 117 // Signals all internal events and stops the jitter buffer. |
(...skipping 213 matching lines...) Loading... |
300 CriticalSectionWrapper* crit_sect_; | 331 CriticalSectionWrapper* crit_sect_; |
301 // Event to signal when we have a frame ready for decoder. | 332 // Event to signal when we have a frame ready for decoder. |
302 rtc::scoped_ptr<EventWrapper> frame_event_; | 333 rtc::scoped_ptr<EventWrapper> frame_event_; |
303 // Number of allocated frames. | 334 // Number of allocated frames. |
304 int max_number_of_frames_; | 335 int max_number_of_frames_; |
305 UnorderedFrameList free_frames_ GUARDED_BY(crit_sect_); | 336 UnorderedFrameList free_frames_ GUARDED_BY(crit_sect_); |
306 FrameList decodable_frames_ GUARDED_BY(crit_sect_); | 337 FrameList decodable_frames_ GUARDED_BY(crit_sect_); |
307 FrameList incomplete_frames_ GUARDED_BY(crit_sect_); | 338 FrameList incomplete_frames_ GUARDED_BY(crit_sect_); |
308 VCMDecodingState last_decoded_state_ GUARDED_BY(crit_sect_); | 339 VCMDecodingState last_decoded_state_ GUARDED_BY(crit_sect_); |
309 bool first_packet_since_reset_; | 340 bool first_packet_since_reset_; |
310 // Contains last received frame's temporal information for non-flexible mode. | 341 // Contains scalability structure data for VP9. |
311 GofInfoVP9 last_gof_; | 342 Vp9SsMap vp9_ss_map_ GUARDED_BY(crit_sect_); |
312 uint32_t last_gof_timestamp_; | |
313 bool last_gof_valid_; | |
314 | 343 |
315 // Statistics. | 344 // Statistics. |
316 VCMReceiveStatisticsCallback* stats_callback_ GUARDED_BY(crit_sect_); | 345 VCMReceiveStatisticsCallback* stats_callback_ GUARDED_BY(crit_sect_); |
317 // Frame counts for each type (key, delta, ...) | 346 // Frame counts for each type (key, delta, ...) |
318 FrameCounts receive_statistics_; | 347 FrameCounts receive_statistics_; |
319 // Latest calculated frame rates of incoming stream. | 348 // Latest calculated frame rates of incoming stream. |
320 unsigned int incoming_frame_rate_; | 349 unsigned int incoming_frame_rate_; |
321 unsigned int incoming_frame_count_; | 350 unsigned int incoming_frame_count_; |
322 int64_t time_last_incoming_frame_count_; | 351 int64_t time_last_incoming_frame_count_; |
323 unsigned int incoming_bit_count_; | 352 unsigned int incoming_bit_count_; |
(...skipping 34 matching lines...) Loading... |
358 // Estimated rolling average of packets per frame | 387 // Estimated rolling average of packets per frame |
359 float average_packets_per_frame_; | 388 float average_packets_per_frame_; |
360 // average_packets_per_frame converges fast if we have fewer than this many | 389 // average_packets_per_frame converges fast if we have fewer than this many |
361 // frames. | 390 // frames. |
362 int frame_counter_; | 391 int frame_counter_; |
363 RTC_DISALLOW_COPY_AND_ASSIGN(VCMJitterBuffer); | 392 RTC_DISALLOW_COPY_AND_ASSIGN(VCMJitterBuffer); |
364 }; | 393 }; |
365 } // namespace webrtc | 394 } // namespace webrtc |
366 | 395 |
367 #endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_JITTER_BUFFER_H_ | 396 #endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_JITTER_BUFFER_H_ |
OLD | NEW |