Commit f41ba26d authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Add StreamReader/Writer custom IO to doc (#3367)

Summary: Pull Request resolved: https://github.com/pytorch/audio/pull/3367

Reviewed By: nateanl

Differential Revision: D46148139

Pulled By: mthrok

fbshipit-source-id: 50f297ac69bb95562976eb452e4e382b8c064c3c
parent 8b85ca5d
...@@ -5,13 +5,28 @@ ...@@ -5,13 +5,28 @@
torchaudio::io::StreamReader torchaudio::io::StreamReader
============================ ============================
.. doxygenclass:: torchaudio::io::StreamReader ``StreamReader`` is the implementation used by Python equivalent and provides similar interface.
When working with custom I/O, such as in-memory data, ``StreamReaderCustomIO`` class can be used.
Both classes have the same methods defined, so their usages are the same.
Constructors Constructors
------------ ------------
StreamReader
^^^^^^^^^^^^
.. doxygenclass:: torchaudio::io::StreamReader
.. doxygenfunction:: torchaudio::io::StreamReader::StreamReader(const std::string &src, const c10::optional<std::string> &format = {}, const c10::optional<OptionDict> &option = {}) .. doxygenfunction:: torchaudio::io::StreamReader::StreamReader(const std::string &src, const c10::optional<std::string> &format = {}, const c10::optional<OptionDict> &option = {})
StreamReaderCustomIO
^^^^^^^^^^^^^^^^^^^^
.. doxygenclass:: torchaudio::io::StreamReaderCustomIO
.. doxygenfunction:: torchaudio::io::StreamReaderCustomIO::StreamReaderCustomIO
Query Methods Query Methods
------------- -------------
......
...@@ -5,13 +5,28 @@ ...@@ -5,13 +5,28 @@
torchaudio::io::StreamWriter torchaudio::io::StreamWriter
============================ ============================
.. doxygenclass:: torchaudio::io::StreamWriter ``StreamWriter`` is the implementation used by Python equivalent and provides similar interface.
When working with custom I/O, such as in-memory data, ``StreamWriterCustomIO`` class can be used.
Both classes have the same methods defined, so their usages are the same.
Constructors Constructors
------------ ------------
StreamWriter
^^^^^^^^^^^^
.. doxygenclass:: torchaudio::io::StreamWriter
.. doxygenfunction:: torchaudio::io::StreamWriter::StreamWriter(const std::string &dst, const c10::optional<std::string> &format = {}) .. doxygenfunction:: torchaudio::io::StreamWriter::StreamWriter(const std::string &dst, const c10::optional<std::string> &format = {})
StreamWriterCustomIO
^^^^^^^^^^^^^^^^^^^^
.. doxygenclass:: torchaudio::io::StreamWriterCustomIO
.. doxygenfunction:: torchaudio::io::StreamWriterCustomIO::StreamWriterCustomIO
Config methods Config methods
-------------- --------------
......
...@@ -359,16 +359,23 @@ struct CustomInput { ...@@ -359,16 +359,23 @@ struct CustomInput {
/// @endcond /// @endcond
/// Construct StreamReader with custom read and seek functions.
/// ///
/// @param opaque Custom data used by read_packet and seek functions. /// A subclass of StreamReader which works with custom read function.
/// @param format Specify input format. /// Can be used for decoding media from memory or custom object.
/// @param buffer_size The size of the intermediate buffer, which FFmpeg uses to ///
/// pass data to function read_packet. class StreamReaderCustomIO : private detail::CustomInput, public StreamReader {
/// @param read_packet Custom read function that is called from FFmpeg to public:
/// read data from the destination. ///
/// @param seek Optional seek function that is used to seek the destination. /// Construct StreamReader with custom read and seek functions.
struct StreamReaderCustomIO : private detail::CustomInput, public StreamReader { ///
/// @param opaque Custom data used by ``read_packet`` and ``seek`` functions.
/// @param format Specify input format.
/// @param buffer_size The size of the intermediate buffer, which FFmpeg uses
/// to pass data to function read_packet.
/// @param read_packet Custom read function that is called from FFmpeg to
/// read data from the destination.
/// @param seek Optional seek function that is used to seek the destination.
/// @param option Custom option passed when initializing format context.
StreamReaderCustomIO( StreamReaderCustomIO(
void* opaque, void* opaque,
const c10::optional<std::string>& format, const c10::optional<std::string>& format,
......
...@@ -306,17 +306,21 @@ struct CustomOutput { ...@@ -306,17 +306,21 @@ struct CustomOutput {
/// @endcond /// @endcond
/// Construct StreamWriter with custom write and seek functions.
/// ///
/// @param opaque Custom data used by write_packet and seek functions. /// A subclass of StreamReader which works with custom read function.
/// @param format Specify output format. /// Can be used for encoding media into memory or custom object.
/// @param buffer_size The size of the intermediate buffer, which FFmpeg uses to ///
/// pass data to write_packet function. class StreamWriterCustomIO : private detail::CustomOutput, public StreamWriter {
/// @param write_packet Custom write function that is called from FFmpeg to public:
/// actually write data to the custom destination. /// Construct StreamWriterCustomIO with custom write and seek functions.
/// @param seek Optional seek function that is used to seek the destination. ///
struct StreamWriterCustomIO : private detail::CustomOutput, /// @param opaque Custom data used by ``write_packet`` and ``seek`` functions.
public StreamWriter { /// @param format Specify output format.
/// @param buffer_size The size of the intermediate buffer, which FFmpeg uses
/// to pass data to write_packet function.
/// @param write_packet Custom write function that is called from FFmpeg to
/// actually write data to the custom destination.
/// @param seek Optional seek function that is used to seek the destination.
StreamWriterCustomIO( StreamWriterCustomIO(
void* opaque, void* opaque,
const c10::optional<std::string>& format, const c10::optional<std::string>& format,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment