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 @@
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
------------
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 = {})
StreamReaderCustomIO
^^^^^^^^^^^^^^^^^^^^
.. doxygenclass:: torchaudio::io::StreamReaderCustomIO
.. doxygenfunction:: torchaudio::io::StreamReaderCustomIO::StreamReaderCustomIO
Query Methods
-------------
......
......@@ -5,13 +5,28 @@
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
------------
StreamWriter
^^^^^^^^^^^^
.. doxygenclass:: torchaudio::io::StreamWriter
.. 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
--------------
......
......@@ -359,16 +359,23 @@ struct CustomInput {
/// @endcond
/// Construct StreamReader with custom read and seek functions.
///
/// @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.
struct StreamReaderCustomIO : private detail::CustomInput, public StreamReader {
/// A subclass of StreamReader which works with custom read function.
/// Can be used for decoding media from memory or custom object.
///
class StreamReaderCustomIO : private detail::CustomInput, public StreamReader {
public:
///
/// Construct StreamReader with custom read and seek functions.
///
/// @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(
void* opaque,
const c10::optional<std::string>& format,
......
......@@ -306,17 +306,21 @@ struct CustomOutput {
/// @endcond
/// Construct StreamWriter with custom write and seek functions.
///
/// @param opaque Custom data used by write_packet and seek functions.
/// @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.
struct StreamWriterCustomIO : private detail::CustomOutput,
public StreamWriter {
/// A subclass of StreamReader which works with custom read function.
/// Can be used for encoding media into memory or custom object.
///
class StreamWriterCustomIO : private detail::CustomOutput, public StreamWriter {
public:
/// Construct StreamWriterCustomIO with custom write and seek functions.
///
/// @param opaque Custom data used by ``write_packet`` and ``seek`` functions.
/// @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(
void* opaque,
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