2007-01-21 07:30:19 +01:00
|
|
|
// Copyright (c) 2005-2007, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
#include <libaegisub/signal.h>
|
|
|
|
#include <libaegisub/vfr.h>
|
|
|
|
|
|
|
|
#include <chrono>
|
2012-12-17 17:27:11 +01:00
|
|
|
#include <set>
|
2009-09-11 04:36:34 +02:00
|
|
|
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/timer.h>
|
2007-01-21 07:30:19 +01:00
|
|
|
|
2014-03-07 19:58:51 +01:00
|
|
|
class AssDialogue;
|
2014-05-22 01:23:28 +02:00
|
|
|
class AsyncVideoProvider;
|
2014-03-07 19:58:51 +01:00
|
|
|
struct SubtitlesProviderErrorEvent;
|
2013-01-04 16:01:50 +01:00
|
|
|
struct VideoProviderErrorEvent;
|
2022-05-07 16:13:50 +02:00
|
|
|
struct VideoFrame;
|
2010-06-08 08:09:13 +02:00
|
|
|
|
|
|
|
namespace agi {
|
2011-01-16 08:17:08 +01:00
|
|
|
struct Context;
|
2010-06-08 08:09:13 +02:00
|
|
|
class OptionValue;
|
|
|
|
}
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2013-01-20 22:05:24 +01:00
|
|
|
enum class AspectRatio {
|
|
|
|
Default = 0,
|
|
|
|
Fullscreen,
|
|
|
|
Widescreen,
|
|
|
|
Cinematic,
|
|
|
|
Custom
|
|
|
|
};
|
|
|
|
|
2014-05-22 01:23:28 +02:00
|
|
|
/// Manage stuff related to video playback
|
|
|
|
class VideoController final : public wxEvtHandler {
|
2010-12-07 20:09:28 +01:00
|
|
|
/// Current frame number changed (new frame number)
|
2010-12-07 20:09:21 +01:00
|
|
|
agi::signal::Signal<int> Seek;
|
2010-12-07 20:09:28 +01:00
|
|
|
/// Aspect ratio was changed (type, value)
|
2013-01-20 22:05:24 +01:00
|
|
|
agi::signal::Signal<AspectRatio, double> ARChange;
|
2010-12-07 20:09:21 +01:00
|
|
|
|
2011-01-16 08:17:08 +01:00
|
|
|
agi::Context *context;
|
|
|
|
|
2012-11-13 17:51:01 +01:00
|
|
|
/// The video provider owned by the threaded frame source, or nullptr if no
|
2011-12-06 01:18:04 +01:00
|
|
|
/// video is open
|
2014-05-22 01:23:28 +02:00
|
|
|
AsyncVideoProvider *provider = nullptr;
|
2010-08-26 20:38:37 +02:00
|
|
|
|
2014-05-20 04:21:50 +02:00
|
|
|
/// Last seen script color matrix
|
|
|
|
std::string color_matrix;
|
|
|
|
|
2012-03-12 01:07:09 +01:00
|
|
|
/// Playback timer used to periodically check if we should go to the next
|
|
|
|
/// frame while playing video
|
2007-01-21 07:30:19 +01:00
|
|
|
wxTimer playback;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
/// Time when playback was last started
|
|
|
|
std::chrono::steady_clock::time_point playback_start_time;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-12-06 01:18:04 +01:00
|
|
|
/// The start time of the first frame of the current playback; undefined if
|
|
|
|
/// video is not currently playing
|
2013-12-12 01:29:48 +01:00
|
|
|
int start_ms = 0;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-12-06 01:18:04 +01:00
|
|
|
/// The last frame to play if video is currently playing
|
2013-12-12 01:29:48 +01:00
|
|
|
int end_frame = 0;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-12-06 01:18:04 +01:00
|
|
|
/// The frame number which was last requested from the video provider,
|
|
|
|
/// which may not be the same thing as the currently displayed frame
|
2013-12-12 01:29:48 +01:00
|
|
|
int frame_n = 0;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-12-06 01:18:04 +01:00
|
|
|
/// The picture aspect ratio of the video if the aspect ratio has been
|
|
|
|
/// overridden by the user
|
2013-12-12 01:29:48 +01:00
|
|
|
double ar_value = 1.;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2013-01-20 22:05:24 +01:00
|
|
|
/// The current AR type
|
2013-12-12 01:29:48 +01:00
|
|
|
AspectRatio ar_type = AspectRatio::Default;
|
2007-01-23 07:32:16 +01:00
|
|
|
|
2012-03-12 01:07:09 +01:00
|
|
|
/// Cached option for audio playing when frame stepping
|
2010-11-08 06:08:24 +01:00
|
|
|
const agi::OptionValue* playAudioOnStep;
|
2010-06-08 08:09:13 +02:00
|
|
|
|
2014-05-22 01:23:28 +02:00
|
|
|
std::vector<agi::signal::Connection> connections;
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
void OnPlayTimer(wxTimerEvent &event);
|
|
|
|
|
2010-07-23 07:58:39 +02:00
|
|
|
void OnVideoError(VideoProviderErrorEvent const& err);
|
|
|
|
void OnSubtitlesError(SubtitlesProviderErrorEvent const& err);
|
|
|
|
|
2014-12-28 21:06:15 +01:00
|
|
|
void OnSubtitlesCommit(int type, const AssDialogue *changed);
|
2014-05-22 01:23:28 +02:00
|
|
|
void OnNewVideoProvider(AsyncVideoProvider *provider);
|
|
|
|
void OnActiveLineChanged(AssDialogue *line);
|
2011-01-16 08:16:40 +01:00
|
|
|
|
2014-05-22 01:23:28 +02:00
|
|
|
void RequestFrame();
|
2011-11-23 19:32:37 +01:00
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
public:
|
2014-05-22 01:23:28 +02:00
|
|
|
VideoController(agi::Context *context);
|
2011-12-06 01:17:54 +01:00
|
|
|
|
2011-12-06 01:18:04 +01:00
|
|
|
/// Is the video currently playing?
|
2011-12-05 06:26:45 +01:00
|
|
|
bool IsPlaying() const { return playback.IsRunning(); }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-12-06 01:18:04 +01:00
|
|
|
/// Get the current frame number
|
2010-07-08 06:29:04 +02:00
|
|
|
int GetFrameN() const { return frame_n; }
|
2007-01-21 07:30:19 +01:00
|
|
|
|
2012-03-12 01:07:09 +01:00
|
|
|
/// Get the actual aspect ratio from a predefined AR type
|
2013-01-20 22:05:24 +01:00
|
|
|
double GetARFromType(AspectRatio type) const;
|
|
|
|
|
|
|
|
/// Override the aspect ratio of the currently loaded video
|
|
|
|
void SetAspectRatio(double value);
|
2011-12-06 01:18:04 +01:00
|
|
|
|
|
|
|
/// Override the aspect ratio of the currently loaded video
|
2013-01-20 22:05:24 +01:00
|
|
|
/// @param type Predefined type to set the AR to. Must not be Custom.
|
|
|
|
void SetAspectRatio(AspectRatio type);
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-03-12 01:07:09 +01:00
|
|
|
/// Get the current AR type
|
2013-01-20 22:05:24 +01:00
|
|
|
AspectRatio GetAspectRatioType() const { return ar_type; }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2011-12-06 01:18:04 +01:00
|
|
|
/// Get the current aspect ratio of the video
|
2013-01-04 16:01:50 +01:00
|
|
|
double GetAspectRatioValue() const { return ar_value; }
|
2007-01-23 07:32:16 +01:00
|
|
|
|
2010-07-08 06:29:04 +02:00
|
|
|
/// @brief Jump to the beginning of a frame
|
|
|
|
/// @param n Frame number to jump to
|
2007-01-21 07:30:19 +01:00
|
|
|
void JumpToFrame(int n);
|
2010-07-08 06:29:04 +02:00
|
|
|
/// @brief Jump to a time
|
|
|
|
/// @param ms Time to jump to in milliseconds
|
|
|
|
/// @param end Type of time
|
|
|
|
void JumpToTime(int ms, agi::vfr::Time end = agi::vfr::START);
|
2007-01-21 07:30:19 +01:00
|
|
|
|
2010-07-08 06:29:04 +02:00
|
|
|
/// Starting playing the video
|
2007-01-21 07:30:19 +01:00
|
|
|
void Play();
|
2010-07-08 06:29:04 +02:00
|
|
|
/// Play the next frame then stop
|
2011-01-16 08:15:53 +01:00
|
|
|
void NextFrame();
|
2010-07-08 06:29:04 +02:00
|
|
|
/// Play the previous frame then stop
|
2011-01-16 08:15:53 +01:00
|
|
|
void PrevFrame();
|
2010-07-08 06:29:04 +02:00
|
|
|
/// Seek to the beginning of the current line, then play to the end of it
|
2007-01-21 07:30:19 +01:00
|
|
|
void PlayLine();
|
2010-07-08 06:29:04 +02:00
|
|
|
/// Stop playing
|
2007-01-21 07:30:19 +01:00
|
|
|
void Stop();
|
|
|
|
|
2010-12-07 20:09:21 +01:00
|
|
|
DEFINE_SIGNAL_ADDERS(Seek, AddSeekListener)
|
2010-12-07 20:09:28 +01:00
|
|
|
DEFINE_SIGNAL_ADDERS(ARChange, AddARChangeListener)
|
2010-12-07 20:09:21 +01:00
|
|
|
|
2010-07-08 06:29:04 +02:00
|
|
|
int TimeAtFrame(int frame, agi::vfr::Time type = agi::vfr::EXACT) const;
|
|
|
|
int FrameAtTime(int time, agi::vfr::Time type = agi::vfr::EXACT) const;
|
2022-05-07 16:13:50 +02:00
|
|
|
std::shared_ptr<VideoFrame> GetFrame(int frame, bool raw) const;
|
2007-01-21 07:30:19 +01:00
|
|
|
};
|