modules/video_coding/generic_encoder_unittest.cc
// Emulates |num_frames| on |num_streams| frames with capture timestamps
// increased by 1 from 0. Size of each frame is between
// |min_frame_size| and |max_frame_size|, outliers are counted relatevely to
// |average_frame_sizes[]| for each stream.
Emulates |num_frames| on |num_streams| frames with capture timestamps
increased by 1 from 0.
Emulates |num_frames| on |num_streams| frames with capture timestamps increased by 1 from 0 .
std::vector<std::vector<FrameType>> GetTimingFrames(
    const int64_t delay_ms,
    const size_t min_frame_size,
    const size_t max_frame_size,
    std::vector<size_t> average_frame_sizes,
    const int num_streams,
    const int num_frames) {
  FakeEncodedImageCallback sink;
  VCMEncodedFrameCallback callback(&sink, nullptr);
  const size_t kFramerate = 30;
  callback.SetTimingFramesThresholds(
      {delay_ms, kDefaultOutlierFrameSizePercent});
  callback.OnFrameRateChanged(kFramerate);
  int s, i;
  std::vector<std::vector<FrameType>> result(num_streams);
  for (s = 0; s < num_streams; ++s)
    callback.OnTargetBitrateChanged(average_frame_sizes[s] * kFramerate, s);
  int64_t current_timestamp = 0;
  for (i = 0; i < num_frames; ++i) {
    current_timestamp += 1;
    for (s = 0; s < num_streams; ++s) {
      bool dropped = i % (5 + s) == 0;
      EncodedImage image;
      CodecSpecificInfo codec_specific;
      image._length = FrameSize(min_frame_size, max_frame_size, s, i);
      image.capture_time_ms_ = current_timestamp;
      codec_specific.codecType = kVideoCodecGeneric;
      codec_specific.codecSpecific.generic.simulcast_idx = s;
      callback.OnEncodeStarted(current_timestamp, s);
      if (dropped) {
        result[s].push_back(FrameType::kDropped);
        continue;
      }
      callback.OnEncodedImage(image, &codec_specific, nullptr);
      if (sink.WasTimingFrame()) {
        result[s].push_back(FrameType::kTiming);
      } else {
        result[s].push_back(FrameType::kNormal);
      }
    }
  }
  return result;
}
std :: vector < std :: vector < FrameType > > GetTimingFrames ( const int64_t delay_ms , const size_t min_frame_size , const size_t max_frame_size , std :: vector < size_t > average_frame_sizes , const int num_streams , const int num_frames ) { FakeEncodedImageCallback sink ; VCMEncodedFrameCallback callback ( & sink , nullptr ) ; const size_t kFramerate = 30 ; callback . SetTimingFramesThresholds ( { delay_ms , kDefaultOutlierFrameSizePercent } ) ; callback . OnFrameRateChanged ( kFramerate ) ; int s , i ; std :: vector < std :: vector < FrameType > > result ( num_streams ) ; for ( s = 0 ; s < num_streams ; ++ s ) callback . OnTargetBitrateChanged ( average_frame_sizes [ s ] * kFramerate , s ) ; int64_t current_timestamp = 0 ; for ( i = 0 ; i < num_frames ; ++ i ) { current_timestamp += 1 ; for ( s = 0 ; s < num_streams ; ++ s ) { bool dropped = i % ( 5 + s ) == 0 ; EncodedImage image ; CodecSpecificInfo codec_specific ; image . _length = FrameSize ( min_frame_size , max_frame_size , s , i ) ; image . capture_time_ms_ = current_timestamp ; codec_specific . codecType = kVideoCodecGeneric ; codec_specific . codecSpecific . generic . simulcast_idx = s ; callback . OnEncodeStarted ( current_timestamp , s ) ; if ( dropped ) { result [ s ] . push_back ( FrameType :: kDropped ) ; continue ; } callback . OnEncodedImage ( image , & codec_specific , nullptr ) ; if ( sink . WasTimingFrame ( ) ) { result [ s ] . push_back ( FrameType :: kTiming ) ; } else { result [ s ] . push_back ( FrameType :: kNormal ) ; } } } return result ; }
Emulates |num_frames| on |num_streams| frames with capture timestamps
increased by 1 from 0.
Emulates |num_frames| on |num_streams| frames with capture timestamps increased by 1 from 0 .
// every (5+s)-th frame is dropped on s-th stream by design.