GF_Err ISOR_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { ISOMChannel *ch; GF_Err e; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; if (!read->mov) return GF_SERVICE_ERROR; gf_mx_p(read->segment_mutex); e = GF_OK; ch = isor_get_channel(read, channel); assert(ch); if (!ch) { e = GF_STREAM_NOT_FOUND; goto exit; } /*signal the service is broken but still process the delete*/ isor_delete_channel(read, ch); assert(!isor_get_channel(read, channel)); exit: if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { send_proxy_command(read, 1, 0, e, NULL, channel); } else { gf_service_disconnect_ack(read->service, channel, e); } gf_mx_v(read->segment_mutex); return e; }
GF_Err ISOR_ChannelGetSLP(GF_InputService *plug, LPNETCHANNEL channel, char **out_data_ptr, u32 *out_data_size, GF_SLHeader *out_sl_hdr, Bool *sl_compressed, GF_Err *out_reception_status, Bool *is_new_data) { ISOMChannel *ch; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; /*cannot read native SL-PDUs*/ if (!out_sl_hdr) return GF_NOT_SUPPORTED; read = (ISOMReader *) plug->priv; if (!read->mov) return GF_SERVICE_ERROR; *out_data_ptr = NULL; *out_data_size = 0; *sl_compressed = 0; *out_reception_status = GF_OK; ch = isor_get_channel(read, channel); if (!ch) return GF_STREAM_NOT_FOUND; if (!ch->is_playing) return GF_OK; *is_new_data = 0; if (!ch->sample) { /*get sample*/ isor_reader_get_sample(ch); *is_new_data = ch->sample ? 1 : 0; } if (ch->sample) { *out_data_ptr = ch->sample->data; *out_data_size = ch->sample->dataLength; *out_sl_hdr = ch->current_slh; } *out_reception_status = ch->last_state; return GF_OK; }
GF_Err ISOR_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { ISOMChannel *ch; GF_Err e; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; if (!read->mov) return GF_SERVICE_ERROR; e = GF_OK; ch = isor_get_channel(read, channel); assert(ch); if (!ch) { e = GF_STREAM_NOT_FOUND; goto exit; } /*signal the service is broken but still process the delete*/ isor_delete_channel(read, ch); assert(!isor_get_channel(read, channel)); exit: gf_term_on_disconnect(read->service, channel, e); return e; }
GF_Err ISOR_ChannelReleaseSLP(GF_InputService *plug, LPNETCHANNEL channel) { ISOMChannel *ch; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; if (!read->mov) return GF_SERVICE_ERROR; ch = isor_get_channel(read, channel); if (!ch) return GF_STREAM_NOT_FOUND; if (!ch->is_playing) return GF_SERVICE_ERROR; if (ch->sample) { isor_reader_release_sample(ch); /*release sample*/ } return GF_OK; }
static GF_Err ISOW_Write(GF_StreamingCache *mc, LPNETCHANNEL ch, char *data, u32 data_size, GF_SLHeader *sl_hdr) { ISOMChannel *mch; GF_ESD *esd; u32 di, mtype; u64 DTS, CTS; ISOMReader *cache = (ISOMReader *)mc->priv; if (!cache->mov || !cache->service) return GF_BAD_PARAM; mch = isor_get_channel(cache, ch); if (!mch) { Bool mapped; GF_NetworkCommand com; com.base.on_channel = ch; com.base.command_type = GF_NET_CHAN_GET_ESD; gf_service_command(cache->service, &com, GF_OK); if (!com.cache_esd.esd) return GF_SERVICE_ERROR; esd = (GF_ESD *)com.cache_esd.esd; switch (esd->decoderConfig->streamType) { case GF_STREAM_OD: mtype = GF_ISOM_MEDIA_OD; break; case GF_STREAM_SCENE: mtype = GF_ISOM_MEDIA_SCENE; break; case GF_STREAM_VISUAL: mtype = GF_ISOM_MEDIA_VISUAL; break; case GF_STREAM_AUDIO: mtype = GF_ISOM_MEDIA_AUDIO; break; case GF_STREAM_MPEG7: mtype = GF_ISOM_MEDIA_MPEG7; break; case GF_STREAM_OCI: mtype = GF_ISOM_MEDIA_OCI; break; case GF_STREAM_IPMP: mtype = GF_ISOM_MEDIA_IPMP; break; case GF_STREAM_MPEGJ: mtype = GF_ISOM_MEDIA_MPEGJ; break; case GF_STREAM_TEXT: mtype = GF_ISOM_MEDIA_TEXT; break; default: return GF_NOT_SUPPORTED; } GF_SAFEALLOC(mch, ISOMChannel); if (!mch) { return GF_OUT_OF_MEM; } mch->time_scale = esd->slConfig->timestampResolution; mch->streamType = esd->decoderConfig->streamType; mch->track = gf_isom_new_track(cache->mov, com.cache_esd.esd->ESID, mtype, mch->time_scale); mch->is_playing = GF_TRUE; mch->channel = ch; mch->owner = cache; gf_isom_set_track_enabled(cache->mov, mch->track, 1); /*translate 3GP streams to MP4*/ mapped = GF_FALSE; if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_MEDIA_GENERIC) { char szCode[5]; strncpy(szCode, esd->decoderConfig->decoderSpecificInfo->data, 4); szCode[4]=0; if (!stricmp(szCode, "samr") || !stricmp(szCode, "amr ") || !stricmp(szCode, "sawb")) { GF_3GPConfig amrc; mapped = GF_TRUE; memset(&amrc, 0, sizeof(GF_3GPConfig)); amrc.frames_per_sample = (u32) esd->decoderConfig->decoderSpecificInfo->data[13]; amrc.type = (!stricmp(szCode, "sawb")) ? GF_ISOM_SUBTYPE_3GP_AMR_WB : GF_ISOM_SUBTYPE_3GP_AMR; amrc.vendor = GF_VENDOR_GPAC; gf_isom_3gp_config_new(cache->mov, mch->track, &amrc, NULL, NULL, &di); } else if (!stricmp(szCode, "h263")) { GF_3GPConfig h263c; memset(&h263c, 0, sizeof(GF_3GPConfig)); h263c.type = GF_ISOM_SUBTYPE_3GP_H263; h263c.vendor = GF_VENDOR_GPAC; gf_isom_3gp_config_new(cache->mov, mch->track, &h263c, NULL, NULL, &di); mapped = GF_TRUE; } } if (!mapped) gf_isom_new_mpeg4_description(cache->mov, mch->track, esd, NULL, NULL, &di); if (com.cache_esd.is_iod_stream) gf_isom_add_track_to_root_od(cache->mov, mch->track); gf_list_add(cache->channels, mch); } /*first sample, cache it*/ if (!mch->cache_sample) { mch->cache_seed_ts = sl_hdr->decodingTimeStamp; mch->cache_sample = gf_isom_sample_new(); mch->cache_sample->IsRAP = sl_hdr->randomAccessPointFlag; mch->cache_sample->dataLength = data_size; mch->cache_sample->data = (char*)gf_malloc(sizeof(char)*data_size); memcpy(mch->cache_sample->data, data, sizeof(char)*data_size); return GF_OK; } /*adjust DTS/CTS*/ DTS = sl_hdr->decodingTimeStamp - mch->cache_seed_ts; if ((mch->streamType==GF_STREAM_VISUAL) && (DTS<=mch->cache_sample->DTS)) { assert(DTS>mch->prev_dts); CTS = mch->cache_sample->DTS + mch->cache_sample->CTS_Offset; mch->cache_sample->CTS_Offset = 0; /*first time, shift all CTS*/ if (!mch->frame_cts_offset) { u32 i, count = gf_isom_get_sample_count(cache->mov, mch->track); mch->frame_cts_offset = (u32) (DTS-mch->prev_dts); for (i=0; i<count; i++) { gf_isom_modify_cts_offset(cache->mov, mch->track, i+1, mch->frame_cts_offset); } mch->cache_sample->CTS_Offset += mch->frame_cts_offset; } mch->cache_sample->DTS = mch->prev_dts + mch->frame_cts_offset; mch->cache_sample->CTS_Offset += (u32) (CTS-mch->cache_sample->DTS); } /*deal with reference picture insertion: if no CTS offset and biggest CTS until now, this is a reference insertion - we must check that in order to make sure we have strictly increasing DTSs*/ if (mch->max_cts && !mch->cache_sample->CTS_Offset && (mch->cache_sample->DTS+mch->cache_sample->CTS_Offset > mch->max_cts)) { assert(mch->cache_sample->DTS > mch->prev_dts + mch->frame_cts_offset); CTS = mch->cache_sample->DTS + mch->cache_sample->CTS_Offset; mch->cache_sample->DTS = mch->prev_dts + mch->frame_cts_offset; mch->cache_sample->CTS_Offset = (u32) (CTS-mch->cache_sample->DTS); } if (mch->cache_sample->CTS_Offset) mch->max_cts = mch->cache_sample->DTS+mch->cache_sample->CTS_Offset; /*add cache*/ gf_isom_add_sample(cache->mov, mch->track, 1, mch->cache_sample); assert(!mch->prev_dts || (mch->prev_dts < mch->cache_sample->DTS)); mch->prev_dts = mch->cache_sample->DTS; mch->duration = MAX(mch->max_cts, mch->prev_dts); gf_isom_sample_del(&mch->cache_sample); /*store sample*/ mch->cache_sample = gf_isom_sample_new(); mch->cache_sample->IsRAP = sl_hdr->randomAccessPointFlag; mch->cache_sample->DTS = DTS + mch->frame_cts_offset; mch->cache_sample->CTS_Offset = (u32) (sl_hdr->compositionTimeStamp - mch->cache_seed_ts - DTS); mch->cache_sample->dataLength = data_size; mch->cache_sample->data = (char*)gf_malloc(sizeof(char)*data_size); memcpy(mch->cache_sample->data, data, sizeof(char)*data_size); return GF_OK; }
GF_Err ISOR_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) { Double track_dur, media_dur; ISOMChannel *ch; ISOMReader *read; if (!plug || !plug->priv || !com) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; if (com->command_type==GF_NET_SERVICE_INFO) { u32 tag_len; const char *tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_NAME, &tag, &tag_len)==GF_OK) com->info.name = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_ARTIST, &tag, &tag_len)==GF_OK) com->info.artist = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_ALBUM, &tag, &tag_len)==GF_OK) com->info.album = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_COMMENT, &tag, &tag_len)==GF_OK) com->info.comment = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_TRACK, &tag, &tag_len)==GF_OK) { com->info.track_info = (((tag[2]<<8)|tag[3]) << 16) | ((tag[4]<<8)|tag[5]); } if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_COMPOSER, &tag, &tag_len)==GF_OK) com->info.composer = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_WRITER, &tag, &tag_len)==GF_OK) com->info.writer = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_GENRE, &tag, &tag_len)==GF_OK) { if (tag[0]) { com->info.genre = 0; } else { com->info.genre = (tag[0]<<8) | tag[1]; } } return GF_OK; } if (com->command_type==GF_NET_SERVICE_HAS_AUDIO) { u32 i, count; count = gf_isom_get_track_count(read->mov); for (i=0; i<count; i++) { if (gf_isom_get_media_type(read->mov, i+1) == GF_ISOM_MEDIA_AUDIO) return GF_OK; } return GF_NOT_SUPPORTED; } if (!com->base.on_channel) return GF_NOT_SUPPORTED; ch = isor_get_channel(read, com->base.on_channel); if (!ch) return GF_STREAM_NOT_FOUND; switch (com->command_type) { case GF_NET_CHAN_SET_PADDING: if (!ch->track) return GF_OK; gf_isom_set_sample_padding(read->mov, ch->track, com->pad.padding_bytes); return GF_OK; case GF_NET_CHAN_SET_PULL: ch->is_pulling = 1; return GF_OK; case GF_NET_CHAN_INTERACTIVE: return GF_OK; case GF_NET_CHAN_BUFFER: com->buffer.max = com->buffer.min = 0; return GF_OK; case GF_NET_CHAN_DURATION: if (!ch->track) { com->duration.duration = 0; return GF_OK; } ch->duration = gf_isom_get_track_duration(read->mov, ch->track); track_dur = (Double) (s64) ch->duration; track_dur /= read->time_scale; if (gf_isom_get_edit_segment_count(read->mov, ch->track)) { com->duration.duration = (Double) track_dur; ch->duration = (u32) (track_dur * ch->time_scale); } else { /*some file indicate a wrong TrackDuration, get the longest*/ ch->duration = gf_isom_get_media_duration(read->mov, ch->track); media_dur = (Double) (s64) ch->duration; media_dur /= ch->time_scale; com->duration.duration = MAX(track_dur, media_dur); } return GF_OK; case GF_NET_CHAN_PLAY: if (!ch->is_pulling) return GF_NOT_SUPPORTED; assert(!ch->is_playing); isor_reset_reader(ch); ch->speed = com->play.speed; ch->start = ch->end = 0; if (com->play.speed>0) { if (com->play.start_range>=0) { ch->start = (u64) (s64) (com->play.start_range * ch->time_scale); ch->start = check_round(ch, ch->start, com->play.start_range, 1); } if (com->play.end_range >= com->play.start_range) { ch->end = (u64) (s64) (com->play.end_range*ch->time_scale); ch->end = check_round(ch, ch->end, com->play.end_range, 0); } } else if (com->play.speed<0) { if (com->play.end_range>=com->play.start_range) ch->start = (u64) (s64) (com->play.start_range * ch->time_scale); if (com->play.end_range >= 0) ch->end = (u64) (s64) (com->play.end_range*ch->time_scale); } ch->is_playing = 1; if (com->play.dash_segment_switch) ch->wait_for_segment_switch = 1; GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[IsoMedia] Starting channel playback "LLD" to "LLD" (%g to %g)\n", ch->start, ch->end, com->play.start_range, com->play.end_range)); return GF_OK; case GF_NET_CHAN_STOP: isor_reset_reader(ch); return GF_OK; /*nothing to do on MP4 for channel config*/ case GF_NET_CHAN_CONFIG: return GF_OK; case GF_NET_CHAN_GET_PIXEL_AR: return gf_isom_get_pixel_aspect_ratio(read->mov, ch->track, 1, &com->par.hSpacing, &com->par.vSpacing); case GF_NET_CHAN_GET_DSI: { /*it may happen that there are conflicting config when using ESD URLs...*/ GF_DecoderConfig *dcd = gf_isom_get_decoder_config(read->mov, ch->track, 1); com->get_dsi.dsi = NULL; com->get_dsi.dsi_len = 0; if (dcd) { if (dcd->decoderSpecificInfo) { com->get_dsi.dsi = dcd->decoderSpecificInfo->data; com->get_dsi.dsi_len = dcd->decoderSpecificInfo->dataLength; dcd->decoderSpecificInfo->data = NULL; } gf_odf_desc_del((GF_Descriptor *) dcd); } } return GF_OK; } return GF_NOT_SUPPORTED; }
GF_Err ISOR_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const char *url, Bool upstream) { u32 ESID; ISOMChannel *ch; GF_NetworkCommand com; u32 track; Bool is_esd_url; GF_Err e; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; track = 0; ch = NULL; is_esd_url = 0; e = GF_OK; if (upstream) { e = GF_ISOM_INVALID_FILE; goto exit; } if (!read->mov) return GF_SERVICE_ERROR; if (strstr(url, "ES_ID")) { sscanf(url, "ES_ID=%ud", &ESID); } else { /*handle url like mypath/myfile.mp4#trackID*/ char *track_id = strrchr(url, '.'); if (track_id) { track_id = strchr(url, '#'); if (track_id) track_id ++; } is_esd_url = 1; ESID = 0; /*if only one track ok*/ if (gf_isom_get_track_count(read->mov)==1) ESID = gf_isom_get_track_id(read->mov, 1); else if (track_id) { ESID = atoi(track_id); track = gf_isom_get_track_by_id(read->mov, (u32) ESID); if (!track) ESID = 0; } } if (!ESID) { e = GF_NOT_SUPPORTED; goto exit; } /*a channel cannot be open twice, it has to be closed before - NOTE a track is NOT a channel and the user can open several times the same track as long as a dedicated channel is used*/ ch = isor_get_channel(read, channel); if (ch) { e = GF_SERVICE_ERROR; goto exit; } track = gf_isom_get_track_by_id(read->mov, (u32) ESID); if (!track) { e = GF_STREAM_NOT_FOUND; goto exit; } GF_SAFEALLOC(ch, ISOMChannel); ch->owner = read; ch->channel = channel; gf_list_add(read->channels, ch); ch->track = track; switch (gf_isom_get_media_type(ch->owner->mov, ch->track)) { case GF_ISOM_MEDIA_OCR: ch->streamType = GF_STREAM_OCR; break; case GF_ISOM_MEDIA_SCENE: ch->streamType = GF_STREAM_SCENE; break; } ch->has_edit_list = gf_isom_get_edit_segment_count(ch->owner->mov, ch->track) ? 1 : 0; ch->has_rap = (gf_isom_has_sync_points(ch->owner->mov, ch->track)==1) ? 1 : 0; ch->time_scale = gf_isom_get_media_timescale(ch->owner->mov, ch->track); exit: gf_term_on_connect(read->service, channel, e); /*if esd url reconfig SL layer*/ if (!e && is_esd_url) { GF_ESD *esd; memset(&com, 0, sizeof(GF_NetworkCommand)); com.base.on_channel = channel; com.command_type = GF_NET_CHAN_RECONFIG; esd = gf_isom_get_esd(read->mov, ch->track, 1); if (esd) { memcpy(&com.cfg.sl_config, esd->slConfig, sizeof(GF_SLConfig)); gf_odf_desc_del((GF_Descriptor *)esd); } else { com.cfg.sl_config.tag = GF_ODF_SLC_TAG; com.cfg.sl_config.timestampLength = 32; com.cfg.sl_config.timestampResolution = ch->time_scale; com.cfg.sl_config.useRandomAccessPointFlag = 1; } gf_term_on_command(read->service, &com, GF_OK); } if (!e && track && gf_isom_is_track_encrypted(read->mov, track)) { memset(&com, 0, sizeof(GF_NetworkCommand)); com.base.on_channel = channel; com.command_type = GF_NET_CHAN_DRM_CFG; ch->is_encrypted = 1; if (gf_isom_is_ismacryp_media(read->mov, track, 1)) { gf_isom_get_ismacryp_info(read->mov, track, 1, NULL, &com.drm_cfg.scheme_type, &com.drm_cfg.scheme_version, &com.drm_cfg.scheme_uri, &com.drm_cfg.kms_uri, NULL, NULL, NULL); gf_term_on_command(read->service, &com, GF_OK); } else if (gf_isom_is_omadrm_media(read->mov, track, 1)) { gf_isom_get_omadrm_info(read->mov, track, 1, NULL, &com.drm_cfg.scheme_type, &com.drm_cfg.scheme_version, &com.drm_cfg.contentID, &com.drm_cfg.kms_uri, &com.drm_cfg.oma_drm_textual_headers, &com.drm_cfg.oma_drm_textual_headers_len, NULL, &com.drm_cfg.oma_drm_crypt_type, NULL, NULL, NULL); gf_media_get_file_hash(gf_isom_get_filename(read->mov), com.drm_cfg.hash); gf_term_on_command(read->service, &com, GF_OK); } } return e; }
GF_Err ISOR_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) { Double track_dur, media_dur; ISOMChannel *ch; ISOMReader *read; u32 count, i; if (!plug || !plug->priv || !com) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; if (read->disconnected) return GF_OK; if (com->command_type==GF_NET_SERVICE_INFO) { u32 tag_len; const char *tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_NAME, &tag, &tag_len)==GF_OK) com->info.name = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_ARTIST, &tag, &tag_len)==GF_OK) com->info.artist = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_ALBUM, &tag, &tag_len)==GF_OK) com->info.album = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_COMMENT, &tag, &tag_len)==GF_OK) com->info.comment = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_TRACK, &tag, &tag_len)==GF_OK) { com->info.track_info = (((tag[2]<<8)|tag[3]) << 16) | ((tag[4]<<8)|tag[5]); } if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_COMPOSER, &tag, &tag_len)==GF_OK) com->info.composer = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_WRITER, &tag, &tag_len)==GF_OK) com->info.writer = tag; if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_GENRE, &tag, &tag_len)==GF_OK) { if (tag[0]) { com->info.genre = 0; } else { com->info.genre = (tag[0]<<8) | tag[1]; } } return GF_OK; } if (com->command_type==GF_NET_SERVICE_HAS_AUDIO) { u32 i, count; count = gf_isom_get_track_count(read->mov); for (i=0; i<count; i++) { if (gf_isom_get_media_type(read->mov, i+1) == GF_ISOM_MEDIA_AUDIO) return GF_OK; } return GF_NOT_SUPPORTED; } if (com->command_type == GF_NET_SERVICE_QUALITY_SWITCH) { count = gf_list_count(read->channels); for (i = 0; i < count; i++) { ch = (ISOMChannel *)gf_list_get(read->channels, i); if (gf_isom_has_scalable_layer(read->mov)) { ch->next_track = gf_channel_switch_quality(ch, read->mov, com->switch_quality.up); } } return GF_OK; } if (com->command_type == GF_NET_SERVICE_PROXY_DATA_RECEIVE) { isor_flush_data(read, 1, com->proxy_data.is_chunk); return GF_OK; } if (com->command_type == GF_NET_SERVICE_FLUSH_DATA) { if (read->nb_playing && plug->query_proxy) isor_flush_data(read, 0, 0); return GF_OK; } if (com->command_type == GF_NET_SERVICE_CAN_REVERSE_PLAYBACK) return GF_OK; if (!com->base.on_channel) return GF_NOT_SUPPORTED; ch = isor_get_channel(read, com->base.on_channel); if (!ch) return GF_STREAM_NOT_FOUND; switch (com->command_type) { case GF_NET_CHAN_SET_PADDING: if (!ch->track) return GF_OK; gf_isom_set_sample_padding(read->mov, ch->track, com->pad.padding_bytes); return GF_OK; case GF_NET_CHAN_SET_PULL: //we don't pull in DASH base services, we flush as soon as we have a complete segment #ifndef DASH_USE_PULL if (read->input->proxy_udta && !read->input->proxy_type) return GF_NOT_SUPPORTED; #endif ch->is_pulling = 1; return GF_OK; case GF_NET_CHAN_INTERACTIVE: return GF_OK; case GF_NET_CHAN_BUFFER: //dash or HTTP, do rebuffer if not disabled if (plug->query_proxy) { } else if (read->dnload) { ch->buffer_min = com->buffer.min; ch->buffer_max = com->buffer.max; } else { com->buffer.max = com->buffer.min = 0; } return GF_OK; case GF_NET_CHAN_DURATION: if (!ch->track) { com->duration.duration = 0; return GF_OK; } ch->duration = gf_isom_get_track_duration(read->mov, ch->track); track_dur = (Double) (s64) ch->duration; track_dur /= read->time_scale; if (gf_isom_get_edit_segment_count(read->mov, ch->track)) { com->duration.duration = (Double) track_dur; ch->duration = (u32) (track_dur * ch->time_scale); } else { /*some file indicate a wrong TrackDuration, get the longest*/ ch->duration = gf_isom_get_media_duration(read->mov, ch->track); media_dur = (Double) (s64) ch->duration; media_dur /= ch->time_scale; com->duration.duration = MAX(track_dur, media_dur); } return GF_OK; case GF_NET_CHAN_PLAY: gf_mx_p(read->segment_mutex); isor_reset_reader(ch); ch->speed = com->play.speed; read->reset_frag_state = 1; if (read->frag_type) read->frag_type = 1; gf_mx_v(read->segment_mutex); ch->start = ch->end = 0; if (com->play.speed>0) { if (com->play.start_range>=0) { ch->start = (u64) (s64) (com->play.start_range * ch->time_scale); ch->start = check_round(ch, ch->start, com->play.start_range, 1); } if (com->play.end_range >= com->play.start_range) { ch->end = (u64) (s64) (com->play.end_range*ch->time_scale); ch->end = check_round(ch, ch->end, com->play.end_range, 0); } } else if (com->play.speed<0) { Double end = com->play.end_range; if (end==-1) end = 0; ch->start = (u64) (s64) (com->play.start_range * ch->time_scale); if (end <= com->play.start_range) ch->end = (u64) (s64) (end * ch->time_scale); } ch->is_playing = 1; if (com->play.dash_segment_switch) ch->wait_for_segment_switch = 1; GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[IsoMedia] Starting channel playback "LLD" to "LLD" (%g to %g)\n", ch->start, ch->end, com->play.start_range, com->play.end_range)); //and check buffer level on play request isor_check_buffer_level(read); read->nb_playing++; return GF_OK; case GF_NET_CHAN_STOP: if (read->nb_playing) read->nb_playing--; isor_reset_reader(ch); return GF_OK; case GF_NET_CHAN_SET_SPEED: gf_mx_p(read->segment_mutex); ch->speed = com->play.speed; gf_mx_v(read->segment_mutex); return GF_OK; /*nothing to do on MP4 for channel config*/ case GF_NET_CHAN_CONFIG: return GF_OK; case GF_NET_CHAN_GET_PIXEL_AR: return gf_isom_get_pixel_aspect_ratio(read->mov, ch->track, 1, &com->par.hSpacing, &com->par.vSpacing); case GF_NET_CHAN_GET_DSI: { /*it may happen that there are conflicting config when using ESD URLs...*/ GF_DecoderConfig *dcd = gf_isom_get_decoder_config(read->mov, ch->track, 1); com->get_dsi.dsi = NULL; com->get_dsi.dsi_len = 0; if (dcd) { if (dcd->decoderSpecificInfo) { com->get_dsi.dsi = dcd->decoderSpecificInfo->data; com->get_dsi.dsi_len = dcd->decoderSpecificInfo->dataLength; dcd->decoderSpecificInfo->data = NULL; } gf_odf_desc_del((GF_Descriptor *) dcd); } return GF_OK; } case GF_NET_CHAN_NALU_MODE: ch->nalu_extract_mode = GF_ISOM_NALU_EXTRACT_INBAND_PS_FLAG; ch->disable_seek = 1; //when this is set, we work in real scalable (eg N streams reassembled by the player) so only extract the layer. This wll need refinements if we plan to support //several scalable layers ... if (com->nalu_mode.extract_mode==1) { ch->nalu_extract_mode |= GF_ISOM_NALU_EXTRACT_ANNEXB_FLAG | GF_ISOM_NALU_EXTRACT_VDRD_FLAG | GF_ISOM_NALU_EXTRACT_LAYER_ONLY; } gf_isom_set_nalu_extract_mode(ch->owner->mov, ch->track, ch->nalu_extract_mode); break; default: break; } return GF_NOT_SUPPORTED; }