Пример #1
0
/*!
  Destructor.
*/
CameraKeyListener::~CameraKeyListener()
{
    if (!m_widget)
        return;

    // Get view's native Symbian window
    WId windowId = 0;

    if (m_widget->internalWinId())
        windowId = m_widget->internalWinId();
    else if (m_widget->parentWidget() && m_widget->effectiveWinId())
        windowId = m_widget->effectiveWinId();

    RWindowBase *window =
            windowId ? static_cast<RWindowBase*>(windowId->DrawableWindow())
                     : 0;

    // Get hold of the window group
    TInt wGroupId = window ? window->WindowGroupId() : 0;

    if (!wGroupId)
        return;

    RWsSession &wsSession = CCoeEnv::Static()->WsSession();
    TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId);

    if (wGroupHandle) {
        RWindowGroup wGroup(wsSession);
        wGroup.Construct(wGroupHandle);
        wGroup.CancelCaptureKey(EKeyCamera);
        wGroup.CancelCaptureKeyUpAndDowns(EKeyCamera);
    }
}
Пример #2
0
/*!
  Constructor, captures the HW camera (shutter) button events and directs them
  to the given widget. Note that the widget must be visible before this
  constructor is called.
*/
CameraKeyListener::CameraKeyListener(QWidget *widget)
    : QObject(widget),
      m_widget(widget)
{
    if (!m_widget) {
        return;
    }

    // Get view's native Symbian window
    WId windowId = 0;

    if (m_widget->internalWinId()) {
        windowId = m_widget->internalWinId();
    }
    else if (m_widget->parentWidget() && m_widget->effectiveWinId()) {
        windowId = m_widget->effectiveWinId();
    }

    RWindowBase *window =
            windowId ? static_cast<RWindowBase*>(windowId->DrawableWindow())
                     : 0;

    // Get hold of the window group
    TInt wGroupId = window ? window->WindowGroupId() : 0;
    if (!wGroupId) {
        return;
    }

    RWsSession &wsSession = CCoeEnv::Static()->WsSession();
    TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId);

    if (wGroupHandle) {
        RWindowGroup wGroup(wsSession);
        wGroup.Construct(wGroupHandle);

        TBool captureOK = ETrue;

        // Capture camera key, in Symbian Belle the key up and downs must
        // be also handled in order to prevent the native camera application
        // to start.
        captureOK = captureOK && (wGroup.CaptureKey(EKeyCamera, 0, 0, 100) > 0);
        captureOK = captureOK && (wGroup.CaptureKeyUpAndDowns(EStdKeyDevice7, 0, 0, 100) > 0);

        if (!captureOK)
            qWarning() << "Unable to register for camera capture key events, "
                       << "SwEvent capability may be missing";
    }
}
/*!
    Constructs the CVideoPlayerUtility2 object with given \a service and \a object.
    And Registers for Video Loading Notifications.
*/
S60VideoPlayerSession::S60VideoPlayerSession(QMediaService *service, S60MediaNetworkAccessControl *object)
    : S60MediaPlayerSession(service)
    , m_accessPointId(0)
    , m_wsSession(&CCoeEnv::Static()->WsSession())
    , m_screenDevice(CCoeEnv::Static()->ScreenDevice())
    , m_service(service)
    , m_player(0)
#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES
    , m_dsaActive(false)
    , m_dsaStopped(false)
#endif
    , m_videoOutputControl(0)
    , m_videoOutputDisplay(0)
    , m_displayWindow(0)
#ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER
    , m_audioOutput(0)
#endif
    , m_audioEndpoint(DefaultAudioEndpoint)
    , m_pendingChanges(0)
    , m_backendInitiatedPause(false)
{
    DP0("S60VideoPlayerSession::S60VideoPlayerSession +++");

    m_networkAccessControl = object;
#ifdef VIDEOOUTPUT_GRAPHICS_SURFACES
    QT_TRAP_THROWING(m_player = CVideoPlayerUtility2::NewL(
                                    *this,
                                    0,
                                    EMdaPriorityPreferenceNone
                                ));
    m_player->RegisterForVideoLoadingNotification(*this);
#else
    RWindow *window = 0;
    QRect extentRect;
    QWidget *widget = QApplication::activeWindow();
    if (!widget)
        widget = QApplication::allWidgets().at(0);
    Q_ASSERT(widget);
    WId wid = widget->effectiveWinId();
    if (!wid)
        wid = widget->winId();
    window = static_cast<RWindow *>(wid->DrawableWindow());
    extentRect = QRect(widget->mapToGlobal(widget->pos()), widget->size());
    TRect clipRect = QRect2TRect(extentRect);
    const TRect desktopRect = QRect2TRect(QApplication::desktop()->screenGeometry());
    clipRect.Intersection(desktopRect);
    QT_TRAP_THROWING(m_player = CVideoPlayerUtility::NewL(
                                    *this,
                                    0,
                                    EMdaPriorityPreferenceNone,
                                    *m_wsSession,
                                    *m_screenDevice,
                                    *window,
                                    QRect2TRect(extentRect),
                                    clipRect));
    m_dsaActive = true;
    m_player->RegisterForVideoLoadingNotification(*this);
#endif // VIDEOOUTPUT_GRAPHICS_SURFACES
    S60VideoPlayerEventHandler::instance()->addApplicationFocusObserver(this);
    DP0("S60VideoPlayerSession::S60VideoPlayerSession ---");
}