2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_TO_FILE_RENDERER_H_
12 #define WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_TO_FILE_RENDERER_H_
20 #include "webrtc/system_wrappers/interface/constructor_magic.h"
21 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
22 #include "webrtc/video_engine/include/vie_render.h"
25 class CriticalSectionWrapper;
28 }; // namespace webrtc
34 class ViEToFileRenderer: public webrtc::ExternalRenderer {
37 virtual ~ViEToFileRenderer();
39 // Returns false if we fail opening the output filename for writing.
40 bool PrepareForRendering(const std::string& output_path,
41 const std::string& output_filename);
43 // Closes the output file.
46 // Deletes the closed output file from the file system. This is one option
47 // after calling StopRendering, the other being KeepOutputFile. This file
48 // renderer will forget about the file after this call and can be used again.
49 bool DeleteOutputFile();
51 // Renames the closed output file to its previous name with the provided
52 // prefix prepended. This file renderer will forget about the file after this
53 // call and can be used again.
54 bool SaveOutputFile(const std::string& prefix);
56 // Implementation of ExternalRenderer:
57 int FrameSizeChange(unsigned int width, unsigned int height,
58 unsigned int number_of_streams) OVERRIDE;
60 int DeliverFrame(unsigned char* buffer,
65 void* handle) OVERRIDE;
67 bool IsTextureSupported() OVERRIDE;
69 const std::string GetFullOutputPath() const;
72 typedef std::list<test::Frame*> FrameQueue;
74 static bool RunRenderThread(void* obj);
75 void ForgetOutputFile();
76 bool ProcessRenderQueue();
79 std::string output_path_;
80 std::string output_filename_;
81 webrtc::scoped_ptr<webrtc::ThreadWrapper> thread_;
82 webrtc::scoped_ptr<webrtc::CriticalSectionWrapper> frame_queue_cs_;
83 webrtc::scoped_ptr<webrtc::EventWrapper> frame_render_event_;
84 FrameQueue render_queue_;
85 FrameQueue free_frame_queue_;
88 #endif // WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_TO_FILE_RENDERER_H_