Home | History | Annotate | Download | only in test
      1 /*
      2  *  Copyright (c) 2012 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 "webrtc/modules/video_coding/codecs/test/predictive_packet_manipulator.h"
     12 
     13 #include <assert.h>
     14 #include <stdio.h>
     15 
     16 #include "webrtc/test/testsupport/packet_reader.h"
     17 
     18 namespace webrtc {
     19 namespace test {
     20 
     21 PredictivePacketManipulator::PredictivePacketManipulator(
     22     PacketReader* packet_reader,
     23     const NetworkingConfig& config)
     24     : PacketManipulatorImpl(packet_reader, config, false) {}
     25 
     26 PredictivePacketManipulator::~PredictivePacketManipulator() {}
     27 
     28 void PredictivePacketManipulator::AddRandomResult(double result) {
     29   assert(result >= 0.0 && result <= 1.0);
     30   random_results_.push(result);
     31 }
     32 
     33 double PredictivePacketManipulator::RandomUniform() {
     34   if (random_results_.size() == 0u) {
     35     fprintf(stderr,
     36             "No more stored results, please make sure AddRandomResult()"
     37             "is called same amount of times you're going to invoke the "
     38             "RandomUniform() function, i.e. once per packet.\n");
     39     assert(false);
     40   }
     41   double result = random_results_.front();
     42   random_results_.pop();
     43   return result;
     44 }
     45 
     46 }  // namespace test
     47 }  // namespace webrtc
     48