mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
New Media Player option to Rewind on Disabled
This commit is contained in:
@@ -37,6 +37,7 @@ MediaPlayer::MediaPlayer()
|
|||||||
|
|
||||||
failed_ = false;
|
failed_ = false;
|
||||||
seeking_ = false;
|
seeking_ = false;
|
||||||
|
rewind_on_disable_ = false;
|
||||||
force_software_decoding_ = false;
|
force_software_decoding_ = false;
|
||||||
decoder_name_ = "";
|
decoder_name_ = "";
|
||||||
rate_ = 1.0;
|
rate_ = 1.0;
|
||||||
@@ -517,6 +518,11 @@ void MediaPlayer::enable(bool on)
|
|||||||
|
|
||||||
if ( enabled_ != on ) {
|
if ( enabled_ != on ) {
|
||||||
|
|
||||||
|
// option to automatically rewind each time the player is disabled
|
||||||
|
if (!on && rewind_on_disable_ )
|
||||||
|
rewind(true);
|
||||||
|
|
||||||
|
// apply change
|
||||||
enabled_ = on;
|
enabled_ = on;
|
||||||
|
|
||||||
// default to pause
|
// default to pause
|
||||||
@@ -648,7 +654,7 @@ void MediaPlayer::setLoop(MediaPlayer::LoopMode mode)
|
|||||||
loop_ = mode;
|
loop_ = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaPlayer::rewind()
|
void MediaPlayer::rewind(bool force)
|
||||||
{
|
{
|
||||||
if (!enabled_ || !media_.seekable)
|
if (!enabled_ || !media_.seekable)
|
||||||
return;
|
return;
|
||||||
@@ -665,6 +671,12 @@ void MediaPlayer::rewind()
|
|||||||
// normal case, end is last frame
|
// normal case, end is last frame
|
||||||
execute_seek_command( timeline_.previous(timeline_.last()) );
|
execute_seek_command( timeline_.previous(timeline_.last()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (force) {
|
||||||
|
GstState state;
|
||||||
|
gst_element_get_state (pipeline_, &state, NULL, GST_CLOCK_TIME_NONE);
|
||||||
|
update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1111,7 +1123,9 @@ bool MediaPlayer::fill_frame(GstBuffer *buf, FrameStatus status)
|
|||||||
// get the frame from buffer
|
// get the frame from buffer
|
||||||
if ( !gst_video_frame_map (&frame_[write_index_].vframe, &v_frame_video_info_, buf, GST_MAP_READ ) )
|
if ( !gst_video_frame_map (&frame_[write_index_].vframe, &v_frame_video_info_, buf, GST_MAP_READ ) )
|
||||||
{
|
{
|
||||||
|
#ifdef MEDIA_PLAYER_DEBUG
|
||||||
Log::Info("MediaPlayer %s Failed to map the video buffer", std::to_string(id_).c_str());
|
Log::Info("MediaPlayer %s Failed to map the video buffer", std::to_string(id_).c_str());
|
||||||
|
#endif
|
||||||
// free access to frame & exit
|
// free access to frame & exit
|
||||||
frame_[write_index_].status = INVALID;
|
frame_[write_index_].status = INVALID;
|
||||||
frame_[write_index_].access.unlock();
|
frame_[write_index_].access.unlock();
|
||||||
@@ -1138,6 +1152,7 @@ bool MediaPlayer::fill_frame(GstBuffer *buf, FrameStatus status)
|
|||||||
#ifdef MEDIA_PLAYER_DEBUG
|
#ifdef MEDIA_PLAYER_DEBUG
|
||||||
Log::Info("MediaPlayer %s Received an Invalid frame", std::to_string(id_).c_str());
|
Log::Info("MediaPlayer %s Received an Invalid frame", std::to_string(id_).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
// free access to frame & exit
|
||||||
frame_[write_index_].status = INVALID;
|
frame_[write_index_].status = INVALID;
|
||||||
frame_[write_index_].access.unlock();
|
frame_[write_index_].access.unlock();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Seek to zero
|
* Seek to zero
|
||||||
* */
|
* */
|
||||||
void rewind();
|
void rewind(bool force = false);
|
||||||
/**
|
/**
|
||||||
* Get position time
|
* Get position time
|
||||||
* */
|
* */
|
||||||
@@ -254,6 +254,12 @@ public:
|
|||||||
* */
|
* */
|
||||||
void setSoftwareDecodingForced(bool on);
|
void setSoftwareDecodingForced(bool on);
|
||||||
bool softwareDecodingForced();
|
bool softwareDecodingForced();
|
||||||
|
/**
|
||||||
|
* Option to automatically rewind each time the player is disabled
|
||||||
|
* (i.e. when enable(false) is called )
|
||||||
|
* */
|
||||||
|
inline void setRewindOnDisabled(bool on) { rewind_on_disable_ = on; }
|
||||||
|
inline bool rewindOnDisabled() const { return rewind_on_disable_; }
|
||||||
/**
|
/**
|
||||||
* Accept visitors
|
* Accept visitors
|
||||||
* */
|
* */
|
||||||
@@ -292,6 +298,7 @@ private:
|
|||||||
std::atomic<bool> failed_;
|
std::atomic<bool> failed_;
|
||||||
bool seeking_;
|
bool seeking_;
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
|
bool rewind_on_disable_;
|
||||||
bool force_software_decoding_;
|
bool force_software_decoding_;
|
||||||
std::string decoder_name_;
|
std::string decoder_name_;
|
||||||
|
|
||||||
|
|||||||
@@ -701,6 +701,10 @@ void SessionLoader::visit(MediaPlayer &n)
|
|||||||
mediaplayerNode->QueryBoolAttribute("software_decoding", &gpudisable);
|
mediaplayerNode->QueryBoolAttribute("software_decoding", &gpudisable);
|
||||||
n.setSoftwareDecodingForced(gpudisable);
|
n.setSoftwareDecodingForced(gpudisable);
|
||||||
|
|
||||||
|
bool rewind_on_disabled = false;
|
||||||
|
mediaplayerNode->QueryBoolAttribute("rewind_on_disabled", &rewind_on_disabled);
|
||||||
|
n.setRewindOnDisabled(rewind_on_disabled);
|
||||||
|
|
||||||
bool play = true;
|
bool play = true;
|
||||||
mediaplayerNode->QueryBoolAttribute("play", &play);
|
mediaplayerNode->QueryBoolAttribute("play", &play);
|
||||||
n.play(play);
|
n.play(play);
|
||||||
|
|||||||
@@ -334,6 +334,7 @@ void SessionVisitor::visit(MediaPlayer &n)
|
|||||||
newelement->SetAttribute("loop", (int) n.loop());
|
newelement->SetAttribute("loop", (int) n.loop());
|
||||||
newelement->SetAttribute("speed", n.playSpeed());
|
newelement->SetAttribute("speed", n.playSpeed());
|
||||||
newelement->SetAttribute("software_decoding", n.softwareDecodingForced());
|
newelement->SetAttribute("software_decoding", n.softwareDecodingForced());
|
||||||
|
newelement->SetAttribute("rewind_on_disabled", n.rewindOnDisabled());
|
||||||
|
|
||||||
// timeline
|
// timeline
|
||||||
XMLElement *timelineelement = xmlDoc_->NewElement("Timeline");
|
XMLElement *timelineelement = xmlDoc_->NewElement("Timeline");
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ TextEditor editor;
|
|||||||
#define PLOT_ARRAY_SIZE 180
|
#define PLOT_ARRAY_SIZE 180
|
||||||
#define LABEL_AUTO_MEDIA_PLAYER ICON_FA_CARET_SQUARE_RIGHT " Dynamic selection"
|
#define LABEL_AUTO_MEDIA_PLAYER ICON_FA_CARET_SQUARE_RIGHT " Dynamic selection"
|
||||||
#define LABEL_STORE_SELECTION " Store selection"
|
#define LABEL_STORE_SELECTION " Store selection"
|
||||||
#define LABEL_EDIT_FADING ICON_FA_RANDOM " Fading"
|
#define LABEL_EDIT_FADING ICON_FA_RANDOM " Edit Fading"
|
||||||
|
|
||||||
// utility functions
|
// utility functions
|
||||||
void ShowAboutGStreamer(bool* p_open);
|
void ShowAboutGStreamer(bool* p_open);
|
||||||
@@ -2162,6 +2162,10 @@ void SourceController::Render()
|
|||||||
if (ImGui::MenuItem(LABEL_EDIT_FADING))
|
if (ImGui::MenuItem(LABEL_EDIT_FADING))
|
||||||
mediaplayer_edit_fading_ = true;
|
mediaplayer_edit_fading_ = true;
|
||||||
|
|
||||||
|
bool option = mediaplayer_active_->rewindOnDisabled();
|
||||||
|
if (ImGui::MenuItem(ICON_FA_FAST_BACKWARD " " ICON_FA_SNOWFLAKE " Rewind when Inactive" , NULL, &option))
|
||||||
|
mediaplayer_active_->setRewindOnDisabled(option);
|
||||||
|
|
||||||
// if (ImGui::BeginMenu(ICON_FA_CUT " Auto cut" ))
|
// if (ImGui::BeginMenu(ICON_FA_CUT " Auto cut" ))
|
||||||
// {
|
// {
|
||||||
// if (ImGuiToolkit::MenuItemIcon(14, 12, "Cut faded areas" ))
|
// if (ImGuiToolkit::MenuItemIcon(14, 12, "Cut faded areas" ))
|
||||||
|
|||||||
Reference in New Issue
Block a user