Refactor webrtc specific Event implementation to an EventFactory.

Review URL: https://webrtc-codereview.appspot.com/1187005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3664 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/video_coding/main/interface/video_coding.h b/webrtc/modules/video_coding/main/interface/video_coding.h
index 1593fb8..a61aab1 100644
--- a/webrtc/modules/video_coding/main/interface/video_coding.h
+++ b/webrtc/modules/video_coding/main/interface/video_coding.h
@@ -11,10 +11,11 @@
 #ifndef WEBRTC_MODULES_INTERFACE_VIDEO_CODING_H_
 #define WEBRTC_MODULES_INTERFACE_VIDEO_CODING_H_
 
-#include "common_video/interface/i420_video_frame.h"
-#include "modules/interface/module.h"
-#include "modules/interface/module_common_types.h"
-#include "modules/video_coding/main/interface/video_coding_defines.h"
+#include "webrtc/common_video/interface/i420_video_frame.h"
+#include "webrtc/modules/interface/module.h"
+#include "webrtc/modules/interface/module_common_types.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
+#include "webrtc/system_wrappers/interface/event_wrapper.h"
 
 namespace webrtc
 {
@@ -24,6 +25,22 @@
 class VideoDecoder;
 struct CodecSpecificInfo;
 
+class EventFactory {
+ public:
+  virtual ~EventFactory() {}
+
+  virtual EventWrapper* CreateEvent() = 0;
+};
+
+class EventFactoryImpl : public EventFactory {
+ public:
+  virtual ~EventFactoryImpl() {}
+
+  virtual EventWrapper* CreateEvent() {
+    return EventWrapper::Create();
+  }
+};
+
 class VideoCodingModule : public Module
 {
 public:
@@ -49,7 +66,8 @@
     static VideoCodingModule* Create(const WebRtc_Word32 id);
 
     static VideoCodingModule* Create(const WebRtc_Word32 id,
-                                     Clock* clock);
+                                     Clock* clock,
+                                     EventFactory* event_factory);
 
     static void Destroy(VideoCodingModule* module);
 
diff --git a/webrtc/modules/video_coding/main/source/event.h b/webrtc/modules/video_coding/main/source/event.h
deleted file mode 100644
index 39fd494..0000000
--- a/webrtc/modules/video_coding/main/source/event.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef WEBRTC_MODULES_VIDEO_CODING_EVENT_H_
-#define WEBRTC_MODULES_VIDEO_CODING_EVENT_H_
-
-#include "event_wrapper.h"
-
-namespace webrtc
-{
-
-//#define EVENT_DEBUG
-
-class VCMEvent : public EventWrapper
-{
-public:
-    VCMEvent() : _event(*EventWrapper::Create()) {};
-
-    virtual ~VCMEvent() { delete &_event; };
-
-    /**
-    *   Release waiting threads
-    */
-    bool Set() { return _event.Set(); };
-
-    bool Reset() { return _event.Reset(); };
-
-    /**
-    *   Wait for this event
-    */
-    EventTypeWrapper Wait(unsigned long maxTime)
-    {
-#ifdef EVENT_DEBUG
-        return kEventTimeout;
-#else
-        return _event.Wait(maxTime);
-#endif
-    };
-
-    /**
-    *   Start a timer
-    */
-    bool StartTimer(bool periodic, unsigned long time)
-                   { return _event.StartTimer(periodic, time); };
-    /**
-    *   Stop the timer
-    */
-    bool StopTimer() { return _event.StopTimer(); };
-
-private:
-    EventWrapper&      _event;
-};
-
-} // namespace webrtc
-
-#endif // WEBRTC_MODULES_VIDEO_CODING_EVENT_H_
diff --git a/webrtc/modules/video_coding/main/source/jitter_buffer.cc b/webrtc/modules/video_coding/main/source/jitter_buffer.cc
index 90e4efd..37c5a7d 100644
--- a/webrtc/modules/video_coding/main/source/jitter_buffer.cc
+++ b/webrtc/modules/video_coding/main/source/jitter_buffer.cc
@@ -7,12 +7,12 @@
  *  in the file PATENTS.  All contributing project authors may
  *  be found in the AUTHORS file in the root of the source tree.
  */
-#include "modules/video_coding/main/source/jitter_buffer.h"
+#include "webrtc/modules/video_coding/main/source/jitter_buffer.h"
 
 #include <algorithm>
 #include <cassert>
 
-#include "webrtc/modules/video_coding/main/source/event.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
 #include "webrtc/modules/video_coding/main/source/frame_buffer.h"
 #include "webrtc/modules/video_coding/main/source/inter_frame_delay.h"
 #include "webrtc/modules/video_coding/main/source/internal_defines.h"
@@ -21,6 +21,7 @@
 #include "webrtc/modules/video_coding/main/source/packet.h"
 #include "webrtc/system_wrappers/interface/clock.h"
 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
+#include "webrtc/system_wrappers/interface/event_wrapper.h"
 #include "webrtc/system_wrappers/interface/logging.h"
 #include "webrtc/system_wrappers/interface/trace.h"
 
@@ -67,6 +68,7 @@
 }
 
 VCMJitterBuffer::VCMJitterBuffer(Clock* clock,
+                                 EventFactory* event_factory,
                                  int vcm_id,
                                  int receiver_id,
                                  bool master)
@@ -76,8 +78,8 @@
       running_(false),
       crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
       master_(master),
-      frame_event_(),
-      packet_event_(),
+      frame_event_(event_factory->CreateEvent()),
+      packet_event_(event_factory->CreateEvent()),
       max_number_of_frames_(kStartNumberOfFrames),
       frame_buffers_(),
       frame_list_(),
@@ -192,8 +194,8 @@
   num_discarded_packets_ = 0;
 
   // Start in a non-signaled state.
-  frame_event_.Reset();
-  packet_event_.Reset();
+  frame_event_->Reset();
+  packet_event_->Reset();
   waiting_for_completion_.frame_size = 0;
   waiting_for_completion_.timestamp = 0;
   waiting_for_completion_.latest_packet_time = -1;
@@ -220,8 +222,8 @@
 
   crit_sect_->Leave();
   // Make sure we wake up any threads waiting on these events.
-  frame_event_.Set();
-  packet_event_.Set();
+  frame_event_->Set();
+  packet_event_->Set();
   WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
                VCMId(vcm_id_, receiver_id_), "JB(0x%x): Jitter buffer: stop",
                this);
@@ -241,8 +243,8 @@
   }
   last_decoded_state_.Reset();  // TODO(mikhal): sync reset.
   num_not_decodable_packets_ = 0;
-  frame_event_.Reset();
-  packet_event_.Reset();
+  frame_event_->Reset();
+  packet_event_->Reset();
   num_consecutive_old_frames_ = 0;
   num_consecutive_old_packets_ = 0;
   // Also reset the jitter and delay estimates
@@ -354,10 +356,10 @@
   FrameList::iterator it = frame_list_.begin();
 
   if (it == frame_list_.end()) {
-    packet_event_.Reset();
+    packet_event_->Reset();
     crit_sect_->Leave();
 
-    if (packet_event_.Wait(max_wait_time_ms) == kEventSignaled) {
+    if (packet_event_->Wait(max_wait_time_ms) == kEventSignaled) {
       // are we closing down the Jitter buffer
       if (!running_) {
         return -1;
@@ -449,7 +451,7 @@
     while (wait_time_ms > 0) {
       crit_sect_->Leave();
       const EventTypeWrapper ret =
-        frame_event_.Wait(static_cast<uint32_t>(wait_time_ms));
+        frame_event_->Wait(static_cast<uint32_t>(wait_time_ms));
       crit_sect_->Enter();
       if (ret == kEventSignaled) {
         // are we closing down the Jitter buffer
@@ -475,7 +477,7 @@
     // Inside |crit_sect_|.
   } else {
     // We already have a frame reset the event.
-    frame_event_.Reset();
+    frame_event_->Reset();
   }
 
   if (it == frame_list_.end()) {
@@ -763,13 +765,13 @@
       if (UpdateFrameState(frame) == kFlushIndicator)
         ret = kFlushIndicator;
       // Signal that we have a received packet.
-      packet_event_.Set();
+      packet_event_->Set();
       break;
     }
     case kDecodableSession:
     case kIncomplete: {
       // Signal that we have a received packet.
-      packet_event_.Set();
+      packet_event_->Set();
       break;
     }
     case kNoError:
@@ -1178,7 +1180,7 @@
   // Only signal if this is the oldest frame.
   // Not necessarily the case due to packet reordering or NACK.
   if (!WaitForRetransmissions() || (old_frame != NULL && old_frame == frame)) {
-    frame_event_.Set();
+    frame_event_->Set();
   }
   return kNoError;
 }
diff --git a/webrtc/modules/video_coding/main/source/jitter_buffer.h b/webrtc/modules/video_coding/main/source/jitter_buffer.h
index a426590..0b07c53 100644
--- a/webrtc/modules/video_coding/main/source/jitter_buffer.h
+++ b/webrtc/modules/video_coding/main/source/jitter_buffer.h
@@ -18,7 +18,6 @@
 #include "webrtc/modules/interface/module_common_types.h"
 #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
 #include "webrtc/modules/video_coding/main/source/decoding_state.h"
-#include "webrtc/modules/video_coding/main/source/event.h"
 #include "webrtc/modules/video_coding/main/source/inter_frame_delay.h"
 #include "webrtc/modules/video_coding/main/source/jitter_buffer_common.h"
 #include "webrtc/modules/video_coding/main/source/jitter_estimator.h"
@@ -40,6 +39,8 @@
 
 // forward declarations
 class Clock;
+class EventFactory;
+class EventWrapper;
 class VCMFrameBuffer;
 class VCMPacket;
 class VCMEncodedFrame;
@@ -54,6 +55,7 @@
 class VCMJitterBuffer {
  public:
   VCMJitterBuffer(Clock* clock,
+                  EventFactory* event_factory,
                   int vcm_id,
                   int receiver_id,
                   bool master);
@@ -248,9 +250,9 @@
   CriticalSectionWrapper* crit_sect_;
   bool master_;
   // Event to signal when we have a frame ready for decoder.
-  VCMEvent frame_event_;
+  scoped_ptr<EventWrapper> frame_event_;
   // Event to signal when we have received a packet.
-  VCMEvent packet_event_;
+  scoped_ptr<EventWrapper> packet_event_;
   // Number of allocated frames.
   int max_number_of_frames_;
   // Array of pointers to the frames in jitter buffer.
diff --git a/webrtc/modules/video_coding/main/source/jitter_buffer_unittest.cc b/webrtc/modules/video_coding/main/source/jitter_buffer_unittest.cc
index fe3cdfa..1b2f37d 100644
--- a/webrtc/modules/video_coding/main/source/jitter_buffer_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/jitter_buffer_unittest.cc
@@ -12,10 +12,11 @@
 
 #include <list>
 
-#include "gtest/gtest.h"
-#include "modules/video_coding/main/source/jitter_buffer.h"
-#include "modules/video_coding/main/source/media_opt_util.h"
-#include "modules/video_coding/main/source/packet.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/modules/video_coding/main/source/jitter_buffer.h"
+#include "webrtc/modules/video_coding/main/source/media_opt_util.h"
+#include "webrtc/modules/video_coding/main/source/packet.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
 #include "webrtc/system_wrappers/interface/clock.h"
 
 namespace webrtc {
@@ -163,7 +164,8 @@
     clock_.reset(new SimulatedClock(0));
     max_nack_list_size_ = 150;
     oldest_packet_to_nack_ = 250;
-    jitter_buffer_ = new VCMJitterBuffer(clock_.get(), -1, -1, true);
+    jitter_buffer_ = new VCMJitterBuffer(clock_.get(), &event_factory_, -1, -1,
+                                         true);
     stream_generator = new StreamGenerator(0, 0, clock_->TimeInMilliseconds());
     jitter_buffer_->Start();
     jitter_buffer_->SetNackSettings(max_nack_list_size_,
@@ -249,6 +251,7 @@
   VCMJitterBuffer* jitter_buffer_;
   StreamGenerator* stream_generator;
   scoped_ptr<SimulatedClock> clock_;
+  NullEventFactory event_factory_;
   size_t max_nack_list_size_;
   int oldest_packet_to_nack_;
   uint8_t data_buffer_[kDataBufferSize];
diff --git a/webrtc/modules/video_coding/main/source/receiver.cc b/webrtc/modules/video_coding/main/source/receiver.cc
index 04fd131..9747244 100644
--- a/webrtc/modules/video_coding/main/source/receiver.cc
+++ b/webrtc/modules/video_coding/main/source/receiver.cc
@@ -25,6 +25,7 @@
 
 VCMReceiver::VCMReceiver(VCMTiming* timing,
                          Clock* clock,
+                         EventFactory* event_factory,
                          int32_t vcm_id,
                          int32_t receiver_id,
                          bool master)
@@ -33,14 +34,14 @@
       clock_(clock),
       receiver_id_(receiver_id),
       master_(master),
-      jitter_buffer_(clock_, vcm_id, receiver_id, master),
+      jitter_buffer_(clock_, event_factory, vcm_id, receiver_id, master),
       timing_(timing),
-      render_wait_event_(),
+      render_wait_event_(event_factory->CreateEvent()),
       state_(kPassive),
       max_video_delay_ms_(kMaxVideoDelayMs) {}
 
 VCMReceiver::~VCMReceiver() {
-  render_wait_event_.Set();
+  render_wait_event_->Set();
   delete crit_sect_;
 }
 
@@ -51,7 +52,7 @@
   } else {
     jitter_buffer_.Flush();
   }
-  render_wait_event_.Reset();
+  render_wait_event_->Reset();
   if (master_) {
     state_ = kReceiving;
   } else {
@@ -298,7 +299,7 @@
     return NULL;
   }
   // Wait until it's time to render.
-  render_wait_event_.Wait(wait_time_ms);
+  render_wait_event_->Wait(wait_time_ms);
 
   // Get a complete frame if possible.
   VCMEncodedFrame* frame = jitter_buffer_.GetCompleteFrameForDecoding(0);
diff --git a/webrtc/modules/video_coding/main/source/receiver.h b/webrtc/modules/video_coding/main/source/receiver.h
index b64582d..88f2fb2 100644
--- a/webrtc/modules/video_coding/main/source/receiver.h
+++ b/webrtc/modules/video_coding/main/source/receiver.h
@@ -37,9 +37,10 @@
  public:
   VCMReceiver(VCMTiming* timing,
               Clock* clock,
-              int32_t vcm_id = -1,
-              int32_t receiver_id = -1,
-              bool master = true);
+              EventFactory* event_factory,
+              int32_t vcm_id,
+              int32_t receiver_id,
+              bool master);
   ~VCMReceiver();
 
   void Reset();
@@ -94,7 +95,7 @@
   bool master_;
   VCMJitterBuffer jitter_buffer_;
   VCMTiming* timing_;
-  VCMEvent render_wait_event_;
+  scoped_ptr<EventWrapper> render_wait_event_;
   VCMReceiverState state_;
   int max_video_delay_ms_;
 
diff --git a/webrtc/modules/video_coding/main/source/video_coding.gypi b/webrtc/modules/video_coding/main/source/video_coding.gypi
index 3f5eb35..b7c6e30 100644
--- a/webrtc/modules/video_coding/main/source/video_coding.gypi
+++ b/webrtc/modules/video_coding/main/source/video_coding.gypi
@@ -42,7 +42,6 @@
         'decoding_state.h',
         'encoded_frame.h',
         'er_tables_xor.h',
-        'event.h',
         'fec_tables_xor.h',
         'frame_buffer.h',
         'generic_decoder.h',
diff --git a/webrtc/modules/video_coding/main/source/video_coding_impl.cc b/webrtc/modules/video_coding/main/source/video_coding_impl.cc
index 70e84ff..ed9e7a1 100644
--- a/webrtc/modules/video_coding/main/source/video_coding_impl.cc
+++ b/webrtc/modules/video_coding/main/source/video_coding_impl.cc
@@ -44,7 +44,9 @@
 }
 
 VideoCodingModuleImpl::VideoCodingModuleImpl(const WebRtc_Word32 id,
-                                             Clock* clock)
+                                             Clock* clock,
+                                             EventFactory* event_factory,
+                                             bool owns_event_factory)
 :
 _id(id),
 clock_(clock),
@@ -52,8 +54,8 @@
 _receiverInited(false),
 _timing(clock_, id, 1),
 _dualTiming(clock_, id, 2, &_timing),
-_receiver(&_timing, clock_, id, 1),
-_dualReceiver(&_dualTiming, clock_, id, 2, false),
+_receiver(&_timing, clock_, event_factory, id, 1, true),
+_dualReceiver(&_dualTiming, clock_, event_factory, id, 2, false),
 _decodedFrameCallback(_timing, clock_),
 _dualDecodedFrameCallback(_dualTiming, clock_),
 _frameTypeCallback(NULL),
@@ -82,7 +84,9 @@
 _receiveStatsTimer(1000, clock_),
 _sendStatsTimer(1000, clock_),
 _retransmissionTimer(10, clock_),
-_keyRequestTimer(500, clock_)
+_keyRequestTimer(500, clock_),
+event_factory_(event_factory),
+owns_event_factory_(owns_event_factory)
 {
     assert(clock_);
 #ifdef DEBUG_DECODER_BIT_STREAM
@@ -98,6 +102,9 @@
     }
     delete _receiveCritSect;
     delete _sendCritSect;
+    if (owns_event_factory_) {
+      delete event_factory_;
+    }
 #ifdef DEBUG_DECODER_BIT_STREAM
     fclose(_bitStreamBeforeDecoder);
 #endif
@@ -110,14 +117,17 @@
 VideoCodingModule*
 VideoCodingModule::Create(const WebRtc_Word32 id)
 {
-    return new VideoCodingModuleImpl(id, Clock::GetRealTimeClock());
+    return new VideoCodingModuleImpl(id, Clock::GetRealTimeClock(),
+                                     new EventFactoryImpl, true);
 }
 
 VideoCodingModule*
-VideoCodingModule::Create(const WebRtc_Word32 id, Clock* clock)
+VideoCodingModule::Create(const WebRtc_Word32 id, Clock* clock,
+                          EventFactory* event_factory)
 {
     assert(clock);
-    return new VideoCodingModuleImpl(id, clock);
+    assert(event_factory);
+    return new VideoCodingModuleImpl(id, clock, event_factory, false);
 }
 
 void
diff --git a/webrtc/modules/video_coding/main/source/video_coding_impl.h b/webrtc/modules/video_coding/main/source/video_coding_impl.h
index ec2b8d8..22bf8d2 100644
--- a/webrtc/modules/video_coding/main/source/video_coding_impl.h
+++ b/webrtc/modules/video_coding/main/source/video_coding_impl.h
@@ -58,7 +58,8 @@
 class VideoCodingModuleImpl : public VideoCodingModule
 {
 public:
-    VideoCodingModuleImpl(const WebRtc_Word32 id, Clock* clock);
+    VideoCodingModuleImpl(const WebRtc_Word32 id, Clock* clock,
+                          EventFactory* event_factory, bool owns_event_factory);
 
     virtual ~VideoCodingModuleImpl();
 
@@ -316,6 +317,8 @@
     VCMProcessTimer                     _sendStatsTimer;
     VCMProcessTimer                     _retransmissionTimer;
     VCMProcessTimer                     _keyRequestTimer;
+    EventFactory*                       event_factory_;
+    bool                                owns_event_factory_;
 };
 } // namespace webrtc
 #endif // WEBRTC_MODULES_VIDEO_CODING_VIDEO_CODING_IMPL_H_
diff --git a/webrtc/modules/video_coding/main/source/video_coding_impl_unittest.cc b/webrtc/modules/video_coding/main/source/video_coding_impl_unittest.cc
index 6fe92a9..7244b3b 100644
--- a/webrtc/modules/video_coding/main/source/video_coding_impl_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/video_coding_impl_unittest.cc
@@ -10,14 +10,14 @@
 
 #include <vector>
 
+#include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h"
 #include "webrtc/modules/video_coding/main/interface/mock/mock_vcm_callbacks.h"
 #include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
 #include "webrtc/system_wrappers/interface/clock.h"
 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
 
-#include "gtest/gtest.h"
-
 using ::testing::_;
 using ::testing::AllOf;
 using ::testing::ElementsAre;
@@ -39,7 +39,7 @@
 
   virtual void SetUp() {
     clock_.reset(new SimulatedClock(0));
-    vcm_ = VideoCodingModule::Create(0, clock_.get());
+    vcm_ = VideoCodingModule::Create(0, clock_.get(), &event_factory_);
     EXPECT_EQ(0, vcm_->InitializeReceiver());
     EXPECT_EQ(0, vcm_->InitializeSender());
     EXPECT_EQ(0, vcm_->RegisterExternalEncoder(&encoder_, kUnusedPayloadType,
@@ -125,6 +125,7 @@
 
   VideoCodingModule* vcm_;
   scoped_ptr<SimulatedClock> clock_;
+  NullEventFactory event_factory_;
   NiceMock<MockVideoDecoder> decoder_;
   NiceMock<MockVideoEncoder> encoder_;
   I420VideoFrame input_frame_;
diff --git a/webrtc/modules/video_coding/main/source/video_coding_robustness_unittest.cc b/webrtc/modules/video_coding/main/source/video_coding_robustness_unittest.cc
index ca7672f..d7e0723 100644
--- a/webrtc/modules/video_coding/main/source/video_coding_robustness_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/video_coding_robustness_unittest.cc
@@ -8,11 +8,12 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-#include "modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h"
-#include "modules/video_coding/main/interface/video_coding.h"
-#include "modules/video_coding/main/interface/mock/mock_vcm_callbacks.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/interface/mock/mock_vcm_callbacks.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
 #include "webrtc/system_wrappers/interface/clock.h"
 
 namespace webrtc {
@@ -34,7 +35,7 @@
   virtual void SetUp() {
     clock_.reset(new SimulatedClock(0));
     ASSERT_TRUE(clock_.get() != NULL);
-    vcm_ = VideoCodingModule::Create(0, clock_.get());
+    vcm_ = VideoCodingModule::Create(0, clock_.get(), &event_factory_);
     ASSERT_TRUE(vcm_ != NULL);
     ASSERT_EQ(0, vcm_->InitializeReceiver());
     const size_t kMaxNackListSize = 250;
@@ -80,6 +81,7 @@
   NiceMock<MockVideoDecoder> decoder_;
   NiceMock<MockVideoDecoder> decoderCopy_;
   scoped_ptr<SimulatedClock> clock_;
+  NullEventFactory event_factory_;
 };
 
 TEST_F(VCMRobustnessTest, TestHardNack) {
diff --git a/webrtc/modules/video_coding/main/test/codec_database_test.cc b/webrtc/modules/video_coding/main/test/codec_database_test.cc
index 980eaaa..9ee82bf 100644
--- a/webrtc/modules/video_coding/main/test/codec_database_test.cc
+++ b/webrtc/modules/video_coding/main/test/codec_database_test.cc
@@ -11,20 +11,19 @@
 // Implementation of codec data base test
 // testing is done via the VCM module, no specific CodecDataBase module functionality.
 
-#include "codec_database_test.h"
+#include "webrtc/modules/video_coding/main/test/codec_database_test.h"
 
 #include <assert.h>
 #include <stdio.h>
 
-#include "../../../../engine_configurations.h"
-#include "../source/event.h"
-#include "test_callbacks.h"
-#include "test_macros.h"
-#include "test_util.h"
-#include "testsupport/fileutils.h"
-#include "testsupport/metrics/video_metrics.h"
-#include "vp8.h" // for external codecs test
-
+#include "webrtc/engine_configurations.h"
+#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/test_callbacks.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
+#include "webrtc/test/testsupport/fileutils.h"
+#include "webrtc/test/testsupport/metrics/video_metrics.h"
 
 using namespace webrtc;
 
diff --git a/webrtc/modules/video_coding/main/test/decode_from_storage_test.cc b/webrtc/modules/video_coding/main/test/decode_from_storage_test.cc
index 5d1c916..c1f91d0 100644
--- a/webrtc/modules/video_coding/main/test/decode_from_storage_test.cc
+++ b/webrtc/modules/video_coding/main/test/decode_from_storage_test.cc
@@ -8,13 +8,12 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "receiver_tests.h"
-#include "video_coding.h"
-#include "rtp_rtcp.h"
-#include "trace.h"
-#include "../source/event.h"
-#include "rtp_player.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/receiver_tests.h"
+#include "webrtc/modules/video_coding/main/test/rtp_player.h"
 #include "webrtc/system_wrappers/interface/clock.h"
+#include "webrtc/system_wrappers/interface/trace.h"
 
 using namespace webrtc;
 
@@ -35,12 +34,7 @@
 
 int DecodeFromStorageTest(CmdArgs& args)
 {
-    // Make sure this test isn't executed without simulated events.
-#if !defined(EVENT_DEBUG)
-    return -1;
-#endif
     // BEGIN Settings
-
     bool protectionEnabled = false;
     VCMVideoProtection protectionMethod = kProtectionNack;
     WebRtc_UWord32 rttMS = 100;
@@ -65,9 +59,12 @@
 
 
     SimulatedClock clock(0);
+    NullEventFactory event_factory;
     // TODO(hlundin): This test was not verified after changing to FakeTickTime.
-    VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
-    VideoCodingModule* vcmPlayback = VideoCodingModule::Create(2, &clock);
+    VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock,
+                                                       &event_factory);
+    VideoCodingModule* vcmPlayback = VideoCodingModule::Create(2, &clock,
+                                                               &event_factory);
     FrameStorageCallback storageCallback(vcmPlayback);
     RtpDataCallback dataCallback(vcm);
     WebRtc_Word32 ret = vcm->InitializeReceiver();
diff --git a/webrtc/modules/video_coding/main/test/generic_codec_test.cc b/webrtc/modules/video_coding/main/test/generic_codec_test.cc
index 3f21a65..e549b9a 100644
--- a/webrtc/modules/video_coding/main/test/generic_codec_test.cc
+++ b/webrtc/modules/video_coding/main/test/generic_codec_test.cc
@@ -8,13 +8,15 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "generic_codec_test.h"
+#include "webrtc/modules/video_coding/main/test/generic_codec_test.h"
+
 #include <cmath>
 #include <stdio.h>
-#include "../source/event.h"
-#include "rtp_rtcp.h"
-#include "common_video/interface/i420_video_frame.h"
-#include "test_macros.h"
+
+#include "webrtc/common_video/interface/i420_video_frame.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
 #include "webrtc/system_wrappers/interface/clock.h"
 
 using namespace webrtc;
@@ -23,12 +25,10 @@
 
 int GenericCodecTest::RunTest(CmdArgs& args)
 {
-#if !defined(EVENT_DEBUG)
-    printf("\n\nEnable debug events to run this test!\n\n");
-    return -1;
-#endif
     SimulatedClock clock(0);
-    VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
+    NullEventFactory event_factory;
+    VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock,
+                                                       &event_factory);
     GenericCodecTest* get = new GenericCodecTest(vcm, &clock);
     Trace::CreateTrace();
     Trace::SetTraceFile(
diff --git a/webrtc/modules/video_coding/main/test/jitter_buffer_test.cc b/webrtc/modules/video_coding/main/test/jitter_buffer_test.cc
index aae2cf5..e34e986 100644
--- a/webrtc/modules/video_coding/main/test/jitter_buffer_test.cc
+++ b/webrtc/modules/video_coding/main/test/jitter_buffer_test.cc
@@ -8,20 +8,20 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include <math.h>
-#include <stdio.h>
+#include "webrtc/modules/video_coding/main/test/jitter_estimate_test.h"
 
-#include "common_types.h"
-#include "../source/event.h"
-#include "frame_buffer.h"
-#include "inter_frame_delay.h"
-#include "jitter_buffer.h"
-#include "jitter_estimate_test.h"
-#include "jitter_estimator.h"
-#include "media_opt_util.h"
-#include "packet.h"
-#include "test_util.h"
-#include "test_macros.h"
+#include <math.h>
+
+#include "webrtc/common_types.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/source/frame_buffer.h"
+#include "webrtc/modules/video_coding/main/source/inter_frame_delay.h"
+#include "webrtc/modules/video_coding/main/source/jitter_buffer.h"
+#include "webrtc/modules/video_coding/main/source/jitter_estimator.h"
+#include "webrtc/modules/video_coding/main/source/media_opt_util.h"
+#include "webrtc/modules/video_coding/main/source/packet.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
 #include "webrtc/system_wrappers/interface/clock.h"
 
 // TODO(holmer): Get rid of this to conform with style guide.
@@ -93,10 +93,6 @@
 
 int JitterBufferTest(CmdArgs& args)
 {
-    // Don't run these tests with debug event.
-#if defined(EVENT_DEBUG)
-    return -1;
-#endif
     Clock* clock = Clock::GetRealTimeClock();
 
     // Start test
@@ -106,7 +102,8 @@
     WebRtc_UWord8 data[1500];
     VCMPacket packet(data, size, seqNum, timeStamp, true);
 
-    VCMJitterBuffer jb(clock, -1, -1, true);
+    NullEventFactory event_factory;
+    VCMJitterBuffer jb(clock, &event_factory, -1, -1, true);
 
     seqNum = 1234;
     timeStamp = 123*90;
diff --git a/webrtc/modules/video_coding/main/test/media_opt_test.cc b/webrtc/modules/video_coding/main/test/media_opt_test.cc
index 12697cf..7d492c9 100644
--- a/webrtc/modules/video_coding/main/test/media_opt_test.cc
+++ b/webrtc/modules/video_coding/main/test/media_opt_test.cc
@@ -11,19 +11,17 @@
 // Implementation of Media Optimization Test
 // testing is done via the VCM module, no specific Media opt functionality.
 
-#include "media_opt_test.h"
+#include "webrtc/modules/video_coding/main/test/media_opt_test.h"
 
 #include <string.h>
 #include <stdio.h>
 #include <time.h>
 #include <vector>
 
-#include "../source/event.h"
-#include "test_macros.h"
-#include "test_util.h" // send side callback
-#include "testsupport/metrics/video_metrics.h"
-#include "video_coding.h"
-
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
+#include "webrtc/test/testsupport/metrics/video_metrics.h"
 
 using namespace webrtc;
 
@@ -32,8 +30,8 @@
     Trace::CreateTrace();
     Trace::SetTraceFile((test::OutputPath() + "mediaOptTestTrace.txt").c_str());
     Trace::SetLevelFilter(webrtc::kTraceAll);
+    VideoCodingModule* vcm = VideoCodingModule::Create(1);
     Clock* clock = Clock::GetRealTimeClock();
-    VideoCodingModule* vcm = VideoCodingModule::Create(1, clock);
     MediaOptTest* mot = new MediaOptTest(vcm, clock);
     if (testNum == 0)
     { // regular
diff --git a/webrtc/modules/video_coding/main/test/mt_rx_tx_test.cc b/webrtc/modules/video_coding/main/test/mt_rx_tx_test.cc
index fd959dd..f91f1a8 100644
--- a/webrtc/modules/video_coding/main/test/mt_rx_tx_test.cc
+++ b/webrtc/modules/video_coding/main/test/mt_rx_tx_test.cc
@@ -16,15 +16,14 @@
 
 #include <string.h>
 
-#include "../source/event.h"
-#include "media_opt_test.h"
-#include "mt_test_common.h"
-#include "receiver_tests.h" // shared RTP state and receive side threads
-#include "rtp_rtcp.h"
-#include "test_macros.h"
-#include "test_util.h" // send side callback
-#include "thread_wrapper.h"
-#include "video_coding.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/media_opt_test.h"
+#include "webrtc/modules/video_coding/main/test/mt_test_common.h"
+#include "webrtc/modules/video_coding/main/test/receiver_tests.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
+#include "webrtc/system_wrappers/interface/thread_wrapper.h"
 
 using namespace webrtc;
 
@@ -143,12 +142,11 @@
         printf("Cannot read file %s.\n", outname.c_str());
         return -1;
     }
-    Clock* clock = Clock::GetRealTimeClock();
-    VideoCodingModule* vcm = VideoCodingModule::Create(1, clock);
+    VideoCodingModule* vcm = VideoCodingModule::Create(1);
     RtpDataCallback dataCallback(vcm);
 
     RTPSendCompleteCallback* outgoingTransport =
-        new RTPSendCompleteCallback(clock, "dump.rtp");
+        new RTPSendCompleteCallback(Clock::GetRealTimeClock(), "dump.rtp");
 
     RtpRtcp::Configuration configuration;
     configuration.id = 1;
diff --git a/webrtc/modules/video_coding/main/test/normal_test.cc b/webrtc/modules/video_coding/main/test/normal_test.cc
index e88ff87..4689462 100644
--- a/webrtc/modules/video_coding/main/test/normal_test.cc
+++ b/webrtc/modules/video_coding/main/test/normal_test.cc
@@ -8,40 +8,36 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "normal_test.h"
+#include "webrtc/modules/video_coding/main/test/normal_test.h"
 
 #include <assert.h>
 #include <iostream>
 #include <sstream>
 #include <time.h>
 
-#include "../source/event.h"
-#include "common_video/libyuv/include/webrtc_libyuv.h"
-#include "common_types.h"
-#include "test_callbacks.h"
-#include "test_macros.h"
-#include "test_util.h"
-#include "trace.h"
-#include "testsupport/metrics/video_metrics.h"
+#include "webrtc/common_types.h"
+#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/test_callbacks.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
+#include "webrtc/test/testsupport/metrics/video_metrics.h"
 #include "webrtc/system_wrappers/interface/clock.h"
+#include "webrtc/system_wrappers/interface/trace.h"
 
 using namespace webrtc;
 
 int NormalTest::RunTest(const CmdArgs& args)
 {
-#if defined(EVENT_DEBUG)
-    printf("SIMULATION TIME\n");
-    SimulatedClock sim_clock;
+    SimulatedClock sim_clock(0);
     SimulatedClock* clock = &sim_clock;
-#else
-    printf("REAL-TIME\n");
-    Clock* clock = Clock::GetRealTimeClock();
-#endif
+    NullEventFactory event_factory;
     Trace::CreateTrace();
     Trace::SetTraceFile(
         (test::OutputPath() + "VCMNormalTestTrace.txt").c_str());
     Trace::SetLevelFilter(webrtc::kTraceAll);
-    VideoCodingModule* vcm = VideoCodingModule::Create(1, clock);
+    VideoCodingModule* vcm = VideoCodingModule::Create(1, clock,
+                                                       &event_factory);
     NormalTest VCMNTest(vcm, clock);
     VCMNTest.Perform(args);
     VideoCodingModule::Destroy(vcm);
@@ -289,9 +285,6 @@
   _vcm->RegisterSendStatisticsCallback(&sendStats);
 
   while (feof(_sourceFile) == 0) {
-#if !defined(EVENT_DEBUG)
-    WebRtc_Word64 processStartTime = _clock->TimeInMilliseconds();
-#endif
     TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0 ||
          feof(_sourceFile));
     _frameCnt++;
@@ -331,17 +324,7 @@
     WebRtc_UWord32 framePeriod =
         static_cast<WebRtc_UWord32>(
             1000.0f / static_cast<float>(_sendCodec.maxFramerate) + 0.5f);
-
-#if defined(EVENT_DEBUG)
     static_cast<SimulatedClock*>(_clock)->AdvanceTimeMilliseconds(framePeriod);
-#else
-    WebRtc_Word64 timeSpent =
-        _clock->TimeInMilliseconds() - processStartTime;
-    if (timeSpent < framePeriod)
-    {
-      waitEvent->Wait(framePeriod - timeSpent);
-    }
-#endif
   }
   double endTime = clock()/(double)CLOCKS_PER_SEC;
   _testTotalTime = endTime - startTime;
diff --git a/webrtc/modules/video_coding/main/test/quality_modes_test.cc b/webrtc/modules/video_coding/main/test/quality_modes_test.cc
index 81f3d9d..a382374 100644
--- a/webrtc/modules/video_coding/main/test/quality_modes_test.cc
+++ b/webrtc/modules/video_coding/main/test/quality_modes_test.cc
@@ -8,29 +8,30 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "quality_modes_test.h"
+#include "webrtc/modules/video_coding/main/test/quality_modes_test.h"
 
 #include <time.h>
 #include <iostream>
 #include <string>
 #include <sstream>
 
-#include "common_video/libyuv/include/webrtc_libyuv.h"
-#include "modules/video_coding/main/source/event.h"
-#include "modules/video_coding/main/test/test_callbacks.h"
-#include "modules/video_coding/main/test/test_macros.h"
-#include "modules/video_coding/main/test/test_util.h"
-#include "system_wrappers/interface/data_log.h"
-#include "system_wrappers/interface/data_log.h"
-#include "testsupport/metrics/video_metrics.h"
+#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/test_callbacks.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
 #include "webrtc/system_wrappers/interface/clock.h"
+#include "webrtc/system_wrappers/interface/data_log.h"
+#include "webrtc/system_wrappers/interface/data_log.h"
+#include "webrtc/test/testsupport/metrics/video_metrics.h"
 
 using namespace webrtc;
 
 int qualityModeTest(const CmdArgs& args)
 {
   SimulatedClock clock(0);
-  VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
+  NullEventFactory event_factory;
+  VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock, &event_factory);
   QualityModesTest QMTest(vcm, &clock);
   QMTest.Perform(args);
   VideoCodingModule::Destroy(vcm);
diff --git a/webrtc/modules/video_coding/main/test/receiver_timing_tests.cc b/webrtc/modules/video_coding/main/test/receiver_timing_tests.cc
index b273b0e..7b64f09 100644
--- a/webrtc/modules/video_coding/main/test/receiver_timing_tests.cc
+++ b/webrtc/modules/video_coding/main/test/receiver_timing_tests.cc
@@ -8,19 +8,18 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "receiver_tests.h"
-#include "video_coding.h"
-#include "trace.h"
-#include "../source/event.h"
-#include "../source/internal_defines.h"
-#include "timing.h"
-#include "test_macros.h"
-#include "test_util.h"
-
 #include <cstdio>
 #include <cstdlib>
 #include <cmath>
 
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/source/internal_defines.h"
+#include "webrtc/modules/video_coding/main/source/timing.h"
+#include "webrtc/modules/video_coding/main/test/receiver_tests.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
+#include "webrtc/system_wrappers/interface/trace.h"
+
 using namespace webrtc;
 
 float vcmFloatMax(float a, float b)
@@ -48,11 +47,6 @@
 
 int ReceiverTimingTests(CmdArgs& args)
 {
-    // Make sure this test is never executed with simulated events.
-#if defined(EVENT_DEBUG)
-    return -1;
-#endif
-
     // Set up trace
     Trace::CreateTrace();
     Trace::SetTraceFile((test::OutputPath() + "receiverTestTrace.txt").c_str());
diff --git a/webrtc/modules/video_coding/main/test/rtp_player.cc b/webrtc/modules/video_coding/main/test/rtp_player.cc
index a52a1cd..20ae1ae 100644
--- a/webrtc/modules/video_coding/main/test/rtp_player.cc
+++ b/webrtc/modules/video_coding/main/test/rtp_player.cc
@@ -18,7 +18,7 @@
 #include <arpa/inet.h>
 #endif
 
-#include "gtest/gtest.h"
+#include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
 #include "webrtc/modules/video_coding/main/source/internal_defines.h"
 #include "webrtc/modules/video_coding/main/test/test_util.h"
diff --git a/webrtc/modules/video_coding/main/test/test_util.h b/webrtc/modules/video_coding/main/test/test_util.h
index 525f1e3..dc8ec38 100644
--- a/webrtc/modules/video_coding/main/test/test_util.h
+++ b/webrtc/modules/video_coding/main/test/test_util.h
@@ -19,8 +19,10 @@
 #include <fstream>
 #include <cstdlib>
 
-#include "module_common_types.h"
-#include "testsupport/fileutils.h"
+#include "webrtc/modules/interface/module_common_types.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/system_wrappers/interface/event_wrapper.h"
+#include "webrtc/test/testsupport/fileutils.h"
 
 enum { kMaxNackListSize = 250 };
 enum { kMaxPacketAgeToNack = 450 };
@@ -72,6 +74,31 @@
   WebRtc_Word64 receiveTime;
 };
 
+class NullEvent : public webrtc::EventWrapper {
+ public:
+  virtual ~NullEvent() {}
+
+  virtual bool Set() { return true; }
+
+  virtual bool Reset() { return true; }
+
+  virtual webrtc::EventTypeWrapper Wait(unsigned long max_time) {
+    return webrtc::kEventTimeout;
+  }
+
+  virtual bool StartTimer(bool periodic, unsigned long time) { return true; }
+
+  virtual bool StopTimer() { return true; }
+};
+
+class NullEventFactory : public webrtc::EventFactory {
+ public:
+  virtual ~NullEventFactory() {}
+
+  virtual webrtc::EventWrapper* CreateEvent() {
+    return new NullEvent;
+  }
+};
 
 // Codec type conversion
 webrtc::RTPVideoCodecTypes
diff --git a/webrtc/modules/video_coding/main/test/tester_main.cc b/webrtc/modules/video_coding/main/test/tester_main.cc
index 6188cba..c928a80 100644
--- a/webrtc/modules/video_coding/main/test/tester_main.cc
+++ b/webrtc/modules/video_coding/main/test/tester_main.cc
@@ -8,24 +8,20 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "google/gflags.h"
-
-#include "receiver_tests.h"
-#include "normal_test.h"
-#include "codec_database_test.h"
-#include "generic_codec_test.h"
-#include "../source/event.h"
-#include "media_opt_test.h"
-#include "quality_modes_test.h"
-#include "test_util.h"
-#include "webrtc/test/testsupport/fileutils.h"
 
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef _WIN32
-//#include "vld.h"
-#endif
+#include "google/gflags.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/test/receiver_tests.h"
+#include "webrtc/modules/video_coding/main/test/normal_test.h"
+#include "webrtc/modules/video_coding/main/test/codec_database_test.h"
+#include "webrtc/modules/video_coding/main/test/generic_codec_test.h"
+#include "webrtc/modules/video_coding/main/test/media_opt_test.h"
+#include "webrtc/modules/video_coding/main/test/quality_modes_test.h"
+#include "webrtc/modules/video_coding/main/test/test_util.h"
+#include "webrtc/test/testsupport/fileutils.h"
 
 DEFINE_string(codec, "VP8", "Codec to use (VP8 or I420).");
 DEFINE_int32(width, 352, "Width in pixels of the frames in the input file.");
diff --git a/webrtc/modules/video_coding/main/test/video_rtp_play.cc b/webrtc/modules/video_coding/main/test/video_rtp_play.cc
index cc91949..819edc5 100644
--- a/webrtc/modules/video_coding/main/test/video_rtp_play.cc
+++ b/webrtc/modules/video_coding/main/test/video_rtp_play.cc
@@ -8,21 +8,20 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "common_video/libyuv/include/webrtc_libyuv.h"
-#include "receiver_tests.h"
-#include "video_coding.h"
-#include "rtp_rtcp.h"
-#include "trace.h"
-#include "../source/event.h"
-#include "../source/internal_defines.h"
-#include "test_macros.h"
-#include "rtp_player.h"
-#include "webrtc/system_wrappers/interface/clock.h"
-
 #include <stdio.h>
 #include <string.h>
 #include <sstream>
 
+#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
+#include "webrtc/modules/video_coding/main/interface/video_coding.h"
+#include "webrtc/modules/video_coding/main/source/internal_defines.h"
+#include "webrtc/modules/video_coding/main/test/receiver_tests.h"
+#include "webrtc/modules/video_coding/main/test/test_macros.h"
+#include "webrtc/modules/video_coding/main/test/rtp_player.h"
+#include "webrtc/system_wrappers/interface/clock.h"
+#include "webrtc/system_wrappers/interface/trace.h"
+
 using namespace webrtc;
 
 WebRtc_Word32
@@ -112,12 +111,7 @@
 
 int RtpPlay(CmdArgs& args)
 {
-    // Make sure this test isn't executed without simulated events.
-#if !defined(EVENT_DEBUG)
-    return -1;
-#endif
     // BEGIN Settings
-
     bool protectionEnabled = true;
     VCMVideoProtection protectionMethod = kProtectionNack;
     WebRtc_UWord32 rttMS = 0;
@@ -131,7 +125,9 @@
         outFile = test::OutputPath() + "RtpPlay_decoded.yuv";
     FrameReceiveCallback receiveCallback(outFile);
     SimulatedClock clock(0);
-    VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
+    NullEventFactory event_factory;
+    VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock,
+                                                       &event_factory);
     RtpDataCallback dataCallback(vcm);
     RTPPlayer rtpStream(args.inputFile.c_str(), &dataCallback, &clock);
 
diff --git a/webrtc/modules/video_coding/main/test/video_rtp_play_mt.cc b/webrtc/modules/video_coding/main/test/video_rtp_play_mt.cc
index 7e4e065..5e42f03 100644
--- a/webrtc/modules/video_coding/main/test/video_rtp_play_mt.cc
+++ b/webrtc/modules/video_coding/main/test/video_rtp_play_mt.cc
@@ -12,11 +12,11 @@
 
 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
 #include "webrtc/modules/video_coding/main/interface/video_coding.h"
-#include "webrtc/modules/video_coding/main/source/event.h"
 #include "webrtc/modules/video_coding/main/test/receiver_tests.h"
 #include "webrtc/modules/video_coding/main/test/rtp_player.h"
 #include "webrtc/modules/video_coding/main/test/test_macros.h"
 #include "webrtc/system_wrappers/interface/clock.h"
+#include "webrtc/system_wrappers/interface/event_wrapper.h"
 #include "webrtc/system_wrappers/interface/thread_wrapper.h"
 #include "webrtc/system_wrappers/interface/trace.h"
 
@@ -61,13 +61,7 @@
 
 int RtpPlayMT(CmdArgs& args, int releaseTestNo, webrtc::VideoCodecType releaseTestVideoType)
 {
-    // Don't run these tests with debug events.
-#if defined(EVENT_DEBUG)
-    return -1;
-#endif
-
     // BEGIN Settings
-
     bool protectionEnabled = true;
     VCMVideoProtection protection = kProtectionDualDecoder;
     WebRtc_UWord8 rttMS = 50;
@@ -83,8 +77,7 @@
                 (protection == kProtectionDualDecoder ||
                 protection == kProtectionNack ||
                 kProtectionNackFEC));
-    Clock* clock = Clock::GetRealTimeClock();
-    VideoCodingModule* vcm = VideoCodingModule::Create(1, clock);
+    VideoCodingModule* vcm = VideoCodingModule::Create(1);
     RtpDataCallback dataCallback(vcm);
     std::string rtpFilename;
     rtpFilename = args.inputFile;
@@ -137,7 +130,8 @@
         }
         printf("Watch %s to verify that the output is reasonable\n", outFilename.c_str());
     }
-    RTPPlayer rtpStream(rtpFilename.c_str(), &dataCallback, clock);
+    RTPPlayer rtpStream(rtpFilename.c_str(), &dataCallback,
+                        Clock::GetRealTimeClock());
     PayloadTypeList payloadTypes;
     payloadTypes.push_front(new PayloadCodecTuple(VCM_VP8_PAYLOAD_TYPE, "VP8",
                                                   kVideoCodecVP8));