blob: 5457d02d5318a3fb24a3d88eb7b9b68c32b5d5f9 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
mflodman@webrtc.orge06ca3c2012-06-29 13:20:14 +000011#ifndef WEBRTC_VIDEO_ENGINE_VIE_FILE_IMPL_H_
12#define WEBRTC_VIDEO_ENGINE_VIE_FILE_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000014#include "system_wrappers/interface/scoped_ptr.h"
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +000015#include "typedefs.h" // NOLINT
mflodman@webrtc.orga4863db2011-12-22 08:51:52 +000016#include "video_engine/include/vie_file.h"
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000017#include "video_engine/vie_defines.h"
18#include "video_engine/vie_frame_provider_base.h"
19#include "video_engine/vie_ref_count.h"
20#include "video_engine/vie_shared_data.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000022namespace webrtc {
23
niklase@google.com470e71d2011-07-07 08:21:25 +000024class ConditionVariableWrapper;
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000025class CriticalSectionWrapper;
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000026class ViESharedData;
niklase@google.com470e71d2011-07-07 08:21:25 +000027
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000028class ViECaptureSnapshot : public ViEFrameCallback {
29 public:
30 ViECaptureSnapshot();
31 ~ViECaptureSnapshot();
niklase@google.com470e71d2011-07-07 08:21:25 +000032
mikhal@webrtc.org9fedff72012-10-24 18:33:04 +000033 bool GetSnapshot(unsigned int max_wait_time, I420VideoFrame* video_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000035 // Implements ViEFrameCallback.
mflodman@webrtc.org8baed512012-06-21 12:11:50 +000036 virtual void DeliverFrame(int id,
mikhal@webrtc.org9fedff72012-10-24 18:33:04 +000037 I420VideoFrame* video_frame,
mflodman@webrtc.org8baed512012-06-21 12:11:50 +000038 int num_csrcs = 0,
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000039 const uint32_t CSRC[kRtpCsrcSize] = NULL);
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000040 virtual void DelayChanged(int id, int frame_delay) {}
mflodman@webrtc.org8baed512012-06-21 12:11:50 +000041 virtual int GetPreferedFrameSettings(int* width,
42 int* height,
43 int* frame_rate) {
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000044 return -1;
45 }
46 virtual void ProviderDestroyed(int id) {}
niklase@google.com470e71d2011-07-07 08:21:25 +000047
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000048 private:
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000049 scoped_ptr<CriticalSectionWrapper> crit_;
mflodman@webrtc.org2877bdc2012-01-17 12:18:16 +000050 scoped_ptr<ConditionVariableWrapper> condition_varaible_;
mikhal@webrtc.org9fedff72012-10-24 18:33:04 +000051 I420VideoFrame* video_frame_;
niklase@google.com470e71d2011-07-07 08:21:25 +000052};
53
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000054class ViEFileImpl
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000055 : public ViEFile,
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000056 public ViERefCount {
57 public:
58 // Implements ViEFile.
59 virtual int Release();
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +000060 virtual int StartPlayFile(const char* file_nameUTF8, int& file_id, // NOLINT
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000061 const bool loop = false,
62 const FileFormats file_format = kFileFormatAviFile);
63 virtual int StopPlayFile(const int file_id);
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +000064 virtual int RegisterObserver(int file_id,
65 ViEFileObserver& observer); // NOLINT
66 virtual int DeregisterObserver(int file_id,
67 ViEFileObserver& observer); // NOLINT
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +000068 virtual int SendFileOnChannel(const int file_id, const int video_channel);
69 virtual int StopSendFileOnChannel(const int video_channel);
70 virtual int StartPlayFileAsMicrophone(const int file_id,
71 const int audio_channel,
72 bool mix_microphone = false,
73 float volume_scaling = 1);
74 virtual int StopPlayFileAsMicrophone(const int file_id,
75 const int audio_channel);
76 virtual int StartPlayAudioLocally(const int file_id, const int audio_channel,
77 float volume_scaling = 1);
78 virtual int StopPlayAudioLocally(const int file_id, const int audio_channel);
79 virtual int StartRecordOutgoingVideo(
80 const int video_channel,
81 const char* file_nameUTF8,
82 AudioSource audio_source,
83 const CodecInst& audio_codec,
84 const VideoCodec& video_codec,
85 const FileFormats file_format = kFileFormatAviFile);
86 virtual int StartRecordIncomingVideo(
87 const int video_channel,
88 const char* file_nameUTF8,
89 AudioSource audio_source,
90 const CodecInst& audio_codec,
91 const VideoCodec& video_codec,
92 const FileFormats file_format = kFileFormatAviFile);
93 virtual int StopRecordOutgoingVideo(const int video_channel);
94 virtual int StopRecordIncomingVideo(const int video_channel);
95 virtual int GetFileInformation(
96 const char* file_name,
97 VideoCodec& video_codec,
98 CodecInst& audio_codec,
99 const FileFormats file_format = kFileFormatAviFile);
100 virtual int GetRenderSnapshot(const int video_channel,
101 const char* file_nameUTF8);
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000102 virtual int GetRenderSnapshot(const int video_channel,
103 ViEPicture& picture); // NOLINT
104 virtual int FreePicture(ViEPicture& picture); // NOLINT
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +0000105 virtual int GetCaptureDeviceSnapshot(const int capture_id,
106 const char* file_nameUTF8);
107 virtual int GetCaptureDeviceSnapshot(const int capture_id,
108 ViEPicture& picture);
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +0000109 virtual int SetRenderStartImage(const int video_channel,
110 const char* file_nameUTF8);
111 virtual int SetRenderStartImage(const int video_channel,
112 const ViEPicture& picture);
113 virtual int SetRenderTimeoutImage(const int video_channel,
114 const char* file_nameUTF8,
115 const unsigned int timeout_ms);
116 virtual int SetRenderTimeoutImage(const int video_channel,
117 const ViEPicture& picture,
118 const unsigned int timeout_ms);
mikhal@webrtc.orge41bbdf2012-08-28 16:15:16 +0000119 virtual int StartDebugRecording(int video_channel,
120 const char* file_name_utf8);
121 virtual int StopDebugRecording(int video_channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000122
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +0000123 protected:
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000124 explicit ViEFileImpl(ViESharedData* shared_data);
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +0000125 virtual ~ViEFileImpl();
niklase@google.com470e71d2011-07-07 08:21:25 +0000126
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +0000127 private:
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000128 int32_t GetNextCapturedFrame(int32_t capture_id, I420VideoFrame* video_frame);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000129
130 ViESharedData* shared_data_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000131};
mflodman@webrtc.org813b4ef2011-12-20 10:39:30 +0000132
133} // namespace webrtc
134
mflodman@webrtc.orge06ca3c2012-06-29 13:20:14 +0000135#endif // WEBRTC_VIDEO_ENGINE_VIE_FILE_IMPL_H_