示例#1
0
/* callback for an expired dialog. */
static void cdr_on_expired( struct dlg_cell* dialog,
                            int type,
                            struct dlg_cb_params* params)
{
    if( !dialog || !params)
    {
        LM_ERR("invalid values\n!");
        return;
    }

    LM_DBG("dialog '%p' expired!\n", dialog);
    /* compute duration for timed out acknowledged dialog */
	if ( params && params->dlg_data ) {
		if ( (void*)CONFIRMED_DIALOG_STATE == params->dlg_data) {
			if( set_end_time( dialog) != 0)
			{
				LM_ERR( "failed to set end time!\n");
				return;
			}	
			
			if( set_duration( dialog) != 0)
			{
				LM_ERR( "failed to set duration!\n");
				return;
			}
			
		}
	}

    if( cdr_expired_dlg_enable  && (write_cdr( dialog, 0) != 0))
    {
        LM_ERR( "failed to write cdr!\n");
        return;
    }
}
		TITANIUM_PROPERTY_SETTER(Animation, duration)
		{
			TITANIUM_ASSERT(argument.IsNumber());
			const auto duration = std::chrono::milliseconds(static_cast<std::chrono::milliseconds::rep>(static_cast<std::uint32_t>(argument)));
			set_duration(duration);
			return true;
		}
示例#3
0
 auto parse(T&& x) {
     switch(current_mode) {
         default: throw std::runtime_error("Error: Invalid sound engine mode."); break;
         case mode::SOUND: play_sound(std::forward<T>(x)); break;
         case mode::PRINT: print_character(std::forward<T>(x)); break;
         case mode::VOLUME: set_volume(std::forward<T>(x)); break;
         case mode::DURATION: set_duration(std::forward<T>(x)); break;
     }
 }
示例#4
0
Contribution::Contribution(Contribution * object)
{
    depositor = object->get_depositor();
    type = object->get_type();
    interest = object->get_interest();
    summ = object->get_init_summ();
    date_of_issue = new Date();
    date_of_refund = new Date();
    date_of_issue->set_date(object->date_of_issue->get_day(), object->date_of_issue->get_month(), object->date_of_issue->get_year());
    set_duration(object->get_period());
    FLAG_summ_is_filled = FLAG_interest_is_filled = FLAG_period_is_filled = FLAG_date_is_filled = FLAG_type_is_setted = true;
}
void PulsingColorAnimation::loadFromJSON(const QJsonObject & obj) {
    if (obj.contains("fromStart")) set_fromStart(obj["fromStart"].toDouble());
    if (obj.contains("duration")) set_duration(obj["duration"].toDouble());
    if (obj.contains("lowerColor") and obj.contains("upperColor")) {
        QColor lowerColor = QColor(obj["lowerColor"].toString());
        QColor upperColor = QColor(obj["upperColor"].toString());
        set_meanColor(QColor((upperColor.red() + lowerColor.red()) / 2, (upperColor.green() + lowerColor.green()) / 2, (upperColor.blue() + lowerColor.blue()) / 2));
        set_varColor(QColor((upperColor.red() - lowerColor.red()) / 2, (upperColor.green() - lowerColor.green()) / 2, (upperColor.blue() - lowerColor.blue()) / 2));
    }
    if (obj.contains("frequency")) set_pulsation(obj["frequency"].toDouble() * 2 * M_PI);
    if (obj.contains("delay")) set_delay(obj["delay"].toDouble());
    if (obj.contains("pulseSignal")) set_pulseSignal(obj["pulseSignal"].toString());
    if (obj.contains("priority")) set_priority(obj["priority"].toInt());
}
示例#6
0
/***************************************************************
 * Constructors for creating FGS_Grain objects
 ***************************************************************/
FGS_Grain :: FGS_Grain(){
    
    // Initialise instance variables, the oscillator
    // and the envelope
    
    set_duration       (20);
    set_wavetype       (SINE);
    maxi_osc.phaseReset(TWOPI);
    frequency        = 440;
    envelope_type    = GAUSS;
    finished_playing = true;
    envelope         = FGS_Envelope(duration);
    
}
示例#7
0
Contribution::Contribution(const std::string setted_depositor, const std::string setted_type, double setted_interest,
                           unsigned short setted_period, double setted_summ,
                           short setted_day, short setted_month, short setted_year)
{

    depositor = setted_depositor;
    type = setted_type;
    interest = setted_interest;
    period = setted_period;
    summ = setted_summ;
    date_of_issue = new Date();
    date_of_issue->set_date(setted_day, setted_month, setted_year);
    date_of_refund = new Date();
    set_duration(period);
    FLAG_summ_is_filled = FLAG_interest_is_filled = FLAG_period_is_filled = FLAG_date_is_filled = FLAG_type_is_setted = true;
}
示例#8
0
/* callback for the end of a dialog (BYE). */
static void cdr_on_end( struct dlg_cell* dialog,
                        int type,
                        struct dlg_cb_params* params)
{
    if( !dialog || !params || !params->req)
    {
        LM_ERR("invalid values\n!");
        return;
    }

    if( set_end_time( dialog) != 0)
    {
        LM_ERR( "failed to set end time!\n");
        return;
    }

    if( set_duration( dialog) != 0)
    {
        LM_ERR( "failed to set duration!\n");
        return;
    }
}
int set_data_source_l(State **ps, const char* path) {
    printf("set_data_source\n");
    int audio_index = -1;
    int video_index = -1;
    int i;
    
    State *state = *ps;
    
    printf("Path: %s\n", path);
    
    AVDictionary *options = NULL;
    av_dict_set(&options, "icy", "1", 0);
    av_dict_set(&options, "user-agent", "FFmpegMediaMetadataRetriever", 0);
    
    if (state->headers) {
        av_dict_set(&options, "headers", state->headers, 0);
    }
    
    if (state->offset > 0) {
        state->pFormatCtx = avformat_alloc_context();
        state->pFormatCtx->skip_initial_bytes = state->offset;
    }
    
    if (avformat_open_input(&state->pFormatCtx, path, NULL, &options) != 0) {
        printf("Metadata could not be retrieved\n");
        *ps = NULL;
        return FAILURE;
    }
    
    if (avformat_find_stream_info(state->pFormatCtx, NULL) < 0) {
        printf("Metadata could not be retrieved\n");
        avformat_close_input(&state->pFormatCtx);
        *ps = NULL;
        return FAILURE;
    }
    
    set_duration(state->pFormatCtx);
    
    set_shoutcast_metadata(state->pFormatCtx);
    
    //av_dump_format(state->pFormatCtx, 0, path, 0);
    
    // Find the first audio and video stream
    for (i = 0; i < state->pFormatCtx->nb_streams; i++) {
        if (state->pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && video_index < 0) {
            video_index = i;
        }
        
        if (state->pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && audio_index < 0) {
            audio_index = i;
        }
        
        set_codec(state->pFormatCtx, i);
    }
    
    if (audio_index >= 0) {
        stream_component_open(state, audio_index);
    }
    
    if (video_index >= 0) {
        stream_component_open(state, video_index);
    }
    
    /*if(state->video_stream < 0 || state->audio_stream < 0) {
	    avformat_close_input(&state->pFormatCtx);
     *ps = NULL;
     return FAILURE;
     }*/
    
    set_rotation(state->pFormatCtx, state->audio_st, state->video_st);
    set_framerate(state->pFormatCtx, state->audio_st, state->video_st);
    set_filesize(state->pFormatCtx);
    set_chapter_count(state->pFormatCtx);
    
    /*printf("Found metadata\n");
     AVDictionaryEntry *tag = NULL;
     while ((tag = av_dict_get(state->pFormatCtx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
    	printf("Key %s: \n", tag->key);
    	printf("Value %s: \n", tag->value);
     }*/
    
    *ps = state;
    return SUCCESS;
}
示例#10
0
int parse_arguments(int argc, char *argv[])
{
        int i;
        char *flag;

        if (argc < 9) {
                return ERROR;
        }

        for (i = 1; i < argc; i += 2) {
                if (strlen(argv[i]) < 2) {
                        printf("invalid flag: %s\n", argv[i]);
                        exit(1);
                }
                flag = argv[i] + 1;
                if (strcmp(flag, "d") == 0) {
                        set_client_hostname(argv[i + 1]);
#ifdef LIBPQ
                } else if (strcmp(flag, "z") == 0) {
                        strcpy(postmaster_port, argv[i + 1]);
#endif /* LIBPQ */
#ifdef LIBMYSQL
		} else if (strcmp(flag, "z") == 0) {
			strcpy(dbt2_mysql_port, argv[i + 1]);
#endif /* LIBMYSQL */
#ifdef LIBDRIZZLE
		} else if (strcmp(flag, "z") == 0) {
			strcpy(dbt2_drizzle_port, argv[i + 1]);
#endif /* LIBDRIZZLE */
                } else if (strcmp(flag, "p") == 0) {
                        set_client_port(atoi(argv[i + 1]));
                } else if (strcmp(flag, "l") == 0) {
                        set_duration(atoi(argv[i + 1]));
                } else if (strcmp(flag, "w") == 0) {
                        set_table_cardinality(TABLE_WAREHOUSE,
                                atoi(argv[i + 1]));
                } else if (strcmp(flag, "c") == 0) {
                        set_table_cardinality(TABLE_CUSTOMER,
                                atoi(argv[i + 1]));
                } else if (strcmp(flag, "i") == 0) {
                        set_table_cardinality(TABLE_ITEM, atoi(argv[i + 1]));
                } else if (strcmp(flag, "o") == 0) {
                        set_table_cardinality(TABLE_ORDER, atoi(argv[i + 1]));
                } else if (strcmp(flag, "s") == 0) {
                        set_table_cardinality(TABLE_STOCK, atoi(argv[i + 1]));
                } else if (strcmp(flag, "n") == 0) {
                        set_table_cardinality(TABLE_NEW_ORDER,
                                atoi(argv[i + 1]));
                } else if (strcmp(flag, "q") == 0) {
                        set_transaction_mix(PAYMENT, atof(argv[i + 1]));
                } else if (strcmp(flag, "r") == 0) {
                        set_transaction_mix(ORDER_STATUS, atof(argv[i + 1]));
                } else if (strcmp(flag, "e") == 0) {
                        set_transaction_mix(DELIVERY, atof(argv[i + 1]));
                } else if (strcmp(flag, "t") == 0) {
                        set_transaction_mix(STOCK_LEVEL, atof(argv[i + 1]));
                } else if (strcmp(flag, "z") == 0) {
                        perform_integrity_check = 1;
                } else if (strcmp(flag, "wmin") == 0) {
                        w_id_min = atoi(argv[i + 1]);
                } else if (strcmp(flag, "wmax") == 0) {
                        w_id_max = atoi(argv[i + 1]);
                } else if (strcmp(flag, "ktd") == 0) {
                        key_time.delivery = atoi(argv[i + 1]);
                } else if (strcmp(flag, "ktn") == 0) {
                        key_time.new_order = atoi(argv[i + 1]);
                } else if (strcmp(flag, "kto") == 0) {
                        key_time.order_status = atoi(argv[i + 1]);
                } else if (strcmp(flag, "ktp") == 0) {
                        key_time.payment = atoi(argv[i + 1]);
                } else if (strcmp(flag, "kts") == 0) {
                        key_time.stock_level = atoi(argv[i + 1]);
                } else if (strcmp(flag, "ttd") == 0) {
                        think_time.delivery = atoi(argv[i + 1]);
                } else if (strcmp(flag, "ttn") == 0) {
                        think_time.new_order = atoi(argv[i + 1]);
                } else if (strcmp(flag, "tto") == 0) {
                        think_time.order_status = atoi(argv[i + 1]);
                } else if (strcmp(flag, "ttp") == 0) {
                        think_time.payment = atoi(argv[i + 1]);
                } else if (strcmp(flag, "tts") == 0) {
                        think_time.stock_level = atoi(argv[i + 1]);
                } else if (strcmp(flag, "tpw") == 0) {
                        terminals_per_warehouse = atoi(argv[i + 1]);
                } else if (strcmp(flag, "sleep") == 0) {
                        client_conn_sleep = atoi(argv[i + 1]);
                } else if (strcmp(flag, "spread") == 0) {
                        spread = atoi(argv[i + 1]);
                } else if (strcmp(flag, "seed") == 0) {
                        int count;
                        int length;

                        seed = 0;
                        length = strlen(argv[i + 1]);

                        for (count = 0; count < length; count++) {
                                seed += (argv[i + 1][count] - '0') *
                                        (unsigned int) pow(10, length -
                                        (count + 1));
                        }
                } else if (strcmp(flag, "altered") == 0) {
                        mode_altered = atoi(argv[i + 1]);
#ifdef STANDALONE
                } else if (strcmp(flag, "dbc") == 0) {
                        db_connections = atoi(argv[i + 1]);
                } else if (strcmp(flag, "dbname") == 0) {
                        strcpy(sname, argv[i + 1]);
#endif /* STANDALONE */
                } else if (strcmp(flag, "outdir") == 0) {
                        strcpy(output_path, argv[i + 1]);
                } else {
                        printf("invalid flag: %s\n", argv[i]);
                        exit(1);
                }
        }

        return OK;
}
示例#11
0
int
cluster_helper_c::render() {
  std::vector<render_groups_cptr> render_groups;
  KaxCues cues;
  cues.SetGlobalTimecodeScale(g_timecode_scale);

  bool use_simpleblock    = !hack_engaged(ENGAGE_NO_SIMPLE_BLOCKS);

  LacingType lacing_type  = hack_engaged(ENGAGE_LACING_XIPH) ? LACING_XIPH : hack_engaged(ENGAGE_LACING_EBML) ? LACING_EBML : LACING_AUTO;

  int64_t min_cl_timecode = std::numeric_limits<int64_t>::max();
  int64_t max_cl_timecode = 0;

  int elements_in_cluster = 0;
  bool added_to_cues      = false;

  // Splitpoint stuff
  if ((-1 == m->header_overhead) && splitting())
    m->header_overhead = m->out->getFilePointer() + g_tags_size;

  // Make sure that we don't have negative/wrapped around timecodes in the output file.
  // Can happend when we're splitting; so adjust timecode_offset accordingly.
  m->timecode_offset       = boost::accumulate(m->packets, m->timecode_offset, [](int64_t a, const packet_cptr &p) { return std::min(a, p->assigned_timecode); });
  int64_t timecode_offset = m->timecode_offset + get_discarded_duration();

  for (auto &pack : m->packets) {
    generic_packetizer_c *source = pack->source;
    bool has_codec_state         = !!pack->codec_state;

    if (g_video_packetizer == source)
      m->max_video_timecode_rendered = std::max(pack->assigned_timecode + pack->get_duration(), m->max_video_timecode_rendered);

    if (discarding()) {
      if (-1 == m->first_discarded_timecode)
        m->first_discarded_timecode = pack->assigned_timecode;
      m->last_discarded_timecode_and_duration = std::max(m->last_discarded_timecode_and_duration, pack->assigned_timecode + pack->get_duration());
      continue;
    }

    if (source->contains_gap())
      m->cluster->SetSilentTrackUsed();

    render_groups_c *render_group = nullptr;
    for (auto &rg : render_groups)
      if (rg->m_source == source) {
        render_group = rg.get();
        break;
      }

    if (!render_group) {
      render_groups.push_back(render_groups_cptr(new render_groups_c(source)));
      render_group = render_groups.back().get();
    }

    min_cl_timecode                        = std::min(pack->assigned_timecode, min_cl_timecode);
    max_cl_timecode                        = std::max(pack->assigned_timecode, max_cl_timecode);

    DataBuffer *data_buffer                = new DataBuffer((binary *)pack->data->get_buffer(), pack->data->get_size());

    KaxTrackEntry &track_entry             = static_cast<KaxTrackEntry &>(*source->get_track_entry());

    kax_block_blob_c *previous_block_group = !render_group->m_groups.empty() ? render_group->m_groups.back().get() : nullptr;
    kax_block_blob_c *new_block_group      = previous_block_group;

    if (!pack->is_key_frame() || has_codec_state || pack->has_discard_padding())
      render_group->m_more_data = false;

    if (!render_group->m_more_data) {
      set_duration(render_group);
      render_group->m_durations.clear();
      render_group->m_duration_mandatory = false;

      BlockBlobType this_block_blob_type
        = !use_simpleblock                         ? BLOCK_BLOB_NO_SIMPLE
        : must_duration_be_set(render_group, pack) ? BLOCK_BLOB_NO_SIMPLE
        : !pack->data_adds.empty()                 ? BLOCK_BLOB_NO_SIMPLE
        : has_codec_state                          ? BLOCK_BLOB_NO_SIMPLE
        : pack->has_discard_padding()              ? BLOCK_BLOB_NO_SIMPLE
        :                                            BLOCK_BLOB_ALWAYS_SIMPLE;

      render_group->m_groups.push_back(kax_block_blob_cptr(new kax_block_blob_c(this_block_blob_type)));
      new_block_group = render_group->m_groups.back().get();
      m->cluster->AddBlockBlob(new_block_group);
      new_block_group->SetParent(*m->cluster);

      added_to_cues = false;
    }

    // Now put the packet into the cluster.
    render_group->m_more_data = new_block_group->add_frame_auto(track_entry, pack->assigned_timecode - timecode_offset, *data_buffer, lacing_type,
                                                                pack->has_bref() ? pack->bref - timecode_offset : -1,
                                                                pack->has_fref() ? pack->fref - timecode_offset : -1);

    if (has_codec_state) {
      KaxBlockGroup &bgroup = (KaxBlockGroup &)*new_block_group;
      KaxCodecState *cstate = new KaxCodecState;
      bgroup.PushElement(*cstate);
      cstate->CopyBuffer(pack->codec_state->get_buffer(), pack->codec_state->get_size());
    }

    if (-1 == m->first_timecode_in_file)
      m->first_timecode_in_file = pack->assigned_timecode;
    if (-1 == m->first_timecode_in_part)
      m->first_timecode_in_part = pack->assigned_timecode;

    m->min_timecode_in_file      = std::min(timecode_c::ns(pack->assigned_timecode),        m->min_timecode_in_file.value_or_max());
    m->max_timecode_in_file      = std::max(pack->assigned_timecode,                        m->max_timecode_in_file);
    m->max_timecode_and_duration = std::max(pack->assigned_timecode + pack->get_duration(), m->max_timecode_and_duration);

    if (!pack->is_key_frame() || !track_entry.LacingEnabled())
      render_group->m_more_data = false;

    render_group->m_durations.push_back(pack->get_unmodified_duration());
    render_group->m_duration_mandatory |= pack->duration_mandatory;

    cues_c::get().set_duration_for_id_timecode(source->get_track_num(), pack->assigned_timecode - timecode_offset, pack->get_duration());

    if (new_block_group) {
      // Set the reference priority if it was wanted.
      if ((0 < pack->ref_priority) && new_block_group->replace_simple_by_group())
        GetChild<KaxReferencePriority>(*new_block_group).SetValue(pack->ref_priority);

      // Handle BlockAdditions if needed
      if (!pack->data_adds.empty() && new_block_group->ReplaceSimpleByGroup()) {
        KaxBlockAdditions &additions = AddEmptyChild<KaxBlockAdditions>(*new_block_group);

        size_t data_add_idx;
        for (data_add_idx = 0; pack->data_adds.size() > data_add_idx; ++data_add_idx) {
          auto &block_more = AddEmptyChild<KaxBlockMore>(additions);
          GetChild<KaxBlockAddID     >(block_more).SetValue(data_add_idx + 1);
          GetChild<KaxBlockAdditional>(block_more).CopyBuffer((binary *)pack->data_adds[data_add_idx]->get_buffer(), pack->data_adds[data_add_idx]->get_size());
        }
      }

      if (pack->has_discard_padding())
        GetChild<KaxDiscardPadding>(*new_block_group).SetValue(pack->discard_padding.to_ns());
    }

    elements_in_cluster++;

    if (!new_block_group)
      new_block_group = previous_block_group;

    else if (g_write_cues && (!added_to_cues || has_codec_state)) {
      added_to_cues = add_to_cues_maybe(pack);
      if (added_to_cues)
        cues.AddBlockBlob(*new_block_group);
    }

    pack->group = new_block_group;

    m->track_statistics[ source->get_uid() ].process(*pack);
  }

  if (!discarding()) {
    if (0 < elements_in_cluster) {
      for (auto &rg : render_groups)
        set_duration(rg.get());

      m->cluster->SetPreviousTimecode(min_cl_timecode - timecode_offset - 1, (int64_t)g_timecode_scale);
      m->cluster->set_min_timecode(min_cl_timecode - timecode_offset);
      m->cluster->set_max_timecode(max_cl_timecode - timecode_offset);

      m->cluster->Render(*m->out, cues);
      m->bytes_in_file += m->cluster->ElementSize();

      if (g_kax_sh_cues)
        g_kax_sh_cues->IndexThis(*m->cluster, *g_kax_segment);

      m->previous_cluster_tc = m->cluster->GlobalTimecode();

      cues_c::get().postprocess_cues(cues, *m->cluster);

    } else
      m->previous_cluster_tc = -1;
  }

  m->min_timecode_in_cluster = -1;
  m->max_timecode_in_cluster = -1;

  m->cluster->delete_non_blocks();

  return 1;
}