Home | History | Annotate | Download | only in interface
      1 /*
      2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_MODULES_UTILITY_INTERFACE_FILE_RECORDER_H_
     12 #define WEBRTC_MODULES_UTILITY_INTERFACE_FILE_RECORDER_H_
     13 
     14 #include "webrtc/common_types.h"
     15 #include "webrtc/common_video/interface/i420_video_frame.h"
     16 #include "webrtc/engine_configurations.h"
     17 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
     18 #include "webrtc/modules/interface/module_common_types.h"
     19 #include "webrtc/modules/media_file/interface/media_file_defines.h"
     20 #include "webrtc/system_wrappers/interface/tick_util.h"
     21 #include "webrtc/typedefs.h"
     22 
     23 namespace webrtc {
     24 
     25 class FileRecorder
     26 {
     27 public:
     28 
     29     // Note: will return NULL for video file formats (e.g. AVI) if the flag
     30     //       WEBRTC_MODULE_UTILITY_VIDEO is not defined.
     31     static FileRecorder* CreateFileRecorder(const uint32_t instanceID,
     32                                             const FileFormats fileFormat);
     33 
     34     static void DestroyFileRecorder(FileRecorder* recorder);
     35 
     36     virtual int32_t RegisterModuleFileCallback(
     37         FileCallback* callback) = 0;
     38 
     39     virtual FileFormats RecordingFileFormat() const = 0;
     40 
     41     virtual int32_t StartRecordingAudioFile(
     42         const char* fileName,
     43         const CodecInst& codecInst,
     44         uint32_t notification,
     45         ACMAMRPackingFormat amrFormat = AMRFileStorage) = 0;
     46 
     47     virtual int32_t StartRecordingAudioFile(
     48         OutStream& destStream,
     49         const CodecInst& codecInst,
     50         uint32_t notification,
     51         ACMAMRPackingFormat amrFormat = AMRFileStorage) = 0;
     52 
     53     // Stop recording.
     54     // Note: this API is for both audio and video.
     55     virtual int32_t StopRecording() = 0;
     56 
     57     // Return true if recording.
     58     // Note: this API is for both audio and video.
     59     virtual bool IsRecording() const = 0;
     60 
     61     virtual int32_t codec_info(CodecInst& codecInst) const = 0;
     62 
     63     // Write frame to file. Frame should contain 10ms of un-ecoded audio data.
     64     virtual int32_t RecordAudioToFile(
     65         const AudioFrame& frame,
     66         const TickTime* playoutTS = NULL) = 0;
     67 
     68     // Open/create the file specified by fileName for writing audio/video data
     69     // (relative path is allowed). audioCodecInst specifies the encoding of the
     70     // audio data. videoCodecInst specifies the encoding of the video data.
     71     // Only video data will be recorded if videoOnly is true. amrFormat
     72     // specifies the amr/amrwb storage format.
     73     // Note: the file format is AVI.
     74     virtual int32_t StartRecordingVideoFile(
     75         const char* fileName,
     76         const CodecInst& audioCodecInst,
     77         const VideoCodec& videoCodecInst,
     78         ACMAMRPackingFormat amrFormat = AMRFileStorage,
     79         bool videoOnly = false) = 0;
     80 
     81     // Record the video frame in videoFrame to AVI file.
     82     virtual int32_t RecordVideoToFile(
     83         const I420VideoFrame& videoFrame) = 0;
     84 
     85 protected:
     86     virtual ~FileRecorder() {}
     87 
     88 };
     89 }  // namespace webrtc
     90 #endif // WEBRTC_MODULES_UTILITY_INTERFACE_FILE_RECORDER_H_
     91