Delete MediaFile support for unused fileformats.

There's no downstream use of kFileFormatCompressedFile,
kFileFormatPreencodedFile or kFileFormatPcm48kHzFile.

Bug: None
Change-Id: I66cbe71151472d6348515a2432a280acbc3bbf85
Reviewed-on: https://webrtc-review.googlesource.com/28040
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21078}
diff --git a/common_types.h b/common_types.h
index 9e4427b..f15fb9e 100644
--- a/common_types.h
+++ b/common_types.h
@@ -78,14 +78,12 @@
   virtual bool Write(const void* buf, size_t len) = 0;
 };
 
+// For the deprecated MediaFile module.
 enum FileFormats {
   kFileFormatWavFile = 1,
-  kFileFormatCompressedFile = 2,
-  kFileFormatPreencodedFile = 4,
   kFileFormatPcm16kHzFile = 7,
   kFileFormatPcm8kHzFile = 8,
   kFileFormatPcm32kHzFile = 9,
-  kFileFormatPcm48kHzFile = 10
 };
 
 enum FrameType {
diff --git a/modules/media_file/media_file_impl.cc b/modules/media_file/media_file_impl.cc
index f3ec5b9..2827139 100644
--- a/modules/media_file/media_file_impl.cc
+++ b/modules/media_file/media_file_impl.cc
@@ -93,29 +93,16 @@
     }
 
     switch (_fileFormat) {
-      case kFileFormatPcm48kHzFile:
       case kFileFormatPcm32kHzFile:
       case kFileFormatPcm16kHzFile:
       case kFileFormatPcm8kHzFile:
         bytesRead = _ptrFileUtilityObj->ReadPCMData(*_ptrInStream, buffer,
                                                     bufferLengthInBytes);
         break;
-      case kFileFormatCompressedFile:
-        bytesRead = _ptrFileUtilityObj->ReadCompressedData(
-            *_ptrInStream, buffer, bufferLengthInBytes);
-        break;
       case kFileFormatWavFile:
         bytesRead = _ptrFileUtilityObj->ReadWavDataAsMono(*_ptrInStream, buffer,
                                                           bufferLengthInBytes);
         break;
-      case kFileFormatPreencodedFile:
-        bytesRead = _ptrFileUtilityObj->ReadPreEncodedData(
-            *_ptrInStream, buffer, bufferLengthInBytes);
-        if (bytesRead > 0) {
-          dataLengthInBytes = static_cast<size_t>(bytesRead);
-          return 0;
-        }
-        break;
       default: {
         RTC_LOG(LS_ERROR) << "Invalid file format: " << _fileFormat;
         assert(false);
@@ -220,20 +207,9 @@
       _fileFormat = kFileFormatWavFile;
       break;
     }
-    case kFileFormatCompressedFile: {
-      if (_ptrFileUtilityObj->InitCompressedReading(stream, startPointMs,
-                                                    stopPointMs) == -1) {
-        RTC_LOG(LS_ERROR) << "Not a valid Compressed file!";
-        StopPlaying();
-        return -1;
-      }
-      _fileFormat = kFileFormatCompressedFile;
-      break;
-    }
     case kFileFormatPcm8kHzFile:
     case kFileFormatPcm16kHzFile:
-    case kFileFormatPcm32kHzFile:
-    case kFileFormatPcm48kHzFile: {
+    case kFileFormatPcm32kHzFile: {
       // ValidFileFormat() called in the beginneing of this function
       // prevents codecInst from being NULL here.
       assert(codecInst != NULL);
@@ -248,19 +224,6 @@
       _fileFormat = format;
       break;
     }
-    case kFileFormatPreencodedFile: {
-      // ValidFileFormat() called in the beginneing of this function
-      // prevents codecInst from being NULL here.
-      assert(codecInst != NULL);
-      if (_ptrFileUtilityObj->InitPreEncodedReading(stream, *codecInst) == -1) {
-        RTC_LOG(LS_ERROR) << "Not a valid PreEncoded file!";
-        StopPlaying();
-        return -1;
-      }
-
-      _fileFormat = kFileFormatPreencodedFile;
-      break;
-    }
     default: {
       RTC_LOG(LS_ERROR) << "Invalid file format: " << format;
       assert(false);
@@ -348,10 +311,8 @@
 bool MediaFileImpl::ValidFileFormat(const FileFormats format,
                                     const CodecInst* codecInst) {
   if (codecInst == NULL) {
-    if (format == kFileFormatPreencodedFile ||
-        format == kFileFormatPcm8kHzFile || format == kFileFormatPcm16kHzFile ||
-        format == kFileFormatPcm32kHzFile ||
-        format == kFileFormatPcm48kHzFile) {
+    if (format == kFileFormatPcm8kHzFile || format == kFileFormatPcm16kHzFile ||
+        format == kFileFormatPcm32kHzFile) {
       RTC_LOG(LS_ERROR) << "Codec info required for file format specified!";
       return false;
     }
diff --git a/modules/media_file/media_file_utility.cc b/modules/media_file/media_file_utility.cc
index 50aee44..d8cc6d9 100644
--- a/modules/media_file/media_file_utility.cc
+++ b/modules/media_file/media_file_utility.cc
@@ -439,199 +439,6 @@
   return bytesRead;
 }
 
-int32_t ModuleFileUtility::InitPreEncodedReading(InStream& in,
-                                                 const CodecInst& cinst) {
-  uint8_t preEncodedID;
-  in.Read(&preEncodedID, 1);
-
-  MediaFileUtility_CodecType codecType =
-      (MediaFileUtility_CodecType)preEncodedID;
-
-  if (set_codec_info(cinst) != 0) {
-    RTC_LOG(LS_ERROR) << "Pre-encoded file send codec mismatch!";
-    return -1;
-  }
-  if (codecType != _codecId) {
-    RTC_LOG(LS_ERROR) << "Pre-encoded file format codec mismatch!";
-    return -1;
-  }
-  memcpy(&codec_info_, &cinst, sizeof(CodecInst));
-  _reading = true;
-  return 0;
-}
-
-int32_t ModuleFileUtility::ReadPreEncodedData(InStream& in,
-                                              int8_t* outData,
-                                              const size_t bufferSize) {
-  RTC_LOG(LS_VERBOSE) << "ModuleFileUtility::ReadPreEncodedData(in= " << &in
-                      << ", outData= " << static_cast<void*>(outData)
-                      << ", bufferSize= " << bufferSize << ")";
-
-  if (outData == NULL) {
-    RTC_LOG(LS_ERROR) << "output buffer NULL";
-  }
-
-  size_t frameLen;
-  uint8_t buf[64];
-  // Each frame has a two byte header containing the frame length.
-  int32_t res = in.Read(buf, 2);
-  if (res != 2) {
-    if (!in.Rewind()) {
-      // The first byte is the codec identifier.
-      in.Read(buf, 1);
-      res = in.Read(buf, 2);
-    } else {
-      return -1;
-    }
-  }
-  frameLen = buf[0] + buf[1] * 256;
-  if (bufferSize < frameLen) {
-    RTC_LOG(LS_ERROR) << "buffer not large enough to read " << frameLen
-                      << " bytes of pre-encoded data!";
-    return -1;
-  }
-  return in.Read(outData, frameLen);
-}
-
-int32_t ModuleFileUtility::InitCompressedReading(InStream& in,
-                                                 const uint32_t start,
-                                                 const uint32_t stop) {
-  RTC_LOG(LS_VERBOSE) << "ModuleFileUtility::InitCompressedReading(in= " << &in
-                      << ", start= " << start << ", stop= " << stop << ")";
-
-#if defined(WEBRTC_CODEC_ILBC)
-  int16_t read_len = 0;
-#endif
-  _codecId = kCodecNoCodec;
-  _playoutPositionMs = 0;
-  _reading = false;
-
-  _startPointInMs = start;
-  _stopPointInMs = stop;
-
-  // Read the codec name
-  int32_t cnt = 0;
-  char buf[64];
-  do {
-    in.Read(&buf[cnt++], 1);
-  } while ((buf[cnt - 1] != '\n') && (64 > cnt));
-
-  if (cnt == 64) {
-    return -1;
-  }
-  buf[cnt] = 0;
-
-#ifdef WEBRTC_CODEC_ILBC
-  if (!strcmp("#!iLBC20\n", buf)) {
-    codec_info_.pltype = 102;
-    strcpy(codec_info_.plname, "ilbc");
-    codec_info_.plfreq = 8000;
-    codec_info_.pacsize = 160;
-    codec_info_.channels = 1;
-    codec_info_.rate = 13300;
-    _codecId = kCodecIlbc20Ms;
-
-    if (_startPointInMs > 0) {
-      while (_playoutPositionMs <= _startPointInMs) {
-        read_len = in.Read(buf, 38);
-        if (read_len != 38) {
-          return -1;
-        }
-        _playoutPositionMs += 20;
-      }
-    }
-  }
-
-  if (!strcmp("#!iLBC30\n", buf)) {
-    codec_info_.pltype = 102;
-    strcpy(codec_info_.plname, "ilbc");
-    codec_info_.plfreq = 8000;
-    codec_info_.pacsize = 240;
-    codec_info_.channels = 1;
-    codec_info_.rate = 13300;
-    _codecId = kCodecIlbc30Ms;
-
-    if (_startPointInMs > 0) {
-      while (_playoutPositionMs <= _startPointInMs) {
-        read_len = in.Read(buf, 50);
-        if (read_len != 50) {
-          return -1;
-        }
-        _playoutPositionMs += 20;
-      }
-    }
-  }
-#endif
-  if (_codecId == kCodecNoCodec) {
-    return -1;
-  }
-  _reading = true;
-  return 0;
-}
-
-int32_t ModuleFileUtility::ReadCompressedData(InStream& in,
-                                              int8_t* outData,
-                                              size_t bufferSize) {
-  RTC_LOG(LS_VERBOSE) << "ModuleFileUtility::ReadCompressedData(in=" << &in
-                      << ", outData=" << static_cast<void*>(outData)
-                      << ", bytes=" << bufferSize << ")";
-
-  int bytesRead = 0;
-
-  if (!_reading) {
-    RTC_LOG(LS_ERROR) << "not currently reading!";
-    return -1;
-  }
-
-#ifdef WEBRTC_CODEC_ILBC
-  if ((_codecId == kCodecIlbc20Ms) || (_codecId == kCodecIlbc30Ms)) {
-    size_t byteSize = 0;
-    if (_codecId == kCodecIlbc30Ms) {
-      byteSize = 50;
-    }
-    if (_codecId == kCodecIlbc20Ms) {
-      byteSize = 38;
-    }
-    if (bufferSize < byteSize) {
-      RTC_LOG(LS_ERROR)
-          << "output buffer is too short to read ILBC compressed data.";
-      assert(false);
-      return -1;
-    }
-
-    bytesRead = in.Read(outData, byteSize);
-    if (bytesRead != static_cast<int>(byteSize)) {
-      if (!in.Rewind()) {
-        InitCompressedReading(in, _startPointInMs, _stopPointInMs);
-        bytesRead = in.Read(outData, byteSize);
-        if (bytesRead != static_cast<int>(byteSize)) {
-          _reading = false;
-          return -1;
-        }
-      } else {
-        _reading = false;
-        return -1;
-      }
-    }
-  }
-#endif
-  if (bytesRead == 0) {
-    RTC_LOG(LS_ERROR)
-        << "ReadCompressedData() no bytes read, codec not supported";
-    return -1;
-  }
-
-  _playoutPositionMs += 20;
-  if ((_stopPointInMs > 0) && (_playoutPositionMs >= _stopPointInMs)) {
-    if (!in.Rewind()) {
-      InitCompressedReading(in, _startPointInMs, _stopPointInMs);
-    } else {
-      _reading = false;
-    }
-  }
-  return bytesRead;
-}
-
 int32_t ModuleFileUtility::InitPCMReading(InStream& pcm,
                                           const uint32_t start,
                                           const uint32_t stop,
diff --git a/modules/media_file/media_file_utility.h b/modules/media_file/media_file_utility.h
index 16cfa12..79436d7 100644
--- a/modules/media_file/media_file_utility.h
+++ b/modules/media_file/media_file_utility.h
@@ -60,32 +60,6 @@
     int32_t ReadPCMData(InStream& stream, int8_t* audioBuffer,
                         const size_t dataLengthInBytes);
 
-    // Prepare for playing audio from stream.
-    // startPointMs and stopPointMs, unless zero, specify what part of the file
-    // should be read. From startPointMs ms to stopPointMs ms.
-    int32_t InitCompressedReading(InStream& stream,
-                                  const uint32_t startPointMs = 0,
-                                  const uint32_t stopPointMs = 0);
-
-    // Put 10-60ms of audio data from stream into the audioBuffer depending on
-    // codec frame size. dataLengthInBytes indicates the size of audioBuffer.
-    // The return value is the number of bytes written to audioBuffer.
-    int32_t ReadCompressedData(InStream& stream,
-                               int8_t* audioBuffer,
-                               const size_t dataLengthInBytes);
-
-    // Prepare for playing audio from stream.
-    // codecInst specifies the encoding of the audio data.
-    int32_t InitPreEncodedReading(InStream& stream,
-                                  const CodecInst& codecInst);
-
-    // Put 10-60ms of audio data from stream into the audioBuffer depending on
-    // codec frame size. dataLengthInBytes indicates the size of audioBuffer.
-    // The return value is the number of bytes written to audioBuffer.
-    int32_t ReadPreEncodedData(InStream& stream,
-                               int8_t* audioBuffer,
-                               const size_t dataLengthInBytes);
-
     // Return the number of ms that have been played so far.
     uint32_t PlayoutPositionMs();