An open movie that can be read, seeked and closed.
More...
#include <movie.h>
An open movie that can be read, seeked and closed.
Definition at line 35 of file movie.h.
◆ Movie()
Open a movie in the referenced file.
- Parameters
-
| [in] | log | cras_cpp_common logging helper. |
| [in] | config | The configuration specifying what movie to open and how. |
- Exceptions
-
| std::runtime_error | If the movie cannot be opened. |
◆ ~Movie()
| virtual movie_publisher::Movie::~Movie |
( |
| ) |
|
|
virtual |
◆ _config()
- Returns
- The configuration with which the movie has been opened.
◆ _info()
- Returns
- Basic information about the open movie.
◆ _playbackState()
- Returns
- The current playback state (after the last call to nextFrame()).
◆ close()
| virtual void movie_publisher::Movie::close |
( |
| ) |
|
|
protectedvirtual |
Close the movie, free all acquired resources.
- Note
- This is automatically called in the destructor.
◆ config()
- Returns
- The configuration with which the movie has been opened.
◆ info()
- Returns
- Basic information about the open movie.
◆ nextFrame()
| virtual cras::expected<std::pair<MoviePlaybackState, sensor_msgs::ImageConstPtr>, std::string> movie_publisher::Movie::nextFrame |
( |
| ) |
|
|
virtual |
Generator returning next frame of the movie on each call.
On first call, this returns the first frame of the selected subclip. After seek(), this returns the first frame after the time it was seeked to.
- Returns
- The playback state and image. header.stamp of the image is the same as the rosTime of the playback state. It depends on what was set by setTimestampSource() and setTimestampOffset(). On error, an error message is returned. When a
nullptr is returned for the image, the movie has reached its end and no more frames will be generated. This is also reflected in the playback state hasMovieEnded().
◆ open()
| virtual cras::expected<void, std::string> movie_publisher::Movie::open |
( |
| ) |
|
|
protectedvirtual |
Open the file configured in the config object passed to constructor.
- Returns
- Nothing or error.
◆ playbackState()
- Returns
- The current playback state (after the last call to nextFrame()).
◆ seek() [1/2]
| cras::expected<void, std::string> movie_publisher::Movie::seek |
( |
const StreamTime & |
time | ) |
|
Seek the movie to the given time (relative to the start of the movie).
- Parameters
-
| [in] | time | The stream time to seek to. It is invalid to seek outside the selected subclip. |
- Returns
- Nothing or an error if seek failed.
- See also
- seekInSubclip()
◆ seek() [2/2]
| virtual cras::expected<void, std::string> movie_publisher::Movie::seek |
( |
const StreamTime & |
time, |
|
|
bool |
allowReopen |
|
) |
| |
|
protectedvirtual |
Seek the movie to the given time (relative to the start of the movie).
- Parameters
-
| [in] | time | The stream time to seek to. It is invalid to seek outside the selected subclip. |
- Returns
- Nothing or an error if seek failed.
- See also
- seekInSubclip()
- Parameters
-
| [in] | allowReopen | Whether it is allowed to reopen the movie (set to false to break recursion). |
◆ seekInSubclip()
| virtual cras::expected<void, std::string> movie_publisher::Movie::seekInSubclip |
( |
const StreamTime & |
time | ) |
|
|
virtual |
Seek the movie to the given time (relative to the start of the subclip).
- Parameters
-
| [in] | time | The subclip time to seek to. It is invalid to seek outside the selected subclip. |
- Returns
- Nothing or an error if seek failed.
- See also
- seek()
◆ setSubClip() [1/2]
| cras::expected<void, std::string> movie_publisher::Movie::setSubClip |
( |
const cras::optional< StreamTime > & |
start, |
|
|
const cras::optional< StreamTime > & |
end, |
|
|
const cras::optional< StreamDuration > & |
duration |
|
) |
| |
Limit the part of the movie returned by nextFrame() calls to the given subclip.
When all arguments are empty, the whole movie is played. If only start is non-empty, the movie plays from start to movie end. If only end is non-empty, the movie plays from the movie start to end. If only duration is non-empty, the movie plays from the movie start for duration seconds. If only start and duration are non-empty, the movie plays from start to start+duration. If only end and duration are non-empty, the movie plays from end-duration to duration. If only start and end are non-empty, the movie plays from start to end.
Error is returned when either:
- all three arguments are non-empty
- the movie is non-seekable and
start or end-duration is non-zero
start or end are outside the movie timeline
duration is longer than the movie
start + duration is outside the movie timeline
end - duration is outside the movie timeline
end is before start
- seek failed
- Note
- This function calls seek() if the current position in the whole movie does not fit in the new subclip. If you want to seek to the start of the subclip for sure, call
seekInSubClip(0).
- Parameters
-
| [in] | start | The start time (relative to movie start). |
| [in] | end | The end time (relative to movie start). |
| [in] | duration | The duration. |
- Returns
- Nothing or error message.
◆ setSubClip() [2/2]
| virtual cras::expected<void, std::string> movie_publisher::Movie::setSubClip |
( |
const cras::optional< StreamTime > & |
start, |
|
|
const cras::optional< StreamTime > & |
end, |
|
|
const cras::optional< StreamDuration > & |
duration, |
|
|
bool |
allowReopen |
|
) |
| |
|
protectedvirtual |
Limit the part of the movie returned by nextFrame() calls to the given subclip.
Limit the part of the movie returned by nextFrame() calls to the given subclip. When all arguments are empty, the whole movie is played. If only start is non-empty, the movie plays from start to movie end. If only end is non-empty, the movie plays from the movie start to end. If only duration is non-empty, the movie plays from the movie start for duration seconds. If only start and duration are non-empty, the movie plays from start to start+duration. If only end and duration are non-empty, the movie plays from end-duration to duration. If only start and end are non-empty, the movie plays from start to end.
Error is returned when either:
- all three arguments are non-empty
- the movie is non-seekable and
start or end-duration is non-zero
start or end are outside the movie timeline
duration is longer than the movie
start + duration is outside the movie timeline
end - duration is outside the movie timeline
end is before start
- seek failed
- Note
- This function calls seek() if the current position in the whole movie does not fit in the new subclip. If you want to seek to the start of the subclip for sure, call
seekInSubClip(0).
- Parameters
-
| [in] | start | The start time (relative to movie start). |
| [in] | end | The end time (relative to movie start). |
| [in] | duration | The duration. |
- Returns
- Nothing or error message.
- Parameters
-
| [in] | allowReopen | Whether it is allowed to reopen the movie (set to false to break recursion). |
◆ setTimestampOffset()
| virtual void movie_publisher::Movie::setTimestampOffset |
( |
const ros::Duration & |
offset | ) |
|
|
virtual |
Set the offset of the computed ROS timestamps relative to the reference time.
- Parameters
-
◆ staticMetadata()
- Returns
- The static metadata of the open movie.
◆ data
The documentation for this class was generated from the following file: