FLACSink::FLACSink(FILE *fp, uint64_t duration, const SampleFormat &fmt, const FLACModule &module, const std::map<uint32_t, std::wstring> &tags) :m_fp(fp), m_module(module), m_format(fmt) { if (fmt.m_type == SampleFormat::kIsFloat) throw std::runtime_error("Can't handle float source"); if (fmt.m_endian == SampleFormat::kIsBigEndian) throw std::runtime_error("Can't handle big endian source"); m_encoder.swap(encoder_t(m_module.stream_encoder_new(), std::bind1st(std::mem_fun(&FLACSink::closeEncoder), this))); TRYFL(m_module.stream_encoder_set_channels( m_encoder.get(), fmt.m_nchannels)); TRYFL(m_module.stream_encoder_set_bits_per_sample( m_encoder.get(), fmt.m_bitsPerSample)); TRYFL(m_module.stream_encoder_set_sample_rate( m_encoder.get(), fmt.m_rate)); TRYFL(m_module.stream_encoder_set_total_samples_estimate( m_encoder.get(), duration)); TRYFL(m_module.stream_encoder_set_compression_level( m_encoder.get(), 5)); FLAC__StreamMetadata *meta[2]; meta[0] = m_module.metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); meta[1] = m_module.metadata_object_new(FLAC__METADATA_TYPE_PADDING); meta[1]->length = 0x1000; m_metadata_holder[0].swap( metadata_t(meta[0], m_module.metadata_object_delete)); m_metadata_holder[1].swap( metadata_t(meta[1], m_module.metadata_object_delete)); { FLAC__StreamMetadata_VorbisComment_Entry entry; std::map<uint32_t, std::wstring>::const_iterator ii; utf8_codecvt_facet u8codec; for (ii = tags.begin(); ii != tags.end(); ++ii) { const char *key = GetNameFromTagID(ii->first); if (!key) continue; std::string value = w2m(ii->second, u8codec); m_module.metadata_object_vorbiscomment_entry_from_name_value_pair( &entry, key, value.c_str()); m_module.metadata_object_vorbiscomment_append_comment( meta[0], entry, false); } } m_module.stream_encoder_set_metadata(m_encoder.get(), meta, 2); TRYFL(m_module.stream_encoder_init_stream(m_encoder.get(), staticWriteCallback, 0, 0, 0, this) == FLAC__STREAM_ENCODER_INIT_STATUS_OK); }
void CmaEvent::vitaEventSendObjectStatus(vita_event_t *event, int eventId) { qDebug("Event recieved in %s, code: 0x%x, id: %d", Q_FUNC_INFO, event->Code, eventId); object_status_t objectstatus; if(VitaMTP_SendObjectStatus(device, eventId, &objectstatus) != PTP_RC_OK) { qWarning("Failed to get information for object status."); return; } QMutexLocker locker(&m_db->mutex); qDebug("Checking for path %s under ohfi %i", objectstatus.title, objectstatus.ohfiRoot); int ohfi = m_db->getPathId(objectstatus.title, objectstatus.ohfiRoot); if(ohfi == 0) { // not in database, don't return metadata qDebug("Object %s not in database (OHFI: %i). Sending OK response for non-existence", objectstatus.title, objectstatus.ohfiRoot); VitaMTP_ReportResult(device, eventId, PTP_RC_OK); } else { metadata_t metadata = metadata_t(); m_db->getObjectMetadata(ohfi, metadata); metadata.next_metadata = NULL; qDebug("Sending metadata for OHFI %d", ohfi); if(VitaMTP_SendObjectMetadata(device, eventId, &metadata) != PTP_RC_OK) { qWarning("Error sending metadata for %d", ohfi); } else { VitaMTP_ReportResult(device, eventId, PTP_RC_OK); } } free(objectstatus.title); }
void rt_kafka_cluster_t::refresh_metadata() { kafka_rpc_t rpc; rpc.request = std::make_shared<metadata_request_t>(); auto response = std::make_shared<metadata_response_t>(); rpc.response = response; next_allowed_refresh_ = std::chrono::system_clock::now() + options_.lib.metadata_refresh_backoff; network_->send(get_next_broker(), rpc); rpc.promise.get_future().get(); metadata_ = metadata_t(*response); metadata_correct_ = true; }
application_factory(const k3d::filesystem::path& ScriptPath, const k3d::string_t& DelegateFactoryName, const k3d::uuid& FactoryID, const k3d::string_t& Name, const k3d::string_t& ShortDescription, const k3d::string_t& Categories, const quality_t Quality = STABLE, const metadata_t& Metadata = metadata_t()) : plugin_factory(FactoryID, Name, ShortDescription, Categories, Quality, Metadata), script_path(ScriptPath), delegate_factory_name(DelegateFactoryName), delegate_factory(0) { }