コード例 #1
0
static int
convert_str_to_int (scloud_prc_t * ap_prc, const char * ap_start,
                    char ** ap_end)
{
  long val = -1;
  assert (ap_prc);
  assert (ap_start);
  assert (ap_end);

  errno = 0;
  val = strtol (ap_start, ap_end, 0);

  if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
      || (errno != 0 && val == 0))
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "Error retrieving the number of channels : [%s]",
                 strerror (errno));
    }
  else if (*ap_end == ap_start)
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "Error retrieving the number of channels : "
                 "[No digits were found]");
    }

  TIZ_TRACE (handleOf (ap_prc), "Value : [%d]", val);
  return val;
}
コード例 #2
0
static int
read_page_first_pass (OGGZ * ap_oggz, const ogg_page * ap_og, long a_serialno,
                      void * ap_user_data)
{
  int rc = OGGZ_CONTINUE;
  oggdmux_prc_t * p_prc = ap_user_data;
  assert (p_prc);
  assert (ap_oggz);

  if (oggz_get_bos (ap_oggz, a_serialno) > 0)
    {
      TIZ_TRACE (handleOf (p_prc), "serialno = [%d]", a_serialno);
      if (!oggz_table_insert (
            p_prc->p_tracks_, a_serialno,
            &read_page_first_pass)) /* NULL makes it barf, needs
                                                                                                 * something */
        {
          TIZ_ERROR (handleOf (p_prc),
                     "serialno = [%d] - "
                     "Could not insert serialno in oggz table",
                     a_serialno);
          rc = OGGZ_STOP_ERR;
        }
    }

  if (oggz_get_bos (ap_oggz, ALL_OGG_STREAMS) == 0)
    {
      TIZ_TRACE (handleOf (p_prc), "Number of tracks [%d]",
                 oggz_get_numtracks (ap_oggz));
      return OGGZ_STOP_OK;
    }

  return rc;
}
コード例 #3
0
static bool
ivrport_check_tunnel_compat (const void * ap_obj,
                             OMX_PARAM_PORTDEFINITIONTYPE * ap_this_def,
                             OMX_PARAM_PORTDEFINITIONTYPE * ap_other_def)
{
  tiz_port_t * p_obj = (tiz_port_t *) ap_obj;

  assert (ap_this_def);
  assert (ap_other_def);

  if (ap_other_def->eDomain != ap_this_def->eDomain)
    {
      TIZ_ERROR (
        handleOf (ap_obj),
        "PORT [%d] : Video domain not found, instead found domain [%d]",
        p_obj->pid_, ap_other_def->eDomain);
      return false;
    }

  /* TODO : Review these compatibility checks */

  TIZ_TRACE (handleOf (ap_obj), "PORT [%d] check_tunnel_compat [OK]",
             p_obj->pid_);

  return true;
}
コード例 #4
0
static OMX_ERRORTYPE
loadedtoidle_state_set (const void * ap_obj, OMX_HANDLETYPE ap_hdl,
                        OMX_COMMANDTYPE a_cmd, OMX_U32 a_param1,
                        OMX_PTR ap_cmd_data)
{
  tiz_state_t * p_base = (tiz_state_t *) ap_obj;
  tiz_fsm_state_id_t new_state = EStateMax;

  assert (ap_obj);
  assert (ap_hdl);
  assert (a_cmd == OMX_CommandStateSet);

  TIZ_TRACE (ap_hdl,
             "Requested transition "
             "[ESubStateLoadedToIdle -> %s]...",
             tiz_fsm_state_to_str (a_param1));

  /* Allowed transitions are OMX_StateLoaded only (a.k.a. transition
   * cancellation). */
  switch (a_param1)
    {
      case OMX_StateLoaded:
        {
          new_state = ESubStateIdleToLoaded;
        }
        break;

      default:
        {
          TIZ_ERROR (ap_hdl,
                     "[OMX_ErrorIncorrectStateTransition] : "
                     "ESubStateLoadedToIdle -> [%s]",
                     tiz_state_to_str (a_param1));
          return OMX_ErrorIncorrectStateTransition;
        }
    };

  /* reset here the servants count */
  p_base->servants_count_ = 0;

  if (ESubStateIdleToLoaded == new_state)
    {
      OMX_ERRORTYPE rc = OMX_ErrorNone;
      if (OMX_ErrorNone
          != (rc = tiz_fsm_set_state (tiz_get_fsm (ap_hdl), new_state,
                                      ESubStateLoadedToIdle)))
        {
          return rc;
        }
    }

  /* IL resource deallocation should take place now */
  /* NOTE: This will call the 'tiz_state_state_set' function and not
   * 'tizloaded_state_set' (we are passing 'tizloaded' as the 1st
   * parameter  */
  return tiz_state_super_state_set (typeOf (ap_obj, "tizloaded"), ap_obj,
                                    ap_hdl, a_cmd, a_param1, ap_cmd_data);
}
コード例 #5
0
/* TODO: Remove duplicate. This function already exists in tizvideoport.c */
static inline OMX_ERRORTYPE
update_video_coding_type (void * ap_obj, const OMX_VIDEO_CODINGTYPE a_encoding)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  tiz_demuxerport_t * p_obj = ap_obj;
  tiz_videoport_t * p_video_port = NULL;
  tiz_port_t * p_base = ap_obj;

  assert (ap_obj);
  p_video_port = p_obj->p_port_;

  if (a_encoding >= OMX_VIDEO_CodingMax)
    {
      TIZ_ERROR (handleOf (ap_obj),
                 "[OMX_ErrorBadParameter] : "
                 "(Bad encoding [0x%08x]...)",
                 a_encoding);
      rc = OMX_ErrorBadParameter;
      goto end;
    }

  if (!tiz_vector_find (p_video_port->p_video_encodings_, (const OMX_PTR) (&a_encoding)))
    {
      TIZ_ERROR (handleOf (ap_obj),
                 "[OMX_ErrorUnsupportedSetting] : "
                 "(Encoding not supported [0x%08x]...)",
                 a_encoding);
      rc = OMX_ErrorUnsupportedSetting;
      goto end;
    }

  /* All well */

  /* Update this port's OMX_VIDEO_PARAM_PORTFORMATTYPE structure */
  p_video_port->port_format_.eCompressionFormat = a_encoding;

  /* Now update the base class' OMX_PARAM_PORTDEFINITIONTYPE */
  p_base->portdef_.format.video.eCompressionFormat = a_encoding;

end:

  return rc;
}
コード例 #6
0
static bool
httpsrc_port_check_tunnel_compat (const void *ap_obj,
                             OMX_PARAM_PORTDEFINITIONTYPE * ap_this_def,
                             OMX_PARAM_PORTDEFINITIONTYPE * ap_other_def)
{
  tiz_port_t *p_obj = (tiz_port_t *) ap_obj;

  assert (ap_this_def);
  assert (ap_other_def);

  if (ap_other_def->eDomain != ap_this_def->eDomain)
    {
      TIZ_ERROR (handleOf (ap_obj),
               "port [%d] check_tunnel_compat : "
               "Audio domain not found, instead found domain [%d]",
               p_obj->pid_, ap_other_def->eDomain);
      return false;
    }

  /* INFO: */
  /* This is not specified in the spec, but a binary audio reader */
  /* could use OMX_AUDIO_CodingUnused as a means to signal "any" format */

  if (ap_other_def->format.audio.eEncoding != OMX_AUDIO_CodingUnused)
    {
      if (ap_other_def->format.audio.eEncoding != OMX_AUDIO_CodingMP3
          && ap_other_def->format.audio.eEncoding != OMX_AUDIO_CodingAAC)
        {
          TIZ_ERROR (handleOf (ap_obj),
                    "port [%d] check_tunnel_compat : "
                    "Unknown encoding found [%d]",
                    p_obj->pid_, ap_other_def->format.audio.eEncoding);
          return false;
        }
    }

  TIZ_TRACE (handleOf (ap_obj),
            "port [%d] check_tunnel_compat [OK]", p_obj->pid_);

  return true;
}
コード例 #7
0
static OMX_ERRORTYPE
sdlivr_prc_allocate_resources (void * ap_obj, OMX_U32 a_pid)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  if (-1 == SDL_Init (SDL_INIT_VIDEO))
    {
      rc = OMX_ErrorInsufficientResources;
      TIZ_ERROR (handleOf (ap_obj), "[%s] : while initializing SDL [%s]",
                 tiz_err_to_str (rc), SDL_GetError ());
    }
  return rc;
}
コード例 #8
0
static OMX_ERRORTYPE
alloc_uri (oggdmux_prc_t * ap_prc)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  const long pathname_max = PATH_MAX + NAME_MAX;

  assert (ap_prc);
  assert (!ap_prc->p_uri_);

  if (!(ap_prc->p_uri_ = tiz_mem_calloc (
          1, sizeof (OMX_PARAM_CONTENTURITYPE) + pathname_max + 1)))
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "Error allocating memory for the content uri struct");
      rc = OMX_ErrorInsufficientResources;
    }
  else
    {
      ap_prc->p_uri_->nSize
        = sizeof (OMX_PARAM_CONTENTURITYPE) + pathname_max + 1;
      ap_prc->p_uri_->nVersion.nVersion = OMX_VERSION;

      if (OMX_ErrorNone
          != (rc = tiz_api_GetParameter (
                tiz_get_krn (handleOf (ap_prc)), handleOf (ap_prc),
                OMX_IndexParamContentURI, ap_prc->p_uri_)))
        {
          TIZ_ERROR (handleOf (ap_prc),
                     "[%s] : Error retrieving the URI param from port",
                     tiz_err_to_str (rc));
        }
      else
        {
          TIZ_NOTICE (handleOf (ap_prc), "URI [%s]",
                      ap_prc->p_uri_->contentURI);
        }
    }
  return rc;
}
コード例 #9
0
static OMX_ERRORTYPE init_vorbis_decoder (vorbisd_prc_t *ap_prc)
{
  OMX_ERRORTYPE rc = OMX_ErrorInsufficientResources;

  assert (NULL != ap_prc);

  tiz_check_null_ret_oom (
      ap_prc->p_fsnd_ = fish_sound_new (FISH_SOUND_DECODE, &(ap_prc->fsinfo_)));

  if (0 != fish_sound_set_interleave (ap_prc->p_fsnd_, 1))
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "[OMX_ErrorInsufficientResources] : "
                 "Could not set interleaved.");
      goto end;
    }

  if (0 != fish_sound_set_decoded_float_ilv (
               ap_prc->p_fsnd_, fishsound_decoded_callback, ap_prc))
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "[OMX_ErrorInsufficientResources] : "
                 "Could not set 'decoded' callback.");
      goto end;
    }

  rc = OMX_ErrorNone;

end:
  if (OMX_ErrorInsufficientResources == rc)
    {
      fish_sound_delete (ap_prc->p_fsnd_);
      ap_prc->p_fsnd_ = NULL;
    }

  return rc;
}
コード例 #10
0
static OMX_ERRORTYPE
sdlivr_proc_prepare_to_transfer (void *ap_obj, OMX_U32 a_pid)
{
  sdlivr_prc_t *p_prc = ap_obj;
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  OMX_PARAM_PORTDEFINITIONTYPE portdef;
  TIZ_INIT_OMX_PORT_STRUCT (portdef, ARATELIA_YUV_RENDERER_PORT_INDEX);

  TIZ_TRACE (handleOf (p_prc), "pid [%d]", a_pid);

  assert (NULL != p_prc);

  /* Retrieve port def from port */
  if (OMX_ErrorNone != (rc = tiz_api_GetParameter
                        (tiz_get_krn (handleOf (p_prc)),
                         handleOf (p_prc),
                         OMX_IndexParamPortDefinition, &portdef)))
    {
      TIZ_ERROR (handleOf (p_prc),
                 "[%s] : retrieving the port definition", tiz_err_to_str (rc));
      return rc;
    }

  p_prc->vportdef_ = portdef.format.video;

  TIZ_TRACE (handleOf (p_prc),
            "nFrameWidth = [%d] nFrameHeight = [%d] ",
            /*            "nStride = [%d] nSliceHeight = [%d] nBitrate = [%d] " */
            /*            "xFramerate = [%s] eCompressionFormat = [%d] eColorFormat = [%d]", */
            p_prc->vportdef_.nFrameWidth, p_prc->vportdef_.nFrameHeight);
  /*            p_prc->vportdef_.nStride, */
  /*            p_prc->vportdef_.nSliceHeight, */
  /*            p_prc->vportdef_.nBitrate, */
  /*            p_prc->vportdef_.xFramerate, */
  /*            p_prc->vportdef_.eCompressionFormat, */
  /*            p_prc->vportdef_.eColorFormat); */

  SDL_WM_SetCaption ("Tizonia OpenMAX IL YUV renderer", "YUV");


  p_prc->p_surface = SDL_SetVideoMode
    (p_prc->vportdef_.nFrameWidth, p_prc->vportdef_.nFrameHeight, 0,
     SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_RESIZABLE);

  p_prc->p_overlay = SDL_CreateYUVOverlay
    (p_prc->vportdef_.nFrameWidth, p_prc->vportdef_.nFrameHeight,
     SDL_YV12_OVERLAY, p_prc->p_surface);
  return OMX_ErrorNone;
}
コード例 #11
0
static inline OMX_ERRORTYPE
set_read_packet_callback (oggdmux_prc_t * ap_prc, long serialno,
                          OggzReadPacket ap_read_cback)
{
  assert (ap_prc);
  assert (ap_read_cback);
  if (oggz_set_read_callback (ap_prc->p_oggz_, serialno, ap_read_cback, ap_prc)
      < 0)
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "[OMX_ErrorInsufficientResources] : "
                 "Could not set read packet callback.");
      return OMX_ErrorInsufficientResources;
    }
  return OMX_ErrorNone;
}
コード例 #12
0
static inline OMX_ERRORTYPE
set_read_page_callback (oggdmux_prc_t * ap_prc, OggzReadPage ap_read_cback)
{
  assert (ap_prc);
  assert (ap_read_cback);
  if (oggz_set_read_page (ap_prc->p_oggz_, ALL_OGG_STREAMS, ap_read_cback,
                          ap_prc)
      < 0)
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "[OMX_ErrorInsufficientResources] : "
                 "Could not set read page callback.");
      return OMX_ErrorInsufficientResources;
    }
  return OMX_ErrorNone;
}
コード例 #13
0
static inline OMX_ERRORTYPE
seek_to_byte_offset (oggdmux_prc_t * ap_prc, const oggz_off_t a_offset)
{
  assert (ap_prc);
  /* Reset the internal EOS flags */
  ap_prc->aud_eos_ = false;
  ap_prc->vid_eos_ = false;
  if (oggz_seek (ap_prc->p_oggz_, a_offset, SEEK_SET) == -1)
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "[OMX_ErrorInsufficientResources] : "
                 "Could not seek to [%d] offset",
                 a_offset);
      return OMX_ErrorInsufficientResources;
    }
  return OMX_ErrorNone;
}
コード例 #14
0
static OMX_ERRORTYPE
httpr_prc_config_change (const void * ap_prc, const OMX_U32 a_pid,
                         const OMX_INDEXTYPE a_config_idx)
{
  const httpr_prc_t * p_prc = ap_prc;
  OMX_ERRORTYPE rc = OMX_ErrorNone;

  assert (ap_prc);

  if (p_prc->p_server_ && OMX_TizoniaIndexConfigIcecastMetadata == a_config_idx
      && ARATELIA_HTTP_RENDERER_PORT_INDEX == a_pid)
    {
      OMX_TIZONIA_ICECASTMETADATATYPE * p_metadata
        = (OMX_TIZONIA_ICECASTMETADATATYPE *) tiz_mem_calloc (
          1, sizeof (OMX_TIZONIA_ICECASTMETADATATYPE)
               + OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE + 1);

      tiz_check_null_ret_oom (p_metadata);

      /* Retrieve the updated icecast metadata from the input port */
      TIZ_INIT_OMX_PORT_STRUCT (*p_metadata, ARATELIA_HTTP_RENDERER_PORT_INDEX);
      p_metadata->nSize = sizeof (OMX_TIZONIA_ICECASTMETADATATYPE)
                          + OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE;

      if (OMX_ErrorNone
          != (rc = tiz_api_GetConfig (
                tiz_get_krn (handleOf (p_prc)), handleOf (p_prc),
                OMX_TizoniaIndexConfigIcecastMetadata, p_metadata)))
        {
          TIZ_ERROR (handleOf (p_prc),
                     "[%s] : Error retrieving "
                     "OMX_TizoniaIndexConfigIcecastMetadata from port",
                     tiz_err_to_str (rc));
        }
      else
        {
          httpr_srv_set_stream_title (p_prc->p_server_,
                                      p_metadata->cStreamTitle);
        }

      tiz_mem_free (p_metadata);
      p_metadata = NULL;
    }
  return rc;
}
コード例 #15
0
static void
mp4_log_cback (MP4LogLevel loglevel, const char * fmt, va_list ap)
{
  #define MAX_ALLOCA_BUF 1024
  char * buffer = alloca (MAX_ALLOCA_BUF);
  vsnprintf (buffer, MAX_ALLOCA_BUF, fmt, ap);

  /* typedef enum {
     MP4_LOG_NONE = 0,
     MP4_LOG_ERROR = 1,
     MP4_LOG_WARNING = 2,
     MP4_LOG_INFO = 3,
     MP4_LOG_VERBOSE1 = 4,
     MP4_LOG_VERBOSE2 = 5,
     MP4_LOG_VERBOSE3 = 6,
     MP4_LOG_VERBOSE4 = 7
     }  MP4LogLevel;
  */

  switch(loglevel)
    {
    case MP4_LOG_ERROR:
      {
        TIZ_ERROR(handleOf(gp_prc), "%s", buffer);
      }
      break;
    case MP4_LOG_INFO:
      {
        TIZ_NOTICE(handleOf(gp_prc), "%s", buffer);
      }
      break;
    case MP4_LOG_WARNING:
      {
        TIZ_DEBUG(handleOf(gp_prc), "%s", buffer);
      }
      break;
    default:
      {
        TIZ_TRACE(handleOf(gp_prc), "%s", buffer);
      }
      break;
    };
}
コード例 #16
0
static bool
binaryport_check_tunnel_compat (const void * ap_obj,
                                OMX_PARAM_PORTDEFINITIONTYPE * ap_this_def,
                                OMX_PARAM_PORTDEFINITIONTYPE * ap_other_def)
{
  tiz_port_t * p_obj = (tiz_port_t *) ap_obj;

  assert (ap_this_def);
  assert (ap_other_def);

  if (ap_other_def->eDomain != ap_this_def->eDomain)
    {
      TIZ_ERROR (handleOf (ap_obj),
                 "port [%d] check_tunnel_compat : Different domain found [%d]",
                 p_obj->pid_, ap_other_def->eDomain);
      return false;
    }

  return true;
}
コード例 #17
0
static OMX_ERRORTYPE
demuxer_cfgport_GetConfig (const void * ap_obj, OMX_HANDLETYPE ap_hdl,
                           OMX_INDEXTYPE a_index, OMX_PTR ap_struct)
{
  tiz_demuxercfgport_t * p_obj = (tiz_demuxercfgport_t *) ap_obj;
  OMX_ERRORTYPE rc = OMX_ErrorNone;

  TIZ_TRACE (ap_hdl, "GetConfig [%s]...", tiz_idx_to_str (a_index));
  assert (p_obj);

  switch (a_index)
    {
      case OMX_IndexConfigTimePosition:
      case OMX_IndexConfigTimeSeekMode:
        {
          /* Only the processor knows about current position or seek mode. So
           lets get the processor to fill this info for us. */
          void * p_prc = tiz_get_prc (ap_hdl);
          assert (p_prc);
          if (OMX_ErrorNone
              != (rc = tiz_api_GetConfig (p_prc, ap_hdl, a_index, ap_struct)))
            {
              TIZ_ERROR (ap_hdl,
                         "[%s] : Error retrieving [%s] "
                         "from the processor",
                         tiz_err_to_str (rc), tiz_idx_to_str (a_index));
            }
        }
        break;

      default:
        {
          /* Delegate to the base port */
          rc = super_GetConfig (typeOf (ap_obj, "tizdemuxercfgport"), ap_obj,
                                ap_hdl, a_index, ap_struct);
        }
    };

  return rc;
}
コード例 #18
0
static OMX_ERRORTYPE
waitforresources_state_set (const void *ap_obj,
                            OMX_HANDLETYPE ap_hdl,
                            OMX_COMMANDTYPE a_cmd,
                            OMX_U32 a_param1, OMX_PTR ap_cmd_data)
{
  const tiz_waitforresources_t *p_obj = ap_obj;
  tiz_fsm_state_id_t new_state = EStateMax;
  OMX_ERRORTYPE omx_error = OMX_ErrorNone;

  assert (p_obj);
  assert (a_cmd == OMX_CommandStateSet);

  TIZ_TRACE (ap_hdl, "Requested transition to state [%s]...",
            tiz_fsm_state_to_str (a_param1));

  /* Only allowed transitions is OMX_StateLoaded. */
  switch (a_param1)
    {
    case OMX_StateLoaded:
      {
        new_state = (tiz_fsm_state_id_t)OMX_StateLoaded;
        break;
      }

    case OMX_StateWaitForResources:
      {
        return OMX_ErrorSameState;
      }

    default:
      {
        TIZ_ERROR (ap_hdl, "[OMX_ErrorIncorrectStateTransition] : ...");
        return OMX_ErrorIncorrectStateTransition;
      }

    };

  /* TODO:  make state transition effective here? */
  (void) new_state;
  /*   if (OMX_ErrorNone != */
  /*       (omx_error = tiz_fsm_set_state */
  /*        (tiz_get_fsm (ap_hdl), new_state))) */
  /*     { */
  /*       return omx_error; */
  /*     } */

  {
    void *p_prc = tiz_get_prc (ap_hdl);
    void *p_krn = tiz_get_krn (ap_hdl);

    /* First notify the kernel servant */
    if (OMX_ErrorNone != (omx_error = tiz_api_SendCommand (p_krn, ap_hdl,
                                                          a_cmd, a_param1,
                                                          ap_cmd_data)))
      {
        return omx_error;
      }

    /* Now notify the processor servant */
    if (OMX_ErrorNone != (omx_error = tiz_api_SendCommand (p_prc, ap_hdl,
                                                          a_cmd, a_param1,
                                                          ap_cmd_data)))
      {
        return omx_error;
      }

  }

  return omx_error;

}
コード例 #19
0
static OMX_ERRORTYPE httpsrc_port_SetParameter (const void *ap_obj,
                                                OMX_HANDLETYPE ap_hdl,
                                                OMX_INDEXTYPE a_index,
                                                OMX_PTR ap_struct)
{
  httpsrc_port_t *p_obj = (httpsrc_port_t *)ap_obj;
  OMX_ERRORTYPE rc = OMX_ErrorNone;

  assert (p_obj);

  TIZ_TRACE (ap_hdl, "[%s]...", tiz_idx_to_str (a_index));

  switch (a_index)
    {
    case OMX_IndexParamAudioMp3:
      {
        const OMX_AUDIO_PARAM_MP3TYPE *p_mp3type
          = (OMX_AUDIO_PARAM_MP3TYPE *) ap_struct;

        switch (p_mp3type->nSampleRate)
          {
          case 16000:           /* MPEG-2 */
          case 24000:           /* MPEG-2 */
          case 22050:           /* MPEG-2 */
          case 32000:           /* MPEG-1 */
          case 44100:           /* MPEG-1 */
          case 48000:           /* MPEG-1 */
            {
              break;
            }
          default:
            {
              TIZ_TRACE (ap_hdl,
                         "[%s] : OMX_ErrorBadParameter : "
                         "Sample rate not supported [%d]. "
                         "Returning...", tiz_idx_to_str (a_index),
                         p_mp3type->nSampleRate);
              rc = OMX_ErrorBadParameter;
            }
          };

        if (OMX_ErrorNone == rc)
          {
            /* Apply the new default values */
            p_obj->mp3type_.nChannels = p_mp3type->nChannels;
            p_obj->mp3type_.nBitRate = p_mp3type->nBitRate;
            p_obj->mp3type_.nSampleRate = p_mp3type->nSampleRate;
            p_obj->mp3type_.nAudioBandWidth = p_mp3type->nAudioBandWidth;
            p_obj->mp3type_.eChannelMode = p_mp3type->eChannelMode;
            p_obj->mp3type_.eFormat = p_mp3type->eFormat;
          }
      }
      break;

    case OMX_IndexParamAudioAac:
      {
        const OMX_AUDIO_PARAM_AACPROFILETYPE *p_aactype
          = (OMX_AUDIO_PARAM_AACPROFILETYPE *) ap_struct;

        switch (p_aactype->nSampleRate)
          {
          case 8000:
          case 11025:
          case 12000:
          case 16000:
          case 22050:
          case 24000:
          case 32000:
          case 44100:
          case 48000:
            {
              break;
            }
          default:
            {
              TIZ_TRACE (ap_hdl, "[%s] : OMX_ErrorBadParameter : "
                         "Sample rate not supported [%d]. "
                         "Returning...", tiz_idx_to_str (a_index),
                         p_aactype->nSampleRate);
              rc = OMX_ErrorBadParameter;
            }
          };

        if (OMX_ErrorNone == rc)
          {
            /* Apply the new default values */
            p_obj->aactype_.nChannels        = p_aactype->nChannels;
            p_obj->aactype_.nSampleRate      = p_aactype->nSampleRate;
            p_obj->aactype_.nBitRate         = p_aactype->nBitRate;
            p_obj->aactype_.nAudioBandWidth  = p_aactype->nAudioBandWidth;
            p_obj->aactype_.nFrameLength     = p_aactype->nFrameLength;
            p_obj->aactype_.nAACtools        = p_aactype->nAACtools;
            p_obj->aactype_.nAACERtools      = p_aactype->nAACERtools;
            p_obj->aactype_.eAACProfile      = p_aactype->eAACProfile;
            p_obj->aactype_.eAACStreamFormat = p_aactype->eAACStreamFormat;
            p_obj->aactype_.eChannelMode     = p_aactype->eChannelMode;
          }
      }
      break;

    default:
      {

        if (OMX_TizoniaIndexParamAudioOpus == a_index)
          {
            const OMX_TIZONIA_AUDIO_PARAM_OPUSTYPE *p_opustype
              = (OMX_TIZONIA_AUDIO_PARAM_OPUSTYPE *) ap_struct;

            switch (p_opustype->nSampleRate)
              {
              case 8000:
              case 16000:
              case 24000:
              case 22050:
              case 32000:
              case 44100:
              case 48000:
                {
                  break;
                }
              default:
                {
                  TIZ_ERROR (ap_hdl, "[%s] : OMX_ErrorBadParameter : "
                             "Sample rate not supported [%d]. "
                             "Returning...", tiz_idx_to_str (a_index),
                             p_opustype->nSampleRate);
                  rc = OMX_ErrorBadParameter;
                }
              };

            if (OMX_ErrorNone == rc)
              {
                /* Apply the new default values */
                p_obj->opustype_.nChannels               = p_opustype->nChannels;
                p_obj->opustype_.nBitRate                = p_opustype->nBitRate;
                p_obj->opustype_.nSampleRate             = p_opustype->nSampleRate;
                p_obj->opustype_.nFrameDuration          = p_opustype->nFrameDuration;
                p_obj->opustype_.nEncoderComplexity      = p_opustype->nEncoderComplexity;
                p_obj->opustype_.bPacketLossResilience   = p_opustype->bPacketLossResilience;
                p_obj->opustype_.bForwardErrorCorrection = p_opustype->bForwardErrorCorrection;
                p_obj->opustype_.bDtx                    = p_opustype->bDtx;
                p_obj->opustype_.eChannelMode            = p_opustype->eChannelMode;
                p_obj->opustype_.eFormat                 = p_opustype->eFormat;
              }
          }
        else
          {
            /* Try the parent's indexes */
            rc = super_SetParameter (typeOf (ap_obj, "httpsrcport"),
                                     ap_obj, ap_hdl, a_index, ap_struct);
          }
      }
    };
  return rc;
}
コード例 #20
0
static OMX_ERRORTYPE transform_buffer (vorbisd_prc_t *ap_prc)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  OMX_BUFFERHEADERTYPE *p_in
    = tiz_filter_prc_get_header
    (ap_prc, ARATELIA_VORBIS_DECODER_INPUT_PORT_INDEX);
  OMX_BUFFERHEADERTYPE *p_out
    = tiz_filter_prc_get_header
    (ap_prc, ARATELIA_VORBIS_DECODER_OUTPUT_PORT_INDEX);

  if (NULL == p_in || NULL == p_out)
    {
      TIZ_TRACE (handleOf (ap_prc), "IN HEADER [%p] OUT HEADER [%p]", p_in,
                 p_out);
      return OMX_ErrorNone;
    }

  assert (NULL != ap_prc);

  if (0 == p_in->nFilledLen)
    {
      TIZ_TRACE (handleOf (ap_prc), "HEADER [%p] nFlags [%d] is empty", p_in,
                 p_in->nFlags);
      if ((p_in->nFlags & OMX_BUFFERFLAG_EOS) > 0)
        {
          /* Inmediately propagate EOS flag to output */
          TIZ_TRACE (handleOf (ap_prc), "Let's propagate EOS flag to output");
          p_out->nFlags |= OMX_BUFFERFLAG_EOS;
          p_in->nFlags &= ~(1 << OMX_BUFFERFLAG_EOS);
          tiz_check_omx_err
            (tiz_filter_prc_release_header
            (ap_prc, ARATELIA_VORBIS_DECODER_OUTPUT_PORT_INDEX));
        }
    }

  if (p_in->nFilledLen > 0)
    {
      unsigned char *p_data = p_in->pBuffer + p_in->nOffset;
      const long len = p_in->nFilledLen;
      long bytes_consumed = fish_sound_decode (ap_prc->p_fsnd_, p_data, len);
      TIZ_TRACE (handleOf (ap_prc), "p_in->nFilledLen [%d] ", p_in->nFilledLen);
      TIZ_TRACE (handleOf (ap_prc), "bytes_consumed [%d] ", bytes_consumed);

      if (bytes_consumed >= 0)
        {
          assert (p_in->nFilledLen >= bytes_consumed);
          p_in->nFilledLen = 0;
          p_in->nOffset = 0;
        }
      else
        {
          switch (bytes_consumed)
            {
              case FISH_SOUND_STOP_ERR:
                {
                  /* Decoding was stopped by a FishSoundDecode* */
                  /* callback returning FISH_SOUND_STOP_ERR before any input
                   * bytes were consumed. */
                  /* This will occur when PCM is decoded from previously
                   * buffered input, and */
                  /* stopping is immediately requested. */
                  TIZ_ERROR (handleOf (ap_prc),
                             "[FISH_SOUND_ERR_STOP_ERR] : "
                             "While decoding the input stream.");
                  rc = OMX_ErrorStreamCorruptFatal;
                }
                break;
              case FISH_SOUND_ERR_OUT_OF_MEMORY:
                {
                  TIZ_ERROR (handleOf (ap_prc),
                             "[FISH_SOUND_ERR_OUT_OF_MEMORY] : "
                             "While decoding the input stream.");
                  rc = OMX_ErrorInsufficientResources;
                }
                break;
              case FISH_SOUND_ERR_BAD:
                {
                  TIZ_ERROR (handleOf (ap_prc),
                             "[FISH_SOUND_ERR_BAD] : "
                             "While decoding the input stream.");
                  rc = OMX_ErrorStreamCorruptFatal;
                }
                break;
              default:
                {
                  TIZ_ERROR (handleOf (ap_prc),
                             "[%s] : "
                             "While decoding the input stream.",
                             bytes_consumed);
                  assert (0);
                  rc = OMX_ErrorStreamCorruptFatal;
                }
            };
        }
    }

  assert (p_in->nFilledLen >= 0);

  if (0 == p_in->nFilledLen)
    {
      TIZ_TRACE (handleOf (ap_prc), "HEADER [%p] nFlags [%d] is empty", p_in,
                 p_in->nFlags);
      if ((p_in->nFlags & OMX_BUFFERFLAG_EOS) > 0)
        {
          /* Let's propagate EOS flag to output */
          TIZ_TRACE (handleOf (ap_prc), "Let's propagate EOS flag to output");
          tiz_filter_prc_update_eos_flag (ap_prc, true);
          p_in->nFlags &= ~(1 << OMX_BUFFERFLAG_EOS);
        }
      rc = tiz_filter_prc_release_header
        (ap_prc, ARATELIA_VORBIS_DECODER_INPUT_PORT_INDEX);
    }

  return rc;
}
コード例 #21
0
static int fishsound_decoded_callback (FishSound *ap_fsound, float *app_pcm[],
                                       long frames, void *ap_user_data)
{
  int rc = FISH_SOUND_CONTINUE;
  vorbisd_prc_t *p_prc = ap_user_data;
  OMX_BUFFERHEADERTYPE *p_out = NULL;

  (void)ap_fsound;
  assert (NULL != app_pcm);
  assert (NULL != ap_user_data);

  TIZ_TRACE (handleOf (p_prc), "frames [%d] ", frames);

  /* Possible return values are: */

  /* FISH_SOUND_CONTINUE Continue decoding */
  /* FISH_SOUND_STOP_OK Stop decoding immediately and return control to the
     fish_sound_decode() caller */
  /* FISH_SOUND_STOP_ERR Stop decoding immediately, purge buffered data, and
     return control to the fish_sound_decode() caller */

  if (!p_prc->started_)
    {
      p_prc->started_ = true;
      fish_sound_command (p_prc->p_fsnd_, FISH_SOUND_GET_INFO,
                          &(p_prc->fsinfo_), sizeof(FishSoundInfo));
      if (p_prc->fsinfo_.channels > 2 || p_prc->fsinfo_.format
                                         != FISH_SOUND_VORBIS)
        {
          TIZ_ERROR (handleOf (p_prc),
                     "Supported Vorbis "
                     "streams up tp 2 channels only.");
          rc = FISH_SOUND_STOP_ERR;
          goto end;
        }
      TIZ_NOTICE (handleOf (p_prc), "Channels [%d] sampling rate [%d]",
                  p_prc->fsinfo_.channels, p_prc->fsinfo_.samplerate);
    }

  p_out = tiz_filter_prc_get_header (p_prc, ARATELIA_VORBIS_DECODER_OUTPUT_PORT_INDEX);
  if (NULL == p_out)
    {
      TIZ_TRACE (handleOf (p_prc),
                 "No more output buffers "
                 "available at the moment");
      rc = FISH_SOUND_STOP_OK;
      goto end;
    }

  {
    /* write decoded PCM samples */
    size_t i = 0;
    size_t frame_len = sizeof(float) * p_prc->fsinfo_.channels;
    size_t frames_alloc = ((p_out->nAllocLen - p_out->nOffset) / frame_len);
    size_t frames_to_write = (frames > frames_alloc) ? frames_alloc : frames;
    size_t bytes_to_write = frames_to_write * frame_len;
    assert (NULL != p_out);

    for (i = 0; i < frames_to_write; ++i)
      {
        size_t frame_offset = i * frame_len;
        size_t float_offset = i * p_prc->fsinfo_.channels;
        float *out = (float *)(p_out->pBuffer + p_out->nOffset + frame_offset);
        write_frame_float_ilv (out, ((float *)app_pcm) + float_offset,
                               p_prc->fsinfo_.channels);
      }
    p_out->nFilledLen += bytes_to_write;
    p_out->nOffset += bytes_to_write;

    if (frames_to_write < frames)
      {
        /* Temporarily store the data until an omx buffer is
         * available */
        OMX_U32 nbytes_remaining = (frames - frames_to_write) * frame_len;
        TIZ_TRACE (handleOf (p_prc), "Need to store [%d] bytes",
                   nbytes_remaining);
        nbytes_remaining = store_data (
            p_prc, (OMX_U8 *)(app_pcm[frames_to_write * sizeof(float)]),
            nbytes_remaining);
      }

    if (tiz_filter_prc_is_eos (p_prc))
      {
        /* Propagate EOS flag to output */
        p_out->nFlags |= OMX_BUFFERFLAG_EOS;
        tiz_filter_prc_update_eos_flag (p_prc, false);
        TIZ_TRACE (handleOf (p_prc), "Propagating EOS flag to output");
      }
    /* TODO: Shouldn't ignore this rc */
    (void)tiz_filter_prc_release_header
      (p_prc, ARATELIA_VORBIS_DECODER_OUTPUT_PORT_INDEX);
    /* Let's process one input buffer at a time, for now */
    rc = FISH_SOUND_STOP_OK;
  }

end:

  return rc;
}