Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / media / cast / sender / audio_encoder_unittest.cc
index 0764148..1ac66fd 100644 (file)
@@ -39,7 +39,12 @@ class TestEncodedAudioFrameReceiver {
     upper_bound_ = upper_bound;
   }
 
-  void FrameEncoded(scoped_ptr<EncodedFrame> encoded_frame) {
+  void SetSamplesPerFrame(int samples_per_frame) {
+    samples_per_frame_ = samples_per_frame;
+  }
+
+  void FrameEncoded(scoped_ptr<EncodedFrame> encoded_frame,
+                    int samples_skipped) {
     EXPECT_EQ(encoded_frame->dependency, EncodedFrame::KEY);
     EXPECT_EQ(static_cast<uint8>(frames_received_ & 0xff),
               encoded_frame->frame_id);
@@ -48,9 +53,7 @@ class TestEncodedAudioFrameReceiver {
     // of the fixed frame size.
     EXPECT_LE(rtp_lower_bound_, encoded_frame->rtp_timestamp);
     rtp_lower_bound_ = encoded_frame->rtp_timestamp;
-    // Note: In audio_encoder.cc, 100 is the fixed audio frame rate.
-    const int kSamplesPerFrame = kDefaultAudioSamplingRate / 100;
-    EXPECT_EQ(0u, encoded_frame->rtp_timestamp % kSamplesPerFrame);
+    EXPECT_EQ(0u, encoded_frame->rtp_timestamp % samples_per_frame_);
     EXPECT_TRUE(!encoded_frame->data.empty());
 
     EXPECT_LE(lower_bound_, encoded_frame->reference_time);
@@ -64,6 +67,7 @@ class TestEncodedAudioFrameReceiver {
   const Codec codec_;
   int frames_received_;
   uint32 rtp_lower_bound_;
+  int samples_per_frame_;
   base::TimeTicks lower_bound_;
   base::TimeTicks upper_bound_;
 
@@ -98,7 +102,7 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> {
     testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks());
   }
 
-  virtual void SetUp() {
+  void SetUp() override {
     task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_);
     cast_environment_ =
         new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(),
@@ -115,9 +119,7 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> {
 
     CreateObjectsForCodec(codec);
 
-    // Note: In audio_encoder.cc, 10 ms is the fixed frame duration.
-    const base::TimeDelta frame_duration =
-        base::TimeDelta::FromMilliseconds(10);
+    const base::TimeDelta frame_duration = audio_encoder_->GetFrameDuration();
 
     for (size_t i = 0; i < scenario.num_durations; ++i) {
       const bool simulate_missing_data = scenario.durations_in_ms[i] < 0;
@@ -159,6 +161,8 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> {
         codec,
         base::Bind(&TestEncodedAudioFrameReceiver::FrameEncoded,
                    base::Unretained(receiver_.get()))));
+
+    receiver_->SetSamplesPerFrame(audio_encoder_->GetSamplesPerFrame());
   }
 
   base::SimpleTestTickClock* testing_clock_;  // Owned by CastEnvironment.
@@ -179,6 +183,12 @@ TEST_P(AudioEncoderTest, EncodePcm16) {
   RunTestForCodec(CODEC_AUDIO_PCM16);
 }
 
+#if defined(OS_MACOSX)
+TEST_P(AudioEncoderTest, EncodeAac) {
+  RunTestForCodec(CODEC_AUDIO_AAC);
+}
+#endif
+
 static const int64 kOneCall_3Millis[] = {3};
 static const int64 kOneCall_10Millis[] = {10};
 static const int64 kOneCall_13Millis[] = {13};