class_docstr: Fetch and decode audio/video streams chunk by chunk.
  
  For the detailed usage of this class, please refer to the tutorial.
  
  Args:
      src (str, path-like, bytes or file-like object): The media source.
          If string-type, it must be a resource indicator that FFmpeg can
          handle. This includes a file path, URL, device identifier or
          filter expression. The supported value depends on the FFmpeg found
          in the system.
  
          If bytes, it must be an encoded media data in contiguous memory.
  
          If file-like object, it must support `read` method with the signature
          `read(size: int) -> bytes`.
          Additionally, if the file-like object has `seek` method, it uses
          the method when parsing media metadata. This improves the reliability
          of codec detection. The signagure of `seek` method must be
          `seek(offset: int, whence: int) -> int`.
  
          Please refer to the following for the expected signature and behavior
          of `read` and `seek` method.
  
          - https://docs.python.org/3/library/io.html#io.BufferedIOBase.read
          - https://docs.python.org/3/library/io.html#io.IOBase.seek
  
      format (str or None, optional):
          Override the input format, or specify the source sound device.
          Default: ``None`` (no override nor device input).
  
          This argument serves two different usecases.
  
          1) Override the source format.
             This is useful when the input data do not contain a header.
  
          2) Specify the input source device.
             This allows to load media stream from hardware devices,
             such as microphone, camera and screen, or a virtual device.
  
  
          .. note::
  
             This option roughly corresponds to ``-f`` option of ``ffmpeg`` command.
             Please refer to the ffmpeg documentations for the possible values.
  
             https://ffmpeg.org/ffmpeg-formats.html#Demuxers
  
             Please use :py:func:`~torio.utils.ffmpeg_utils.get_demuxers` to list the
             demultiplexers available in the current environment.
  
             For device access, the available values vary based on hardware (AV device) and
             software configuration (ffmpeg build).
  
             https://ffmpeg.org/ffmpeg-devices.html#Input-Devices
  
             Please use :py:func:`~torio.utils.ffmpeg_utils.get_input_devices` to list
             the input devices available in the current environment.
  
      option (dict of str to str, optional):
          Custom option passed when initializing format context (opening source).
  
          You can use this argument to change the input source before it is passed to decoder.
  
          Default: ``None``.
  
      buffer_size (int):
          The internal buffer size in byte. Used only when `src` is file-like object.
  
          Default: `4096`.
class_docstr_tok: ["Fetch","and","decode","audio\/video","streams","chunk","by","chunk",".","For","the","detailed","usage","of","this","class",",","please","refer","to","the","tutorial",".","Args",":","src","(","str",",","path-like",",","bytes","or","file-like","object",")",":","The","media","source",".","If","string-type",",","it","must","be","a","resource","indicator","that","FFmpeg","can","handle",".","This","includes","a","file","path",",","URL",",","device","identifier","or","filter","expression",".","The","supported","value","depends","on","the","FFmpeg","found","in","the","system",".","If","bytes",",","it","must","be","an","encoded","media","data","in","contiguous","memory",".","If","file-like","object",",","it","must","support","`","read","`","method","with","the","signature","`","read","(","size",":","int",")","-",">","bytes","`",".","Additionally",",","if","the","file-like","object","has","`","seek","`","method",",","it","uses","the","method","when","parsing","media","metadata",".","This","improves","the","reliability","of","codec","detection",".","The","signagure","of","`","seek","`","method","must","be","`","seek","(","offset",":","int",",","whence",":","int",")","-",">","int","`",".","Please","refer","to","the","following","for","the","expected","signature","and","behavior","of","`","read","`","and","`","seek","`","method",".","-","https",":","\/\/docs.python.org\/3\/library\/io.html","#","io.BufferedIOBase.read","-","https",":","\/\/docs.python.org\/3\/library\/io.html","#","io.IOBase.seek","format","(","str","or","None",",","optional",")",":","Override","the","input","format",",","or","specify","the","source","sound","device",".","Default",":","``","None","``","(","no","override","nor","device","input",")",".","This","argument","serves","two","different","usecases",".","1",")","Override","the","source","format",".","This","is","useful","when","the","input","data","do","not","contain","a","header",".","2",")","Specify","the","input","source","device",".","This","allows","to","load","media","stream","from","hardware","devices",",","such","as","microphone",",","camera","and","screen",",","or","a","virtual","device",".","..","note",":",":","This","option","roughly","corresponds","to","``","-f","``","option","of","``","ffmpeg","``","command",".","Please","refer","to","the","ffmpeg","documentations","for","the","possible","values",".","https",":","\/\/ffmpeg.org\/ffmpeg-formats.html","#","Demuxers","Please","use",":","py",":","func",":","`","~torio.utils.ffmpeg_utils.get_demuxers","`","to","list","the","demultiplexers","available","in","the","current","environment",".","For","device","access",",","the","available","values","vary","based","on","hardware","(","AV","device",")","and","software","configuration","(","ffmpeg","build",")",".","https",":","\/\/ffmpeg.org\/ffmpeg-devices.html","#","Input-Devices","Please","use",":","py",":","func",":","`","~torio.utils.ffmpeg_utils.get_input_devices","`","to","list","the","input","devices","available","in","the","current","environment",".","option","(","dict","of","str","to","str",",","optional",")",":","Custom","option","passed","when","initializing","format","context","(","opening","source",")",".","You","can","use","this","argument","to","change","the","input","source","before","it","is","passed","to","decoder",".","Default",":","``","None","``",".","buffer_size","(","int",")",":","The","internal","buffer","size","in","byte",".","Used","only","when","`","src","`","is","file-like","object",".","Default",":","`","4096","`","."]
docstr: Read the source media and process one packet.
  
  If a packet is read successfully, then the data in the packet will
  be decoded and passed to corresponding output stream processors.
  
  If the packet belongs to a source stream that is not connected to
  an output stream, then the data are discarded.
  
  When the source reaches EOF, then it triggers all the output stream
  processors to enter drain mode. All the output stream processors
  flush the pending frames.
  
  Args:
      timeout (float or None, optional): Timeout in milli seconds.
  
          This argument changes the retry behavior when it failed to
          process a packet due to the underlying media resource being
          temporarily unavailable.
  
          When using a media device such as a microphone, there are cases
          where the underlying buffer is not ready.
          Calling this function in such case would cause the system to report
          `EAGAIN (resource temporarily unavailable)`.
  
          * ``>=0``: Keep retrying until the given time passes.
  
          * ``0<``: Keep retrying forever.
  
          * ``None`` : No retrying and raise an exception immediately.
  
          Default: ``None``.
  
          Note:
  
              The retry behavior is applicable only when the reason is the
              unavailable resource. It is not invoked if the reason of failure is
              other.
  
      backoff (float, optional): Time to wait before retrying in milli seconds.
  
          This option is effective only when `timeout` is effective. (not ``None``)
  
          When `timeout` is effective, this `backoff` controls how long the function
          should wait before retrying. Default: ``10.0``.
  
  Returns:
      int:
          ``0``
          A packet was processed properly. The caller can keep
          calling this function to buffer more frames.
  
          ``1``
          The streamer reached EOF. All the output stream processors
          flushed the pending frames. The caller should stop calling
          this method.
docstr_tok: ["Read","the","source","media","and","process","one","packet",".","If","a","packet","is","read","successfully",",","then","the","data","in","the","packet","will","be","decoded","and","passed","to","corresponding","output","stream","processors",".","If","the","packet","belongs","to","a","source","stream","that","is","not","connected","to","an","output","stream",",","then","the","data","are","discarded",".","When","the","source","reaches","EOF",",","then","it","triggers","all","the","output","stream","processors","to","enter","drain","mode",".","All","the","output","stream","processors","flush","the","pending","frames",".","Args",":","timeout","(","float","or","None",",","optional",")",":","Timeout","in","milli","seconds",".","This","argument","changes","the","retry","behavior","when","it","failed","to","process","a","packet","due","to","the","underlying","media","resource","being","temporarily","unavailable",".","When","using","a","media","device","such","as","a","microphone",",","there","are","cases","where","the","underlying","buffer","is","not","ready",".","Calling","this","function","in","such","case","would","cause","the","system","to","report","`","EAGAIN","(","resource","temporarily","unavailable",")","`",".","*","``",">","=0","``",":","Keep","retrying","until","the","given","time","passes",".","*","``","0","<","``",":","Keep","retrying","forever",".","*","``","None","``",":","No","retrying","and","raise","an","exception","immediately",".","Default",":","``","None","``",".","Note",":","The","retry","behavior","is","applicable","only","when","the","reason","is","the","unavailable","resource",".","It","is","not","invoked","if","the","reason","of","failure","is","other",".","backoff","(","float",",","optional",")",":","Time","to","wait","before","retrying","in","milli","seconds",".","This","option","is","effective","only","when","`","timeout","`","is","effective",".","(","not","``","None","``",")","When","`","timeout","`","is","effective",",","this","`","backoff","`","controls","how","long","the","function","should","wait","before","retrying",".","Default",":","``","10.0","``",".","Returns",":","int",":","``","0","``","A","packet","was","processed","properly",".","The","caller","can","keep","calling","this","function","to","buffer","more","frames",".","``","1","``","The","streamer","reached","EOF",".","All","the","output","stream","processors","flushed","the","pending","frames",".","The","caller","should","stop","calling","this","method","."]
code: def process_packet(
      self, timeout: Optional[float] = None, backoff: float = 10.0
  ) -> int:
      """Read the source media and process one packet.
  
      If a packet is read successfully, then the data in the packet will
      be decoded and passed to corresponding output stream processors.
  
      If the packet belongs to a source stream that is not connected to
      an output stream, then the data are discarded.
  
      When the source reaches EOF, then it triggers all the output stream
      processors to enter drain mode. All the output stream processors
      flush the pending frames.
  
      Args:
          timeout (float or None, optional): Timeout in milli seconds.
  
              This argument changes the retry behavior when it failed to
              process a packet due to the underlying media resource being
              temporarily unavailable.
  
              When using a media device such as a microphone, there are cases
              where the underlying buffer is not ready.
              Calling this function in such case would cause the system to report
              `EAGAIN (resource temporarily unavailable)`.
  
              * ``>=0``: Keep retrying until the given time passes.
  
              * ``0<``: Keep retrying forever.
  
              * ``None`` : No retrying and raise an exception immediately.
  
              Default: ``None``.
  
              Note:
  
                  The retry behavior is applicable only when the reason is the
                  unavailable resource. It is not invoked if the reason of failure is
                  other.
  
          backoff (float, optional): Time to wait before retrying in milli seconds.
  
              This option is effective only when `timeout` is effective. (not ``None``)
  
              When `timeout` is effective, this `backoff` controls how long the function
              should wait before retrying. Default: ``10.0``.
  
      Returns:
          int:
              ``0``
              A packet was processed properly. The caller can keep
              calling this function to buffer more frames.
  
              ``1``
              The streamer reached EOF. All the output stream processors
              flushed the pending frames. The caller should stop calling
              this method.
      """
      return self._be.process_packet(timeout, backoff)
  
imports: from __future__ import annotations
  import os
  from dataclasses import dataclass
  from pathlib import Path
  from typing import BinaryIO, Dict, Iterator, Optional, Tuple, TypeVar, Union
  import torch
  import torio
  from torch.utils._pytree import tree_map
label_desc: Use image node_id 15 for calling the StreamingMediaDecoder obj's underlying member method code with example usage: obj.process_packet(timeout, backoff) and returns: self