filmstro_ffmpeg
 All Classes Files Functions Friends Macros
filmstro_ffmpeg_FFmpegVideoComponent.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3  Copyright (c) 2017, Filmstro Ltd. - Daniel Walz
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without modification,
7  are permitted provided that the following conditions are met:
8  1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10  2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13  3. Neither the name of the copyright holder nor the names of its contributors
14  may be used to endorse or promote products derived from this software without
15  specific prior written permission.
16 
17  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26  OF THE POSSIBILITY OF SUCH DAMAGE.
27  ==============================================================================
28  \class FFmpegVideoComponent
29  \file filmstro_ffmpeg_FFmpegVideoComponent.h
30  \brief A component to view a video decoded by FFmpeg
31 
32  \author Daniel Walz @ filmstro.com
33  \date August 31st 2016
34 
35  \description This component will display the movie in the gui.
36  It has a FFmpegVideoSource, which will send changeMessages when
37  a new Video frame arrived in the stream to be displayed.
38 
39  ==============================================================================
40  */
41 
42 
43 #ifndef FILMSTRO_FFMPEG_FFMPEGVIDEOCOMPONENT_H_INCLUDED
44 #define FILMSTRO_FFMPEG_FFMPEGVIDEOCOMPONENT_H_INCLUDED
45 
46 class FFmpegVideoSource;
47 
52 class FFmpegVideoComponent : public juce::Component,
53  public juce::Timer,
54  public FFmpegVideoListener
55 {
56 public:
58  virtual ~FFmpegVideoComponent ();
59 
61  void resized () override;
62 
63  void paint (juce::Graphics& g) override;
64 
66  void timerCallback () override;
67 
69  void displayNewFrame (const AVFrame*) override;
70 
72  void videoSizeChanged (const int width, const int height, const AVPixelFormat) override;
73 
75  void setVideoReader (FFmpegVideoReader* source);
76 
79 
80 private:
82  juce::String formatTimeCode (const double tc);
83 
85  juce::WeakReference<FFmpegVideoReader> videoSource;
86 
87  const AVFrame* currentFrame;
88 
89  juce::Image frameBuffer;
90 
91  FFmpegVideoScaler videoScaler;
92 
93  bool dirty;
94 
95  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FFmpegVideoComponent)
96 };
97 
98 #endif /* FILMSTRO_FFMPEG_FFMPEGVIDEOCOMPONENT_H_INCLUDED */
99 
void setVideoReader(FFmpegVideoReader *source)
Set a video source for the component.
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:129
void resized() override
Callback when the component is resized.
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:66
void displayNewFrame(const AVFrame *) override
callback from FFmpegVideoReader to display a new frame
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:113
FFmpegVideoComponent()
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:54
Reads a ffmpeg video file
Definition: filmstro_ffmpeg_FFmpegVideoReader.h:55
void paint(juce::Graphics &g) override
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:98
void videoSizeChanged(const int width, const int height, const AVPixelFormat) override
This is called whenever the size changed, so a framebuffer can be resized.
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:123
virtual ~FFmpegVideoComponent()
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:62
FFmpegVideoReader * getVideoReader() const
Get the video source for the component.
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:142
Definition: filmstro_ffmpeg_FFmpegVideoListener.h:44
void timerCallback() override
triggers repaint on message thread
Definition: filmstro_ffmpeg_FFmpegVideoComponent.cpp:90
Definition: filmstro_ffmpeg_FFmpegVideoScaler.h:44
Component to display a video read by FFmpegVideoReader
Definition: filmstro_ffmpeg_FFmpegVideoComponent.h:52