<commit_before>/*
 * Copyright (C) 2008-2012 The QXmpp developers
 *
 * Author:
 *  <NAME>
 *
 * Source:
 *  http://code.google.com/p/qxmpp
 *
 * This file is a part of QXmpp library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 */

#include <QDomElement>
#include <QTimer>

#include "QXmppCallManager.h"
#include "QXmppClient.h"
#include "QXmppConstants.h"
#include "QXmppJingleIq.h"
#include "QXmppRtpChannel.h"
#include "QXmppStun.h"
#include "QXmppUtils.h"

static int typeId = qRegisterMetaType<QXmppCall::State>();

static const int RTP_COMPONENT = 1;
static const int RTCP_COMPONENT = 2;

static const QLatin1String AUDIO_MEDIA("audio");
static const QLatin1String VIDEO_MEDIA("video");

class QXmppCallPrivate
{
public:
    class Stream {
    public:
        QXmppRtpChannel *channel;
        QXmppIceConnection *connection;
        QString creator;
        QString media;
        QString name;
    };

    QXmppCallPrivate(QXmppCall *qq);
    Stream *createStream(const QString &media);
    Stream *findStreamByMedia(const QString &media);
    Stream *findStreamByName(const QString &name);
    void handleAck(const QXmppIq &iq);
    bool handleDescription(QXmppCallPrivate::Stream *stream, const QXmppJingleIq::Content &content);
    void handleRequest(const QXmppJingleIq &iq);
    bool handleTransport(QXmppCallPrivate::Stream *stream, const QXmppJingleIq::Content &content);
    void setState(QXmppCall::State state);
    bool sendAck(const QXmppJingleIq &iq);
    bool sendInvite();
    bool sendRequest(const QXmppJingleIq &iq);
    void terminate(QXmppJingleIq::Reason::Type reasonType);

    QXmppCall::Direction direction;
    QString jid;
    QString ownJid;
    QXmppCallManager *manager;
    QList<QXmppJingleIq> requests;
    QString sid;
    QXmppCall::State state;

    // Media streams
    bool sendVideo;
    QList<Stream*> streams;
    QIODevice::OpenMode audioMode;
    QIODevice::OpenMode videoMode;

private:
    QXmppCall *q;
};

class QXmppCallManagerPrivate
{
public:
    QXmppCallManagerPrivate(QXmppCallManager *qq);
    QXmppCall *findCall(const QString &sid) const;
    QXmppCall *findCall(const QString &sid, QXmppCall::Direction direction) const;

    QList<QXmppCall*> calls;
    QHostAddress stunHost;
    quint16 stunPort;
    QHostAddress turnHost;
    quint16 turnPort;
    QString turnUser;
    QString turnPassword;

private:
    QXmppCallManager *q;
};

QXmppCallPrivate::QXmppCallPrivate(QXmppCall *qq)
    : state(QXmppCall::ConnectingState),
    manager(0),
    sendVideo(false),
    audioMode(QIODevice::NotOpen),
    videoMode(QIODevice::NotOpen),
    q(qq)
{
}

QXmppCallPrivate::Stream *QXmppCallPrivate::findStreamByMedia(const QString &media)
{
    foreach (Stream *stream, streams)
        if (stream->media == media)
            return stream;
    return 0;
}<commit_msg>re-order member initialization (silences GCC warning)<commit_after>/*
 * Copyright (C) 2008-2012 The QXmpp developers
 *
 * Author:
 *  <NAME>
 *
 * Source:
 *  http://code.google.com/p/qxmpp
 *
 * This file is a part of QXmpp library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 */

#include <QDomElement>
#include <QTimer>

#include "QXmppCallManager.h"
#include "QXmppClient.h"
#include "QXmppConstants.h"
#include "QXmppJingleIq.h"
#include "QXmppRtpChannel.h"
#include "QXmppStun.h"
#include "QXmppUtils.h"

static int typeId = qRegisterMetaType<QXmppCall::State>();

static const int RTP_COMPONENT = 1;
static const int RTCP_COMPONENT = 2;

static const QLatin1String AUDIO_MEDIA("audio");
static const QLatin1String VIDEO_MEDIA("video");

class QXmppCallPrivate
{
public:
    class Stream {
    public:
        QXmppRtpChannel *channel;
        QXmppIceConnection *connection;
        QString creator;
        QString media;
        QString name;
    };

    QXmppCallPrivate(QXmppCall *qq);
    Stream *createStream(const QString &media);
    Stream *findStreamByMedia(const QString &media);
    Stream *findStreamByName(const QString &name);
    void handleAck(const QXmppIq &iq);
    bool handleDescription(QXmppCallPrivate::Stream *stream, const QXmppJingleIq::Content &content);
    void handleRequest(const QXmppJingleIq &iq);
    bool handleTransport(QXmppCallPrivate::Stream *stream, const QXmppJingleIq::Content &content);
    void setState(QXmppCall::State state);
    bool sendAck(const QXmppJingleIq &iq);
    bool sendInvite();
    bool sendRequest(const QXmppJingleIq &iq);
    void terminate(QXmppJingleIq::Reason::Type reasonType);

    QXmppCall::Direction direction;
    QString jid;
    QString ownJid;
    QXmppCallManager *manager;
    QList<QXmppJingleIq> requests;
    QString sid;
    QXmppCall::State state;

    // Media streams
    bool sendVideo;
    QList<Stream*> streams;
    QIODevice::OpenMode audioMode;
    QIODevice::OpenMode videoMode;

private:
    QXmppCall *q;
};

class QXmppCallManagerPrivate
{
public:
    QXmppCallManagerPrivate(QXmppCallManager *qq);
    QXmppCall *findCall(const QString &sid) const;
    QXmppCall *findCall(const QString &sid, QXmppCall::Direction direction) const;

    QList<QXmppCall*> calls;
    QHostAddress stunHost;
    quint16 stunPort;
    QHostAddress turnHost;
    quint16 turnPort;
    QString turnUser;
    QString turnPassword;

private:
    QXmppCallManager *q;
};

QXmppCallPrivate::QXmppCallPrivate(QXmppCall *qq)
    : manager(0),
    state(QXmppCall::ConnectingState),
    sendVideo(false),
    audioMode(QIODevice::NotOpen),
    videoMode(QIODevice::NotOpen),
    q(qq)
{
}

QXmppCallPrivate::Stream *QXmppCallPrivate::findStreamByMedia(const QString &media)
{
    foreach (Stream *stream, streams)
        if (stream->media == media)
            return stream;
    return 0;
}
{'fraction_non_alphanumeric': 0.09420072115384616, 'fraction_numerical': 0.006009615384615385, 'mean_word_length': 4.156467854376452, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6415507', 'n_tokens_mistral': 2282, 'n_tokens_neox': 2246, 'n_words': 585}