Exemplo n.º 1
0
void tiz_rcfile_destroy (tiz_rcfile_t *p_rc)
{
  keyval_t *p_kv_lst = NULL;
  keyval_t *p_kvt = NULL;
  value_t *p_val_lst = NULL;

  if (NULL == p_rc)
    {
      return;
    }

  p_kv_lst = p_rc->p_keyvals;
  while (p_kv_lst)
    {
      value_t *p_vt = NULL;
      TIZ_LOG (TIZ_PRIORITY_TRACE, "Deleting Key [%s]", p_kv_lst->p_key);
      tiz_mem_free (p_kv_lst->p_key);
      p_val_lst = p_kv_lst->p_value_list;
      while (p_val_lst)
        {
          TIZ_LOG (TIZ_PRIORITY_TRACE, "Deleting Val [%s]", p_val_lst->p_value);
          p_vt = p_val_lst;
          p_val_lst = p_val_lst->p_next;
          tiz_mem_free (p_vt->p_value);
          tiz_mem_free (p_vt);
        }
      p_kvt = p_kv_lst;
      p_kv_lst = p_kv_lst->p_next;
      tiz_mem_free (p_kvt);
    }

  tiz_mem_free (p_rc);
}
Exemplo n.º 2
0
END_TEST
START_TEST (test_ilcore_init_and_deinit_get_hdl_free_hdl)
{
  OMX_ERRORTYPE error = OMX_ErrorNone;
  OMX_HANDLETYPE p_hdl = NULL;
  OMX_U32 appData;
  OMX_CALLBACKTYPE callBacks;

  error = OMX_Init ();
  fail_if (error != OMX_ErrorNone);

  error = OMX_GetHandle (&p_hdl,
                         TIZ_CORE_TEST_COMPONENT_NAME,
                         (OMX_PTR *) (&appData), &callBacks);
  TIZ_LOG (TIZ_PRIORITY_TRACE, "OMX_GetHandle error [%s]", tiz_err_to_str (error));
  fail_if (error != OMX_ErrorNone);

  TIZ_LOG (TIZ_PRIORITY_TRACE, "p_hdl [%p]", p_hdl);

  error = OMX_FreeHandle (p_hdl);
  fail_if (error != OMX_ErrorNone);

  error = OMX_Deinit ();
  fail_if (error != OMX_ErrorNone);
}
OMX_ERRORTYPE
graph::gmusicops::set_channels_and_rate_on_decoder (
    const OMX_U32 channels, const OMX_U32 sampling_rate)
{
  const OMX_HANDLETYPE handle = handles_[1];  // decoder's handle
  const OMX_U32 port_id = 0;                  // decoder's input port

  TIZ_LOG (TIZ_PRIORITY_TRACE, "channels = [%d] sampling_rate = [%d]", channels,
           sampling_rate);

  // Retrieve the mp3 settings from the decoder component
  TIZ_INIT_OMX_PORT_STRUCT (decoder_mp3type_, port_id);
  tiz_check_omx (
      OMX_GetParameter (handle, OMX_IndexParamAudioMp3, &decoder_mp3type_));

  TIZ_LOG (TIZ_PRIORITY_TRACE, "channels = [%d] sampling_rate = [%d]", channels,
           sampling_rate);

  // Now assign the actual settings to the pcmtype structure
  decoder_mp3type_.nChannels = channels;
  decoder_mp3type_.nSampleRate = sampling_rate;

  // Set the new mp3 settings
  tiz_check_omx (
      OMX_SetParameter (handle, OMX_IndexParamAudioMp3, &decoder_mp3type_));

  TIZ_LOG (TIZ_PRIORITY_TRACE, "channels = [%d] sampling_rate = [%d]", channels,
           sampling_rate);

  return OMX_ErrorNone;
}
Exemplo n.º 4
0
END_TEST

START_TEST (test_vector_push_back_vector)
{
  OMX_U32 i = 0;
  OMX_ERRORTYPE error = OMX_ErrorNone;
  int *p_item = NULL;
  tiz_vector_t *p_vector = NULL;
  tiz_vector_t *p_vector2 = NULL;

  TIZ_LOG (TIZ_PRIORITY_TRACE, "test_vector_push_back_vector");

  error = tiz_vector_init (&p_vector, sizeof(int*));
  error = tiz_vector_init (&p_vector2, sizeof(tiz_vector_t*));

  fail_if (error != OMX_ErrorNone);

  for (i = 0; i < 10; i++)
    {
      p_item = (int *) tiz_mem_alloc (sizeof (int));
      fail_if (p_item == NULL);
      *p_item = i;

      error = tiz_vector_push_back (p_vector, &p_item);
      fail_if (error != OMX_ErrorNone);

      p_item = *(int **) tiz_vector_back (p_vector);
      fail_if (*p_item != i);
    }

  TIZ_LOG (TIZ_PRIORITY_TRACE, "vector length %d",
             tiz_vector_length (p_vector));
  fail_if (10 != tiz_vector_length (p_vector));


  TIZ_LOG (TIZ_PRIORITY_TRACE, "pushing vector [%p] [%p]", p_vector, &p_vector);

  tiz_vector_push_back (p_vector2, &p_vector);
  p_vector = *(tiz_vector_t **) tiz_vector_back (p_vector2);

  TIZ_LOG (TIZ_PRIORITY_TRACE, "received vector [%p] [%p] [%p]",
           p_vector, &p_vector, *(tiz_vector_t **) p_vector);

  for (i = 0; i < 10; i++)
    {
      fail_if (10 - i != tiz_vector_length (p_vector));

      p_item = * (int **) tiz_vector_back (p_vector);
      fail_if (*p_item != 10 - i - 1);

      TIZ_LOG (TIZ_PRIORITY_TRACE, "received int [%d]", *p_item);

      tiz_vector_pop_back (p_vector);
      tiz_mem_free(p_item);
    }

  fail_if (0 != tiz_vector_length (p_vector));

  tiz_vector_destroy (p_vector);
}
Exemplo n.º 5
0
void tiz::playlist::skip (const int jump)
{
  const int list_size = uri_list_.size ();
  TIZ_LOG (TIZ_PRIORITY_TRACE,
           "jump [%d] current_index_ [%d]"
           " loop_playback [%s]",
           jump, current_index_, loop_playback_ ? "YES" : "NO");
  current_index_ += jump;

  if (loop_playback ())
  {
    if (current_index_ < 0)
    {
      current_index_ = list_size - abs (current_index_);
    }
    else if (current_index_ >= list_size)
    {
      current_index_ %= list_size;
    }
  }

  TIZ_LOG (TIZ_PRIORITY_TRACE, "jump [%d] new index [%d]... [%s]", jump,
           current_index_, current_index_ < list_size && current_index_ >= 0
                               ? uri_list_[current_index_].c_str ()
                               : "");
}
Exemplo n.º 6
0
static bool
refresh_rm_db (void)
{
  bool rv = false;

  /* Re-fresh the rm db */
  size_t total_len = strlen (pg_init_script)
    + strlen (pg_sqlite_script)
    + strlen (pg_rmdb_path) + 4;
  char *p_cmd = tiz_mem_calloc (1, total_len);

  if (p_cmd)
    {
      snprintf(p_cmd, total_len -1, "%s %s %s",
               pg_init_script, pg_sqlite_script, pg_rmdb_path);
      if (-1 != system (p_cmd))
        {
          TIZ_LOG(TIZ_TRACE, "Successfully run [%s] script...", p_cmd);
          rv = true;
        }
      else
        {
          TIZ_LOG(TIZ_TRACE,
                  "Error while executing db init shell script...");
        }
      tiz_mem_free (p_cmd);
    }

  return rv;
}
OMX_ERRORTYPE
graph::youtubeops::add_demuxer_to_component_list (
    omx_comp_name_lst_t &comp_list, omx_comp_role_lst_t &role_list)
{
  OMX_ERRORTYPE rc = OMX_ErrorFormatNotDetected;
  if (OMX_AUDIO_CodingWEBM == container_)
  {
    comp_list.push_back ("OMX.Aratelia.container_demuxer.webm");
    role_list.push_back ("container_demuxer.filter.webm");
    rc = OMX_ErrorNone;
  }
  else if (OMX_AUDIO_CodingMP4 == container_)
  {
    // TODO
    TIZ_LOG (TIZ_PRIORITY_ERROR,
             "[OMX_ErrorFormatNotDetected] : Unhandled container format "
             "[OMX_AUDIO_CodingMP4].");
  }
  else if (OMX_AUDIO_CodingOGA == container_)
  {
    // TODO
    TIZ_LOG (TIZ_PRIORITY_ERROR,
             "[OMX_ErrorFormatNotDetected] : Unhandled container format "
             "[OMX_AUDIO_CodingOGA].");
  }
  else
  {
    TIZ_LOG (
        TIZ_PRIORITY_ERROR,
        "[OMX_ErrorFormatNotDetected] : Unhandled container format [%d]...",
        container_);
  }
  return rc;
}
Exemplo n.º 8
0
bool tizrmdb::comp_provisioned_with_resid (const std::string &cname,
                                           const unsigned int &rid) const
{
  bool ret_val = false;
  int rc = SQLITE_OK;
  char query[255];

  TIZ_LOG (TIZ_PRIORITY_TRACE,
           "tizrmdb::comp_provisioned_with_resid : "
           "'%s' : Checking component provisioning for "
           "resource id [%d]",
           cname.c_str (), rid);

  snprintf (query, sizeof(query),
            "select * from components where cname='%s' and resid=%d",
            cname.c_str (), rid);

  rc = run_query (query);

  if (SQLITE_OK == rc && !vdata_.empty ())
  {
    ret_val = true;
  }

  TIZ_LOG (TIZ_PRIORITY_TRACE, "'%s' : is [%s] with resource id [%d]",
           cname.c_str (),
           (true == ret_val ? "PROVISIONED" : "NOT PROVISIONED"), rid);

  return ret_val;
}
Exemplo n.º 9
0
tiz_rm_error_t tizrmdb::connect ()
{
  tiz_rm_error_t ret_val = TIZ_RM_SUCCESS;

  if (!dbname_.empty ())
  {
    int rc = open (dbname_.c_str ());
    TIZ_LOG (TIZ_PRIORITY_TRACE, "Opening db [%s]", dbname_.c_str ());
    if (rc != SQLITE_OK)
    {
      TIZ_LOG (TIZ_PRIORITY_TRACE, "Could not open db [%s]",
               dbname_.c_str ());
      ret_val = TIZ_RM_DATABASE_OPEN_ERROR;
    }
    else
    {
      rc = reset_alloc_table ();
      if (rc != SQLITE_OK)
      {
        TIZ_LOG (TIZ_PRIORITY_TRACE, "Could not init db [%s]",
                 dbname_.c_str ());
        ret_val = TIZ_RM_DATABASE_INIT_ERROR;
      }
    }
  }
  else
  {
    TIZ_LOG (TIZ_PRIORITY_TRACE, "Empty db name");
    ret_val = TIZ_RM_DATABASE_OPEN_ERROR;
  }

  return ret_val;
}
Exemplo n.º 10
0
bool tizrmdb::resource_available (const unsigned int &rid,
                                  const unsigned int &quantity) const
{
  bool ret_val = false;
  int rc = SQLITE_OK;
  char query[255];

  TIZ_LOG (TIZ_PRIORITY_TRACE,
           "tizrmdb::resource_available : Checking resource "
           " availability for resid [%d] - quantity [%d]",
           rid, quantity);

  snprintf (query, sizeof(query),
            "select * from resources where resid='%d' and current>='%d'", rid,
            quantity);

  rc = run_query (query);

  if (SQLITE_OK == rc && !vdata_.empty ())
  {
    TIZ_LOG (TIZ_PRIORITY_TRACE,
             "tizrmdb::resource_available : "
             "Enough resource id [%d] available",
             rid);
    ret_val = true;
  }

  return ret_val;
}
Exemplo n.º 11
0
bool tizrmdb::comp_provisioned (const std::string &cname) const
{
  bool ret_val = false;
  int rc = SQLITE_OK;

  TIZ_LOG (TIZ_PRIORITY_TRACE, "tizrmdb::comp_provisioned : Checking [%s]",
           cname.c_str ());

  rc = run_query (TIZ_RM_DB_CNAMES_FROM_COMPONENTS);

  if (SQLITE_OK == rc)
  {
    for (std::vector< std::string >::iterator it = vdata_.begin ();
         it < vdata_.end (); ++it)
    {
      if (cname.compare (*it) == 0)
      {
        ret_val = true;
      }
    }
  }

  TIZ_LOG (TIZ_PRIORITY_TRACE, "'%s' is [%s]", cname.c_str (),
           (true == ret_val ? "PROVISIONED" : "NOT PROVISIONED"));

  return ret_val;
}
Exemplo n.º 12
0
static void
setup (void)
{
  pg_rmdb_path = strndup (tiz_rcfile_get_value("resource-management", "rmdb"),
                          PATH_MAX);
  pg_sqlite_script = strndup (tiz_rcfile_get_value("resource-management",
                                                   "rmdb.sqlite_script"),
                              PATH_MAX);
  pg_init_script = strndup (tiz_rcfile_get_value("resource-management",
                                                "rmdb.init_script"),
                           PATH_MAX);
  pg_rmd_path = strndup (tiz_rcfile_get_value("resource-management",
                                             "rmd.path"),
                        PATH_MAX);
  pg_dump_script = strndup (tiz_rcfile_get_value("resource-management",
                                                "rmdb.dbdump_script"),
                           PATH_MAX);

  if (!pg_rmdb_path || !pg_sqlite_script
      || !pg_init_script || !pg_rmd_path || !pg_dump_script)
    {
      TIZ_LOG(TIZ_TRACE, "Test data not available...");
      fail_if(0);
    }
  else
    {
      TIZ_LOG(TIZ_TRACE, "RM daemon [%s] ...", pg_rmd_path);
    }

}
Exemplo n.º 13
0
int tizrmdb::reset_alloc_table ()
{
  int rc = SQLITE_OK;
  char *p_errmsg;

  // Drop allocation table
  if (pdb_)
  {
    rc = sqlite3_exec (pdb_, TIZ_RM_DB_DROP_ALLOC_TABLE, NULL, NULL, &p_errmsg);
    TIZ_LOG (TIZ_PRIORITY_TRACE, "Dropping allocation table...");
    if (rc != SQLITE_OK)
    {
      TIZ_LOG (TIZ_PRIORITY_TRACE, "Could not drop allocation table [%s]",
               p_errmsg);
    }

    rc = sqlite3_exec (pdb_, TIZ_RM_DB_CREATE_ALLOC_TABLE, NULL, NULL,
                       &p_errmsg);
    if (rc != SQLITE_OK)
    {
      TIZ_LOG (TIZ_PRIORITY_TRACE, "Could not create allocation table [%s]",
               p_errmsg);
      return rc;
    }
    TIZ_LOG (TIZ_PRIORITY_TRACE, "Created allocation table succesfully");
  }

  return rc;
}
Exemplo n.º 14
0
static bool
dump_rmdb (const char * p_dest_path)
{
  bool rv = false;

  /* Dump the rm db */
  size_t total_len = strlen (pg_dump_script)
    + strlen (pg_rmdb_path)
    + strlen (p_dest_path) + 4;
  char *p_cmd = tiz_mem_calloc (1, total_len);

  if (p_cmd)
    {
      snprintf(p_cmd, total_len -1, "%s %s %s",
               pg_dump_script, pg_rmdb_path, p_dest_path);
      if (-1 != system (p_cmd))
        {
          TIZ_LOG(TIZ_TRACE, "Successfully run [%s] script...", p_cmd);
          rv = true;
        }
      else
        {
          TIZ_LOG(TIZ_TRACE,
                  "Error while executing db dump shell script...");
        }
      tiz_mem_free (p_cmd);
    }

  return rv;
}
Exemplo n.º 15
0
static OMX_ERRORTYPE
ComponentRoleEnum (OMX_HANDLETYPE ap_hdl, OMX_U8 * a_role, OMX_U32 a_index)
{

  OMX_ERRORTYPE ret_val = OMX_ErrorNone;
  TIZ_LOG (TIZ_PRIORITY_TRACE, "ComponentRoleEnum : a_index [%d]", a_index);

  if (!a_role)
    {
      TIZ_LOG (TIZ_PRIORITY_TRACE, "ComponentRoleEnum: "
               "NULL a_role pointer found.");
      return OMX_ErrorBadParameter;
    }

  if (0 == a_index)
    {
      strcpy ((char *) a_role, TIZ_CORE_TEST_COMPONENT_ROLE);
      ret_val = OMX_ErrorNone;
    }
  else
    {
      ret_val = OMX_ErrorNoMore;
    }

  return ret_val;

}
Exemplo n.º 16
0
static bool
init_test_data()
{
  bool rv = false;
  const char *p_testfile1 = NULL;
  const char *p_testfile2 = NULL;

  p_testfile1 = tiz_rcfile_get_value("plugins-data",
                                     "OMX.Aratelia.file_writer.binary.testfile1_uri");
  p_testfile2 = tiz_rcfile_get_value("plugins-data",
                                     "OMX.Aratelia.file_writer.binary.testfile2_uri");

  if (!p_testfile1 || !p_testfile1)

    {
      TIZ_LOG(TIZ_TRACE, "Test data not available...");
    }
  else
    {
      pg_files[0] = p_testfile1; pg_files[1] = p_testfile2;
      TIZ_LOG(TIZ_TRACE, "Test data available [%s]", pg_files[0]);
      TIZ_LOG(TIZ_TRACE, "Test data available [%s]", pg_files[1]);
      rv = true;
    }

  return rv;
}
Exemplo n.º 17
0
static keyval_t *find_node (const tiz_rcfile_t *ap_rc, const char *key)
{
  keyval_t *p_kvs = NULL;

  assert (NULL != ap_rc);
  assert (NULL != key);

  p_kvs = ap_rc->p_keyvals;

  TIZ_LOG (TIZ_PRIORITY_TRACE, "Looking for Key [%s]", key);

  while (p_kvs && p_kvs->p_key)
    {
      /* TODO: strncmp here */
      if (0 == strcmp (p_kvs->p_key, key))
        {
          TIZ_LOG (TIZ_PRIORITY_TRACE, "Found Key [%s]", p_kvs->p_key);
          return p_kvs;
        }
      p_kvs = p_kvs->p_next;
    }

  TIZ_LOG (TIZ_PRIORITY_TRACE, "Key not found [%s] [%p]", key, p_kvs);
  return NULL;
}
bool graph::oggopusdecoder::dispatch_cmd (const tiz::graph::cmd *p_cmd)
{
  assert (NULL != p_cmd);

  if (!p_cmd->kill_thread ())
  {
    if (p_cmd->evt ().type () == typeid(tiz::graph::load_evt))
    {
      // Time to start the FSM
      TIZ_LOG (TIZ_PRIORITY_NOTICE, "Starting [%s] fsm...",
               get_graph_name ().c_str ());
      fsm_.start ();
    }

    p_cmd->inject< fsm >(fsm_, tiz::graph::pstate);

    // Check for internal errors produced during the processing of the last
    // event. If any, inject an "internal" error event. This is fatal and shall
    // terminate the state machine.
    if (OMX_ErrorNone != p_ops_->internal_error ())
    {
      fsm_.process_event (tiz::graph::err_evt (p_ops_->internal_error (),
                                               p_ops_->internal_error_msg ()));
    }

    if (fsm_.terminated_)
    {
      TIZ_LOG (TIZ_PRIORITY_NOTICE, "[%s] fsm terminated...",
               get_graph_name ().c_str ());
    }
  }

  return p_cmd->kill_thread ();
}
Exemplo n.º 19
0
static OMX_ERRORTYPE
pause_SetParameter (const void *ap_obj,
                    OMX_HANDLETYPE ap_hdl,
                    OMX_INDEXTYPE a_index, OMX_PTR a_struct)
{
  const void *p_krn = tiz_get_krn (ap_hdl);
  OMX_PTR p_port = NULL;
  OMX_ERRORTYPE rc = OMX_ErrorNone;

  /* TODO: Optimization: find_managing_port is called twice, first time here,
   * then in the SetParameter implementation of the kernel object. */
  if (OMX_ErrorNone
      != (rc =
          tiz_krn_find_managing_port (p_krn, a_index, a_struct, &p_port)))
    {
      TIZ_LOG (TIZ_TRACE, "Cannot retrieve managing port (%s)...",
               tiz_err_to_str (rc));
      return rc;
    }

  assert (p_port);

  if (TIZ_PORT_IS_CONFIG_PORT (p_port)
      || (!TIZ_PORT_IS_CONFIG_PORT (p_port) && TIZ_PORT_IS_ENABLED (p_port)))
    {
      TIZ_LOG (TIZ_TRACE, "Incorrect state op "
               "(SetParameter received in Pause state)...");
      return OMX_ErrorIncorrectStateOperation;
    }

  return tiz_api_SetParameter (p_krn, ap_hdl, a_index, a_struct);

}
Exemplo n.º 20
0
void tizrmdb::print_query_result () const
{
  TIZ_LOG (TIZ_PRIORITY_TRACE,
           "tizrmdb::print_query_result : vdata_.size() [%d]"
           " vcol_head_.size() [%d]",
           vdata_.size (), vcol_head_.size ());

  if (!vcol_head_.empty ())
  {
    int headingsize = vcol_head_.size ();
    std::stringstream headings;
    for (int i = 0; i < headingsize; ++i)
    {
      headings << "[" << vcol_head_[i] << "] \t\t\t ";
    }
    TIZ_LOG (TIZ_PRIORITY_TRACE, "%s", headings.str ().c_str ());

    int datasize = vdata_.size ();
    std::stringstream data;
    for (int i = 0; i < datasize; ++i)
    {
      data << "[" << vdata_[i] << "] \t\t ";
    }
    TIZ_LOG (TIZ_PRIORITY_TRACE, "%s", data.str ().c_str ());
  }
}
Exemplo n.º 21
0
END_TEST

START_TEST (test_pqueue_removep)
{

  OMX_S32 i;
  OMX_ERRORTYPE error = OMX_ErrorNone;
  tiz_pqueue_t *p_queue = NULL;
  OMX_PTR p_received = NULL;
  int *p_item = NULL;
  int *p_item_cat_one = NULL;

  TIZ_LOG (TIZ_TRACE, "test_pqueue_removep");

  error = tiz_pqueue_init (&p_queue, 2, &pqueue_cmp, NULL, "tizkrn");

  fail_if (error != OMX_ErrorNone);

  error = tiz_pqueue_first (p_queue, &p_received);

  fail_if (error != OMX_ErrorNoMore);

  for (i = 2; i >= 0; i--)
    {
      p_item = (int *) tiz_mem_alloc (sizeof (int));
      fail_if (p_item == NULL);
      *p_item = i;
      error = tiz_pqueue_send (p_queue, p_item, i);
      fail_if (error != OMX_ErrorNone);
      if (1 == i)
        {
          p_item_cat_one = p_item;
        }
    }

  tiz_pqueue_dump (p_queue, &pqueue_dump_item);

  error = tiz_pqueue_removep (p_queue, p_item_cat_one, 1);
  fail_if (error != OMX_ErrorNone);
  fail_if (tiz_pqueue_length (p_queue) != 2);

  tiz_pqueue_dump (p_queue, &pqueue_dump_item);

  for (i = 0; i < 2; i++)
    {
      error = tiz_pqueue_receive (p_queue, &p_received);
      fail_if (error != OMX_ErrorNone);
      p_item = (int *) p_received;
      TIZ_LOG (TIZ_TRACE, "*p_item [%d]", *p_item);
      if (0 == i)
        fail_if (*p_item != 0);
      if (1 == i)
        fail_if (*p_item != 2);
      tiz_mem_free (p_received);
    }

  tiz_pqueue_destroy (p_queue);

}
Exemplo n.º 22
0
END_TEST

START_TEST (test_pqueue_send_and_receive_one_group)
{
  OMX_U32 i;
  OMX_PTR p_received = NULL;
  OMX_ERRORTYPE error = OMX_ErrorNone;
  int *p_item = NULL;
  tiz_pqueue_t *p_queue = NULL;
  tiz_soa_t *p_soa = NULL;

  TIZ_LOG (TIZ_TRACE, "test_pqueue_send_and_receive_one_group");

  fail_if (tiz_soa_init (&p_soa) != OMX_ErrorNone);

  error = tiz_pqueue_init (&p_queue, 0, &pqueue_cmp, p_soa, "tizkrn");

  fail_if (error != OMX_ErrorNone);

  for (i = 0; i < 10; i++)
    {
      p_item = (int *) tiz_mem_alloc (sizeof (int));
      fail_if (p_item == NULL);
      *p_item = i;
      error = tiz_pqueue_send (p_queue, p_item, 0);
      fail_if (error != OMX_ErrorNone);
    }

  TIZ_LOG (TIZ_TRACE, "queue length %d",
             tiz_pqueue_length (p_queue));
  fail_if (10 != tiz_pqueue_length (p_queue));

  for (i = 0; i <= 10; i++)
    {
      error = tiz_pqueue_receive (p_queue, &p_received);
      if (i > 9)
        {
          fail_if (error != OMX_ErrorNoMore);
        }
      else
        {
          fail_if (error != OMX_ErrorNone);
        }

      fail_if (p_received == NULL);
      p_item = (int *) p_received;
      if (i < 9)
        {
          TIZ_LOG (TIZ_TRACE, "item [%d]", *p_item);
          fail_if (*p_item != i);
          tiz_mem_free (p_received);
        }
    }

  tiz_pqueue_destroy (p_queue);
  tiz_soa_destroy (p_soa);
}
OMX_ERRORTYPE
graph::youtubeops::get_channels_and_rate_from_decoder (
    OMX_U32 &channels, OMX_U32 &sampling_rate, std::string &encoding_str) const
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  const OMX_HANDLETYPE handle = handles_[2];  // decoder's handle
  const OMX_U32 port_id = 1;                  // decoder's output port

  switch (encoding_)
  {
    case OMX_AUDIO_CodingMP3:
    {
      encoding_str = "mp3";
    }
    break;
    case OMX_AUDIO_CodingAAC:
    {
      encoding_str = "aac";
    }
    break;
    case OMX_AUDIO_CodingVORBIS:
    {
      encoding_str = "vorbis";
    }
    break;
    default:
    {
      if (OMX_AUDIO_CodingOPUS == encoding_)
      {
        encoding_str = "opus";
      }
      else if (OMX_AUDIO_CodingFLAC == encoding_)
      {
        encoding_str = "flac";
      }
      else
      {
        TIZ_LOG (
            TIZ_PRIORITY_ERROR,
            "[OMX_ErrorFormatNotDetected] : Unhandled encoding type [%d]...",
            encoding_);
        rc = OMX_ErrorFormatNotDetected;
      }
    }
    break;
  };

  if (OMX_ErrorNone == rc)
  {
    rc = tiz::graph::util::
        get_channels_and_rate_from_audio_port_v2< OMX_AUDIO_PARAM_PCMMODETYPE > (
            handle, port_id, OMX_IndexParamAudioPcm, channels, sampling_rate);
  }
  TIZ_LOG (TIZ_PRIORITY_TRACE, "outcome = [%s]", tiz_err_to_str (rc));

  return rc;
}
Exemplo n.º 24
0
OMX_ERRORTYPE
check_EventHandler (OMX_HANDLETYPE ap_hdl,
                    OMX_PTR ap_app_data,
                    OMX_EVENTTYPE eEvent,
                    OMX_U32 nData1, OMX_U32 nData2, OMX_PTR pEventData)
{
  check_common_context_t *p_ctx = NULL;
  cc_ctx_t *pp_ctx = NULL;
  assert (ap_app_data);
  pp_ctx = (cc_ctx_t *) ap_app_data;
  p_ctx = *pp_ctx;

  TIZ_LOG (TIZ_TRACE, "Component Event [%s]",
             tiz_evt_to_str (eEvent));

  if (OMX_EventCmdComplete == eEvent)
    {
      switch ((OMX_COMMANDTYPE) (nData1))
        {
        case OMX_CommandStateSet:
          {
            TIZ_LOG (TIZ_TRACE, "Component transitioned to [%s]",
                       tiz_state_to_str ((OMX_STATETYPE) (nData2)));
            p_ctx->state = (OMX_STATETYPE) (nData2);
            _ctx_signal (pp_ctx);
            break;
          }

        case OMX_CommandPortDisable:
        case OMX_CommandPortEnable:
        default:
          {
            assert (0);
          }

        };
    }

  if (OMX_EventBufferFlag == eEvent)
    {
      if (nData2 & OMX_BUFFERFLAG_EOS)
        {
          TIZ_LOG (TIZ_TRACE, "Received EOS from [%s] port[%i]",
                     TIZ_FILE_WRITER_COMPONENT_NAME, nData1);
        }
      else
        {
          fail_if (0);
        }
    }

  return OMX_ErrorNone;

}
static bool
refresh_rm_db (void)
{
  bool rv = false;
  const char *p_rmdb_path = NULL;
  const char *p_sqlite_path = NULL;
  const char *p_init_path = NULL;
  const char *p_rmd_path = NULL;

  p_rmdb_path = tiz_rcfile_get_value("resource-management", "rmdb");
  p_sqlite_path = tiz_rcfile_get_value("resource-management",
                                       "rmdb.sqlite_script");
  p_init_path = tiz_rcfile_get_value("resource-management",
                                     "rmdb.init_script");

  p_rmd_path = tiz_rcfile_get_value("resource-management", "rmd.path");

  if (!p_rmdb_path || !p_sqlite_path || !p_init_path || !p_rmd_path)

    {
      TIZ_LOG(TIZ_PRIORITY_TRACE, "Test data not available...");
    }
  else
    {
      pg_rmd_path = strndup (p_rmd_path, PATH_MAX);

      TIZ_LOG(TIZ_PRIORITY_TRACE, "RM daemon [%s] ...", pg_rmd_path);

      /* Re-fresh the rm db */
      size_t total_len = strlen (p_init_path)
        + strlen (p_sqlite_path)
        + strlen (p_rmdb_path) + 4;
      char *p_cmd = tiz_mem_calloc (1, total_len);
      if (p_cmd)
        {
          snprintf(p_cmd, total_len -1, "%s %s %s",
                  p_init_path, p_sqlite_path, p_rmdb_path);
          if (-1 != system (p_cmd))
            {
              TIZ_LOG(TIZ_PRIORITY_TRACE, "Successfully run [%s] script...", p_cmd);
              rv = true;
            }
          else
            {
              TIZ_LOG(TIZ_PRIORITY_TRACE, 
                      "Error while executing db init shell script...");
            }
          tiz_mem_free (p_cmd);
        }
    }

  return rv;
}
Exemplo n.º 26
0
pid_t
check_tizrmproxy_find_proc (const char *name)
{
  DIR *dir;
  struct dirent *ent;
  char *endptr;
  char buf[512];

  if (!(dir = opendir ("/proc")))
    {
      TIZ_LOG (TIZ_TRACE, "Could not open /proc");
      return -1;
    }

  while ((ent = readdir (dir)) != NULL)
    {
      /* if endptr is not a null character, the directory is not
       * entirely numeric, so ignore it */
      long lpid = strtol (ent->d_name, &endptr, 10);
      if (*endptr != '\0')
        {
          continue;
        }

      /* try to open the cmdline file */
      snprintf (buf, sizeof (buf), "/proc/%ld/cmdline", lpid);
      FILE *fp = fopen (buf, "r");

      if (fp)
        {
          if (fgets (buf, sizeof (buf), fp) != NULL)
            {
              /* check the first token in the file, the program name */
              char *first = strtok (buf, " ");
              TIZ_LOG (TIZ_TRACE, "buf [%s]", buf);
              if (first && strstr (first, name))
                {
                  fclose (fp);
                  closedir (dir);
                  TIZ_LOG (TIZ_TRACE, "Found process [%s] --> PID [%d]",
                             name, lpid);
                  return (pid_t) lpid;
                }
            }
          fclose (fp);
        }
    }

  TIZ_LOG (TIZ_TRACE, "Process [%s] NOT FOUND", name);

  closedir (dir);
  return -1;
}
Exemplo n.º 27
0
 void on_entry (Event const &evt, FSM &fsm)
 {
   TIZ_LOG (TIZ_PRIORITY_TRACE, "ack unload");
   if (!fsm.terminated_)
   {
     if (fsm.pp_ops_ && *(fsm.pp_ops_))
     {
       (*(fsm.pp_ops_))->do_ack_unloaded ();
     }
     TIZ_LOG (TIZ_PRIORITY_TRACE, "terminating");
     fsm.terminated_ = true;
   }
 }
Exemplo n.º 28
0
static OMX_ERRORTYPE
fr_proc_allocate_resources (void *ap_obj, OMX_U32 a_pid)
{
  fr_prc_t *p_obj = ap_obj;
  const tiz_srv_t *p_parent = ap_obj;
  OMX_ERRORTYPE ret_val = OMX_ErrorNone;
  void *p_krn = tiz_get_krn (p_parent->p_hdl_);

  assert (ap_obj);

  if (!(p_obj->p_uri_param_))
    {
      p_obj->p_uri_param_ = tiz_mem_calloc
        (1, sizeof (OMX_PARAM_CONTENTURITYPE) + OMX_MAX_STRINGNAME_SIZE);

      if (NULL == p_obj->p_uri_param_)
        {
          TIZ_LOG (TIZ_ERROR, "Error allocating memory "
                   "for the content uri struct");
          return OMX_ErrorInsufficientResources;
        }

      p_obj->p_uri_param_->nSize = sizeof (OMX_PARAM_CONTENTURITYPE)
        + OMX_MAX_STRINGNAME_SIZE - 1;
      p_obj->p_uri_param_->nVersion.nVersion = OMX_VERSION;
    }

  if (OMX_ErrorNone != (ret_val = tiz_api_GetParameter
                        (p_krn,
                         p_parent->p_hdl_,
                         OMX_IndexParamContentURI, p_obj->p_uri_param_)))
    {
      TIZ_LOG (TIZ_ERROR, "Error retrieving URI param from port");
      return ret_val;
    }

  TIZ_LOG (TIZ_NOTICE, "Retrieved URI [%s]",
           p_obj->p_uri_param_->contentURI);

  if ((p_obj->p_file_
       = fopen ((const char *) p_obj->p_uri_param_->contentURI, "r")) == 0)
    {
      TIZ_LOG (TIZ_ERROR, "Error opening file from  URI string");
      return OMX_ErrorInsufficientResources;
    }

  return OMX_ErrorNone;
}
Exemplo n.º 29
0
bool graph::ops::is_trans_complete (const OMX_HANDLETYPE handle,
                                    const OMX_STATETYPE to_state)
{
  bool rc = false;

  assert (std::find (handles_.begin (), handles_.end (), handle)
          != handles_.end ());
  assert (to_state <= OMX_StateWaitForResources);

  TIZ_LOG (TIZ_PRIORITY_TRACE,
           "[%s] to_state [%s] expected transitions [%d] handles [%d]...",
           handle2name (handle).c_str (), tiz_state_to_str (to_state),
           expected_transitions_lst_.size (), handles_.size ());

  if (!handles_.empty () && !expected_transitions_lst_.empty ())
  {
    omx_event_info_lst_t::iterator it = std::find (
        expected_transitions_lst_.begin (), expected_transitions_lst_.end (),
        omx_event_info (handle, to_state, OMX_ErrorNone));

    if (expected_transitions_lst_.end () != it)
    {
      expected_transitions_lst_.erase (it);
      assert (util::verify_transition_one (handle, to_state));
    }
  }

  if (expected_transitions_lst_.empty ())
  {
    rc = true;
  }

  return rc;
}
Exemplo n.º 30
0
static void *
webpd_proc_dtor (void *ap_obj)
{
  struct webpdprc *p_obj = ap_obj;
  TIZ_LOG (TIZ_TRACE, "Destructing webpdprc...[%p]", p_obj);
  return super_dtor (webpdprc, ap_obj);
}