Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/phonon/gstreamer/mediaobject.cpp

    r2 r561  
    8888
    8989    if (!m_backend->isValid()) {
    90         setError(tr("Cannot start playback. \n\nCheck your Gstreamer installation and make sure you "
     90        setError(tr("Cannot start playback. \n\nCheck your GStreamer installation and make sure you "
    9191                    "\nhave libgstreamer-plugins-base installed."), Phonon::FatalError);
    9292    } else {
     
    9696        connect(m_tickTimer, SIGNAL(timeout()), SLOT(emitTick()));
    9797    }
    98     connect(this, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
    99             this, SLOT(notifyStateChange(Phonon::State, Phonon::State)));
     98    connect(this, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
     99            this, SLOT(notifyStateChange(Phonon::State,Phonon::State)));
    100100
    101101}
     
    227227
    228228    // These functions require GStreamer > 0.10.12
     229#ifndef QT_NO_LIBRARY
    229230    static Ptr_gst_pb_utils_init p_gst_pb_utils_init = 0;
    230231    static Ptr_gst_pb_utils_get_codec_description p_gst_pb_utils_get_codec_description = 0;
     
    240241        value = QString::fromUtf8(codecName);
    241242        g_free (codecName);
    242     } else {
     243    } else
     244#endif //QT_NO_LIBRARY
     245    {
    243246        // For GStreamer versions < 0.10.12
    244247        GstStructure *str = gst_caps_get_structure (caps, 0);
    245248        value = QString::fromUtf8(gst_structure_get_name (str));
     249
    246250    }
    247251    media->addMissingCodecName(value);
     
    341345    GstPad *decodepad = static_cast<GstPad*>(data);
    342346    gst_pad_link (pad, decodepad);
    343     gst_object_unref (decodepad);
     347    //gst_object_unref (decodepad);
    344348}
    345349
     
    369373    if (!m_datasource)
    370374        return false;
     375
     376    // Set the device for MediaSource::Disc
     377    if (m_source.type() == MediaSource::Disc) {
     378
     379        if (g_object_class_find_property (G_OBJECT_GET_CLASS (m_datasource), "device")) {
     380            QByteArray mediaDevice = QFile::encodeName(m_source.deviceName());
     381            if (!mediaDevice.isEmpty())
     382                g_object_set (G_OBJECT (m_datasource), "device", mediaDevice.constData(), (const char*)NULL);
     383        }
     384
     385        // Also Set optical disc speed to 2X for Audio CD
     386        if (m_source.discType() == Phonon::Cd
     387            && (g_object_class_find_property (G_OBJECT_GET_CLASS (m_datasource), "read-speed"))) {
     388            g_object_set (G_OBJECT (m_datasource), "read-speed", 2, (const char*)NULL);
     389            m_backend->logMessage(QString("new device speed : 2X"), Backend::Info, this);
     390        }
     391    }
    371392
    372393    // Link data source into pipeline
     
    388409bool MediaObject::createPipefromStream(const MediaSource &source)
    389410{
     411#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
    390412    // Remove any existing data source
    391413    if (m_datasource) {
     
    409431    }
    410432    return true;
     433#else //QT_NO_PHONON_ABSTRACTMEDIASTREAM
     434    Q_UNUSED(source);
     435    return false;
     436#endif
    411437}
    412438
     
    903929        break;
    904930
    905     case MediaSource::Disc: // CD tracks can be specified by setting the url in the following way uri=cdda:4
     931    case MediaSource::Disc:
    906932        {
    907             QUrl cdurl(QLatin1String("cdda://"));
    908             if (createPipefromURL(cdurl))
     933            QString mediaUrl;
     934            switch (source.discType()) {
     935            case Phonon::NoDisc:
     936                qWarning() << "I should never get to see a MediaSource that is a disc but doesn't specify which one";
     937                return;
     938            case Phonon::Cd:  // CD tracks can be specified by setting the url in the following way uri=cdda:4
     939                mediaUrl = QLatin1String("cdda://");
     940                break;
     941            case Phonon::Dvd:
     942                mediaUrl = QLatin1String("dvd://");
     943                break;
     944            case Phonon::Vcd:
     945                mediaUrl = QLatin1String("vcd://");
     946                break;
     947            default:
     948                qWarning() <<  "media " << source.discType() << " not implemented";
     949                return;
     950            }
     951            if (!mediaUrl.isEmpty() && createPipefromURL(QUrl(mediaUrl)))
    909952                m_loading = true;
    910953            else
     
    9661009    GstFormat format = gst_format_get_by_nick("track");
    9671010    if (gst_element_query_duration (m_pipeline, &format, &titleCount)) {
    968         int oldAvailableTitles = m_availableTitles;
    969         m_availableTitles = (int)titleCount;
    970         if (m_availableTitles != oldAvailableTitles) {
    971             emit availableTitlesChanged(m_availableTitles);
    972             m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
     1011        //check if returned format is still "track",
     1012        //gstreamer sometimes returns the total time, if tracks information is not available.
     1013        if (qstrcmp(gst_format_get_name(format), "track") == 0)  {
     1014            int oldAvailableTitles = m_availableTitles;
     1015            m_availableTitles = (int)titleCount;
     1016            if (m_availableTitles != oldAvailableTitles) {
     1017                emit availableTitlesChanged(m_availableTitles);
     1018                m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
     1019            }
    9731020        }
    9741021    }
Note: See TracChangeset for help on using the changeset viewer.