void RtpAudioStream::stopPlaying()
{
    if (audio_output_) {
        audio_output_->stop();
        delete audio_output_;
        audio_output_ = NULL;
    }
    emit finishedPlaying();
}
void RtpAudioStream::outputStateChanged()
{
    if (!audio_output_) return;

    if (audio_output_->state() == QAudio::IdleState) {
        // RTP_STREAM_DEBUG("stopped %f", audio_output_->processedUSecs() / 100000.0);
        delete audio_output_;
        audio_output_ = NULL;

        emit finishedPlaying();
    }
}
Exemple #3
0
Cluster::Cluster(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Cluster),
    _list_player(this)
{
    ui->setupUi(this);
    ui->btnPlay->setIcon(QIcon(QPixmap(play_tone_xpm)));
    ui->btnPlay2->setIcon(QIcon(QPixmap(play_frame_xpm)));
    ui->btnStop->setIcon(QIcon(QPixmap(stop_xpm)));
    ui->btnDeleteCluster->setIcon(QIcon(QPixmap(delete_cluster_xpm)));
    _list_player.setList(ui->listWidget);
    connect(&_list_player,
            SIGNAL(finishedPlaying()),
            SLOT(_finished_playing()));
}
void RtpAudioStream::outputStateChanged()
{
    switch (audio_output_->state()) {
    case QAudio::StoppedState:
        // RTP_STREAM_DEBUG("stopped %f", audio_output_->processedUSecs() / 100000.0);
        delete audio_output_;
        audio_output_ = NULL;
        emit finishedPlaying();
        break;
    case QAudio::IdleState:
        audio_output_->stop();
        break;
    default:
        break;
    }
}
void RtpPlayerDialog::addRtpStream(struct _rtp_stream_info *rtp_stream)
{
    if (!rtp_stream) return;

    // Find the RTP streams associated with this conversation.
    // gtk/rtp_player.c:mark_rtp_stream_to_play does this differently.

    RtpAudioStream *audio_stream = NULL;
    int tli_count = ui->streamTreeWidget->topLevelItemCount();
    for (int row = 0; row < tli_count; row++) {
        QTreeWidgetItem *ti = ui->streamTreeWidget->topLevelItem(row);
        RtpAudioStream *row_stream = ti->data(stream_data_col_, Qt::UserRole).value<RtpAudioStream*>();
        if (row_stream->isMatch(rtp_stream)) {
            audio_stream = row_stream;
            break;
        }
    }

    if (!audio_stream) {
        audio_stream = new RtpAudioStream(this, rtp_stream);
        audio_stream->setColor(ColorUtils::graph_colors_[tli_count % ColorUtils::graph_colors_.length()]);

        QTreeWidgetItem *ti = new QTreeWidgetItem(ui->streamTreeWidget);
        ti->setText(src_addr_col_, address_to_qstring(&rtp_stream->src_addr));
        ti->setText(src_port_col_, QString::number(rtp_stream->src_port));
        ti->setText(dst_addr_col_, address_to_qstring(&rtp_stream->dest_addr));
        ti->setText(dst_port_col_, QString::number(rtp_stream->dest_port));
        ti->setText(ssrc_col_, int_to_qstring(rtp_stream->ssrc, 8, 16));
        ti->setText(first_pkt_col_, QString::number(rtp_stream->setup_frame_number));
        ti->setText(num_pkts_col_, QString::number(rtp_stream->packet_count));

        ti->setData(stream_data_col_, Qt::UserRole, QVariant::fromValue(audio_stream));

        for (int col = 0; col < ui->streamTreeWidget->columnCount(); col++) {
            ti->setTextColor(col, audio_stream->color());
        }

        connect(ui->playButton, SIGNAL(clicked(bool)), audio_stream, SLOT(startPlaying()));
        connect(ui->stopButton, SIGNAL(clicked(bool)), audio_stream, SLOT(stopPlaying()));

        connect(audio_stream, SIGNAL(startedPlaying()), this, SLOT(updateWidgets()));
        connect(audio_stream, SIGNAL(finishedPlaying()), this, SLOT(updateWidgets()));
        connect(audio_stream, SIGNAL(processedSecs(double)), this, SLOT(setPlayPosition(double)));
    }
void RtpAudioStream::outputStateChanged(QAudio::State new_state)
{
    if (!audio_output_) return;

    // On some platforms including OS X and Windows, the stateChanged signal
    // is emitted while a QMutexLocker is active. As a result we shouldn't
    // delete audio_output_ here.
    switch (new_state) {
    case QAudio::StoppedState:
        // RTP_STREAM_DEBUG("stopped %f", audio_output_->processedUSecs() / 100000.0);
        audio_output_->disconnect();
        audio_output_->deleteLater();
        audio_output_ = NULL;
        emit finishedPlaying();
        break;
    case QAudio::IdleState:
        audio_output_->stop();
        break;
    default:
        break;
    }
}