Esempio n. 1
0
void
EditViewBase::slotToggleSolo()
{
    // Select the track for this segment.
    getDocument()->getComposition().setSelectedTrack(
            getCurrentSegment()->getTrack());
    getDocument()->getComposition().notifyTrackSelectionChanged(
            getCurrentSegment()->getTrack());
    // Old notification mechanism.
    emit selectTrack(getCurrentSegment()->getTrack());

    // Toggle solo on the selected track.
    // The "false" is ignored.  It was used for the checked state.
    emit toggleSolo(false);
}
Esempio n. 2
0
void
EditViewBase::slotSetSegmentDuration()
{
    Segment *s = getCurrentSegment();
    if (!s)
        return ;

    TimeDialog dialog(this, tr("Segment Duration"),
                      &getDocument()->getComposition(),
                      s->getStartTime(),
                      s->getEndMarkerTime() - s->getStartTime(), 
                      Note(Note::Shortest).getDuration(), false);

    if (dialog.exec() == QDialog::Accepted) {

        SegmentReconfigureCommand *command =
            new SegmentReconfigureCommand(tr("Set Segment Duration"),
                    &getDocument()->getComposition());

        command->addSegment
        (s, s->getStartTime(),
         s->getStartTime() + dialog.getTime(),
         s->getTrack());

        CommandHistory::getInstance()->addCommand(command);
    }
}
Esempio n. 3
0
const char* getCurrentSegmentUrl(void* hSession)
{
    if (gListMgt == NULL) {
        return NULL;
    }

    const char* url = getCurrentSegment(gListMgt)->file;

    return url;
}
Esempio n. 4
0
void
EditViewBase::slotToggleSolo()
{
    QAction *toggleSoloAction = findAction("toggle_solo");
    if (!toggleSoloAction) return;

    bool newSoloState = toggleSoloAction->isChecked();

    //RG_DEBUG << "EditViewBase::slotToggleSolo() : solo action is " << (toggleSoloAction->isCheckable() ? "" : "NOT") << " checkable.";
    //RG_DEBUG << "EditViewBase::slotToggleSolo() : solo  = " << newSoloState;

    emit toggleSolo(newSoloState);

    if (newSoloState) {
        getDocument()->getComposition().setSelectedTrack(
                getCurrentSegment()->getTrack());
        getDocument()->getComposition().notifyTrackSelectionChanged(
                getCurrentSegment()->getTrack());

        // Old notification mechanism.
        emit selectTrack(getCurrentSegment()->getTrack());
    }
}
Esempio n. 5
0
static void *circular_buffer_task( void *_handle)
{
    CacheHttpContext * s = (CacheHttpContext *)_handle;
    URLContext *h = NULL;
    float config_value = 0.0;
    void * fp = NULL;
    int config_ret = 0;

    while(!s->EXIT) {

        av_log(h, AV_LOG_ERROR, "----------circular_buffer_task  item ");
        s->reset_flag = 1;
        if (url_interrupt_cb()) {
            s->circular_buffer_error = EINTR;
            goto FAIL;
        }

        if(h) {
            CacheHttp_ffurl_close(h);
            config_ret = am_getconfig_float("libplayer.hls.dump",&config_value);
            if(config_ret >= 0 && (int)config_value == 2)
                CacheHttp_dump_close(fp);
            h = NULL;
        }

        list_item_t * item = getCurrentSegment(NULL);
        if(!item||(!item->file&&!item->flags&ENDLIST_FLAG)) {
            usleep(WAIT_TIME);
            continue;
        }

        s->reset_flag = 0;
        s->item_starttime = item->start_time;
        s->item_duration = item->duration;
        s->have_list_end = item->have_list_end;
        s->ktype = item->ktype;
        if(item->key_ctx!=NULL&& s->ktype==KEY_AES_128) {
            ff_data_to_hex(s->iv, item->key_ctx->iv, sizeof(item->key_ctx->iv), 0);
            ff_data_to_hex(s->key, item->key_ctx->key, sizeof(item->key_ctx->key), 0);
            s->iv[32] = s->key[32] = '\0';
        }
        if(item&&item->flags&ENDLIST_FLAG) {
            s->finish_flag =1;
        } else {
            s->finish_flag =0;
        }

        if(s->finish_flag) {
            av_log(NULL, AV_LOG_INFO, "ENDLIST_FLAG, return 0\n");
            //break;
            usleep(500*1000);
            continue;
        }

        int err, http_code;
        char* filename = NULL;
        if(s->ktype == KEY_NONE) {
            filename = av_strdup(item->file);

        } else {
            char url[MAX_URL_SIZE];
            if (strstr(item->file, "://"))
                snprintf(url, sizeof(url), "crypto+%s", item->file);
            else
                snprintf(url, sizeof(url), "crypto:%s", item->file);

            filename = av_strdup(url);

        }
        int retry_num = 0;
OPEN_RETRY:
        if(s->RESET)
            goto SKIP;
        err = CacheHttp_advanced_ffurl_open_h(&h, filename,AVIO_FLAG_READ|AVIO_FLAG_NONBLOCK, s->headers, &http_code,s);
        if (err) {
            if(url_interrupt_cb()) {
                if(filename) {
                    av_free(filename);
                    filename = NULL;
                }
                break;
            }
            if(1 == http_code && !s->have_list_end) {
                av_log(h, AV_LOG_ERROR, "----------CacheHttpContext : ffurl_open_h 404\n");
                if(retry_num++ < LIVE_HTTP_RETRY_TIMES) {
                    usleep(WAIT_TIME);
                    goto OPEN_RETRY;
                } else {
                    goto SKIP;
                }
            } else if(s->have_list_end || ((2 == http_code || 3 == http_code)&& !s->have_list_end)) {
                usleep(1000*20);
                goto OPEN_RETRY;
            } else if(!s->have_list_end&&err ==AVERROR(EIO)) {
                if(retry_num++ < LIVE_HTTP_RETRY_TIMES) {//if live streaming,just keep on 2s.
                    usleep(WAIT_TIME);
                    goto OPEN_RETRY;
                } else {
                    av_log(h, AV_LOG_ERROR, "----------CacheHttpContext : ffurl_open_h failed ,%d\n",err);
                    if(filename) {
                        av_free(filename);
                        filename = NULL;
                    }
                    break;
                }

            } else {
                av_log(h, AV_LOG_ERROR, "----------CacheHttpContext : ffurl_open_h failed ,%d\n",err);
                if(filename) {
                    av_free(filename);
                    filename = NULL;
                }
                break;
            }
        }

        if(h && s->seek_flag) {
            int64_t cur_pos = CacheHttp_ffurl_seek(h, 0, SEEK_CUR);
            int64_t pos_ret = CacheHttp_ffurl_seek(h, s->seek_pos-cur_pos, SEEK_CUR);
            av_log(NULL,AV_LOG_INFO,"--------------> cachehttp_seek   seek_pos=%lld, pos_ret=%lld", s->seek_pos, pos_ret);
            s->seek_flag = 0;
        }

        s->hd = h;
        s->item_pos = 0;
        s->item_size = CacheHttp_ffurl_seek(s->hd, 0, AVSEEK_SIZE);
        item->item_size = s->item_size;
        char tmpbuf[TMP_BUFFER_SIZE];
        int left = 0;
        int tmpdatasize = 0;
        config_ret = am_getconfig_float("libplayer.hls.dump",&config_value);
        if(config_ret >= 0 && config_value > 0)
            CacheHttp_dump_open(&fp, filename, (int)config_value);

        while(!s->EXIT) {

            if(s->RESET)
                break;

            if (url_interrupt_cb()) {
                s->circular_buffer_error = EINTR;
                break;
            }

            if(!s->hd)
                break;

            if(s->hd && tmpdatasize <= 0) {
                bandwidth_measure_start_read(s->bandwidth_measure);
                tmpdatasize = CacheHttp_ffurl_read(s->hd, tmpbuf, TMP_BUFFER_SIZE);
                bandwidth_measure_finish_read(s->bandwidth_measure,tmpdatasize);
            }

            //if(tmpdatasize > 0) {
            pthread_mutex_lock(&s->read_mutex);
            left = av_fifo_space(s->fifo);
            left = FFMIN(left, s->fifo->end - s->fifo->wptr);


            if( !left) {
                pthread_mutex_unlock(&s->read_mutex);
                usleep(WAIT_TIME);
                continue;
            }
            left = FFMIN(left, tmpdatasize);
            if(left >0) {
                memcpy(s->fifo->wptr, tmpbuf , left);
                tmpdatasize-=left;
            }
            if(tmpdatasize>0) {
                memmove(tmpbuf, tmpbuf+left , tmpdatasize);
            }

            if (left > 0) {
                config_ret = am_getconfig_float("libplayer.hls.dump",&config_value);
                if(config_ret >= 0 && config_value > 0)
                    CacheHttp_dump_write(fp, s->fifo->wptr, left);
                s->fifo->wptr += left;
                if (s->fifo->wptr >= s->fifo->end)
                    s->fifo->wptr = s->fifo->buffer;
                s->fifo->wndx += left;
                s->item_pos += left;
            } else if(left == AVERROR(EAGAIN) || (left < 0 && s->have_list_end&& left != AVERROR_EOF)) {
                pthread_mutex_unlock(&s->read_mutex);
                continue;
            } else {
                pthread_mutex_unlock(&s->read_mutex);
                av_log(h, AV_LOG_ERROR, "---------- circular_buffer_task read left = %d\n", left);
                break;
            }
            pthread_mutex_unlock(&s->read_mutex);
            //}

            //usleep(WAIT_TIME);

        }

SKIP:
        if(filename) {
            av_free(filename);
            filename = NULL;
        }
        if(!s->RESET)
            switchNextSegment(NULL);
    }

FAIL:

    if(h)
        CacheHttp_ffurl_close(h);
    s->hd = NULL;
    s->EXITED = 1;
    config_ret = am_getconfig_float("libplayer.hls.dump",&config_value);
    if(config_ret >= 0 && config_value > 0)
        CacheHttp_dump_close(fp);
    av_log(NULL, AV_LOG_ERROR, "---------> CacheHttp thread quit !");
    return NULL;
}
JNIEXPORT jint JNICALL Java_com_anvato_android_player_hls_HLSNativeConverter_GetCurrentSegment(JNIEnv *env, jobject obj )
{
	LOGD("GetCurrentSegment() called" );
	
	return getCurrentSegment( );
}