LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/video_coding - timestamp_map.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 24 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
       3             :  *
       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
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #include <assert.h>
      12             : #include <stdlib.h>
      13             : 
      14             : #include "webrtc/modules/include/module_common_types.h"
      15             : #include "webrtc/modules/video_coding/timestamp_map.h"
      16             : 
      17             : namespace webrtc {
      18             : 
      19           0 : VCMTimestampMap::VCMTimestampMap(size_t capacity)
      20           0 :     : ring_buffer_(new TimestampDataTuple[capacity]),
      21             :       capacity_(capacity),
      22             :       next_add_idx_(0),
      23           0 :       next_pop_idx_(0) {}
      24             : 
      25           0 : VCMTimestampMap::~VCMTimestampMap() {}
      26             : 
      27           0 : void VCMTimestampMap::Add(uint32_t timestamp, VCMFrameInformation* data) {
      28           0 :   ring_buffer_[next_add_idx_].timestamp = timestamp;
      29           0 :   ring_buffer_[next_add_idx_].data = data;
      30           0 :   next_add_idx_ = (next_add_idx_ + 1) % capacity_;
      31             : 
      32           0 :   if (next_add_idx_ == next_pop_idx_) {
      33             :     // Circular list full; forget oldest entry.
      34           0 :     next_pop_idx_ = (next_pop_idx_ + 1) % capacity_;
      35             :   }
      36           0 : }
      37             : 
      38           0 : VCMFrameInformation* VCMTimestampMap::Pop(uint32_t timestamp) {
      39           0 :   while (!IsEmpty()) {
      40           0 :     if (ring_buffer_[next_pop_idx_].timestamp == timestamp) {
      41             :       // Found start time for this timestamp.
      42           0 :       VCMFrameInformation* data = ring_buffer_[next_pop_idx_].data;
      43           0 :       ring_buffer_[next_pop_idx_].data = nullptr;
      44           0 :       next_pop_idx_ = (next_pop_idx_ + 1) % capacity_;
      45           0 :       return data;
      46           0 :     } else if (IsNewerTimestamp(ring_buffer_[next_pop_idx_].timestamp,
      47             :                                 timestamp)) {
      48             :       // The timestamp we are looking for is not in the list.
      49           0 :       return nullptr;
      50             :     }
      51             : 
      52             :     // Not in this position, check next (and forget this position).
      53           0 :     next_pop_idx_ = (next_pop_idx_ + 1) % capacity_;
      54             :   }
      55             : 
      56             :   // Could not find matching timestamp in list.
      57           0 :   return nullptr;
      58             : }
      59             : 
      60           0 : bool VCMTimestampMap::IsEmpty() const {
      61           0 :   return (next_add_idx_ == next_pop_idx_);
      62             : }
      63             : }  // namespace webrtc

Generated by: LCOV version 1.13