No need to check for an empty queue.  The == queue_.end() check will handle it.  Also add a debug message if we nuke samples.
Bit of cleanup: remove unused variables, make varaibles that don't need to be class members local to a function.
Do not insert duplicate samples in the queue.
Cleanup in MediaDefinitions.h; scrub formatting, remove extraneous semicolons
Bit of reworking; going to use context_->filename instead of tracking url separately.  Remove oformat_ in favor of context->oformat.  Trying to consolidate stuff, the additional variables make code hard to follow.
More cleanup.  Less variables to track because we just leverage our context_ instead of duplicating pointers.  Also relocate some initialization code to the constructor, where it fits a bit better.
Ability to record both PCM and OPUS in external output.  Sniffs the incoming stream to correctly configure libav.

Also a bunch of general cleanup changes and consolidation.  Shutdown our worker thread before we nuke libav, and change the ordering of closing the file to match libav documentation.
Fix a bug in the RtpPacketQueue.  There is no reason to push a sample that has a sequence number less than or equal to something we've already popped--it's simply too late to be useful to the receiving client.
Timestamp using the incoming RTP timestamps instead of restamping.  This is going to allow a longer packet reorder time window without affecting AV sync.
Get rid of audioCodec_ and videoCodec_; we don't need to hold on to these in the member class.  instead use video_stream_ and audio_stream_
More cleanup; there's no good reason to estimate bitrate before starting file writing.  A good guess will suffice here, and having proper timestamps in the output file is more important.
No need to track whether or not we wrote the header; checking the context is good enough.
Make timestamping more accurate, have both audio and video streams initialize our context, and a few other tweaks.
Handle rtp timestamp wrap
Relocate locking to the object that owns the queue.  This way, we block push/pop threads for a minimal amount of time, so writing out the file is less likely to interfere with network capture.

Also a bit of cleanup.
Clean up some logging and remove a boolean I didn't need in the Rtp Packet Queue.
Found the source of my corruption.  The && between the queue depth check needed to be an ||.  Also, to prevent queues from growing, always write out enough samples to bring it back down to the queue depth specified.

Also some cleanup.
Make the packet queue in charge of managing its own reorder depth.  Caller can specify the depth and max (or optionally use defaults) and the queue will handle letting people know when data's actually ready.
Unit tests for erizo using Boost.Test.  Currently there's a few basic tests for RtpPacketQueue to validate its behavior, but I need to add more.
Beef up the basic test a bit to make sure that no sample was actually popped