Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User Dunderante's Avatar
    Join Date
    Jul 2008
    Posts
    3
    Hi!

    I'm building an application that uses CVidePlayerUtility to play video streams from Darwin Streaming Server. I'm also using multiple views. In one view you can watch a video.

    When i go to the video view first time everything works and the video starts playing. Then I switch view and then switch back to the video view. I then get USER32-CBase 46.

    I know this refers to Stray signal when using Active Objects (CActive). The thing is that i'm not using CActive. So from where is this panic coming from?

    If I Remove/Comment MediaEngine from the code below I don't get the error so I'm pretty sure it's somewhere there the problem lies.

    dbg is just a debugwriter I wrote to be able to debug easier. When I run my aaplication it says The Connection was ok, but I don't receive any events, that is

    void CMediaEngine::EventL(const CConnMonEventBase &aConnMonEvent)
    {


    is never run the second time.


    Please help me.

    class CMediaView: public CAknView

    Code:
    CMediaView* CMediaView::NewLC()
        {
        CMediaView* self = new ( ELeave ) CMediaView();
        CleanupStack::PushL( self );
        self->ConstructL();
        return self;
        }
    
    void CMediaView::ConstructL()
        {
        BaseConstructL( R_MEDIA_VIEW ); //r_Media_view
        }
    
    CMediaView::~CMediaView()
        {
        
        if ( iContainer )
        	{
        	dbg("Deleting MEDIA VIEW container from destructor");
        	AppUi()->RemoveFromStack( iContainer );
        	delete iContainer;
        	iContainer = NULL;
        	}
        if (iMediaEngine){
    
        	dbg("Deleting MEDIA ENGINE from destructor");
            delete iMediaEngine;
            iMediaEngine = NULL;
            }
        }
    
    TUid CMediaView::Id() const
        {
        return TUid::Uid( EMediaViewId );
        }
    
    
    void CMediaView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
                                        TUid /*aCustomMessageId*/,
                                        const TDesC8& aCustomMessage )
        {
        
        dbg("Activating MEDIA VIEW");
        if(!iContainer) {
       		dbg("Creating MEDIA VIEW container");
       		iContainer = CMediaContainer::NewL( ClientRect());
        }
        AppUi()->AddToStackL(*this, iContainer);
       
       if(!iMediaEngine) {
    
    		dbg("Creating MEDIA ENGINE");
       		iMediaEngine = CMediaEngine::NewL(iContainer);
       }
    iAddr.Copy(aCustomMessage);
    	iMediaEngine->InitControllerL(iAddr);
        iContainer->DrawNow();
        }
    void CMediaView::DoDeactivate()
        {
        dbg("Deactivating MEDIA VIEW");
        if (iContainer )
            {
            dbg("Deleting MEDIA VIEW container from deactivator");
            AppUi()->RemoveFromStack( iContainer );
            delete iContainer;
            iContainer = NULL;
        }
        
        if (iMediaEngine) {
    
        	dbg("Deleting MEDIA ENGINE from deactivator");
        	delete iMediaEngine;
        	dbg("deleted MEDIA ENGINE from deactivator");
        	iMediaEngine = NULL;
        }
    void CMediaView::HandleCommandL( TInt aCommand )
        {
    
        switch(aCommand) {
        	iMediaEngine->Stop();
           	case ECTVDone:
           		{
           		
           		AppUi()->ActivateLocalViewL(TUid::Uid(EStatViewId),TUid::Uid(100),iAddr);
           		break;
           	}/*
           	case EAknSoftkeyYes:
               		{
               		TBuf8<200> address;
               		address.Copy(iContainer->GetSDP());
               		AppUi()->ActivateLocalViewL(TUid::Uid(EMediaViewId),TUid::Uid(1),address);
               		break;
               	}*/
           	case EEikCmdExit:
           	
           	case EAknSoftkeyAbort:{
    
           		//iMediaEngine->Stop();
           		AppUi()->ActivateLocalViewL(TUid::Uid(EWatchViewId));
           		break;
           	}
           	case ECTVMainMenu:{
    
           		//iMediaEngine->Stop();
           		AppUi()->ActivateLocalViewL(TUid::Uid(EMainMenuViewId));
           		break;
           	}
           	default:
    
           	   // iMediaEngine->Stop();
           		AppUi()->HandleCommandL( aCommand );
           		break;
           	}
        }
    
    void CMediaView::HandleSizeChange( TInt aType )
        {
        if( iContainer )
            {
            iContainer->HandleResourceChange( aType );
            
            if ( aType==KEikDynamicLayoutVariantSwitch )
                {        
                TRect rect;
                AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
                iContainer->SetRect(rect);
                }
            }         
        }
    class CMediaEngine : public MVideoPlayerUtilityObserver, MConnectionMonitorObserver, CBase

    Code:
    CMediaEngine::CMediaEngine():iPlayer(NULL) //ANte
    	{
    	// No implementation required
    	}
    void CMediaEngine::ConstructL(CMediaContainer* aView)
    	{
    	iView = aView;
    	}
    CMediaEngine* CMediaEngine::NewL(CMediaContainer* aView)
    	{
    	CMediaEngine* self = new (ELeave) CMediaEngine();
    	CleanupStack::PushL(self);
    	self->ConstructL(aView);
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    
    
    void CMediaEngine::InitControllerL(TBuf8<200> addr)
    	{
    
    		dbg("\n\n ************* Entering InitController v0.25 ***************");
    
    		iPlayer = NULL;
    
    		ReadIPFromFile(addr);
    		dbg("INNAN connectL");
    		TInt err = iConnMon.ConnectL();
    		dbg("EFTRE connectL");
    		iConnMon.NotifyEventL( *this );
    
    		RHostResolver iResolver;
    		RSocketServ sock;
    		dbg("INNAN connect");
    		User::LeaveIfError(sock.Connect());
    		dbg("EFTER connect");
    		err = iResolver.Open(sock,KAfInet, KProtocolInetUdp);
    
    		if (err != 0) {
    			dbg("Error in connection: %d",err);
    		}
    		else{
    			dbg("Connection ok");
    			TNameEntry nameEntry;
    			status = -1;
    			iResolver.GetByName(_L("http://www.google.se"),nameEntry,status);
    		}
    
    
    	}
    
    
    
    void CMediaEngine::EventL(const CConnMonEventBase &aConnMonEvent)
    	{
    		/*_LIT(KUrlVideos, "rtsp://rtsp.youtube.com/youtube/videos/bxabHg--WBE/video.3gp");
    		const char * str = "rtsp://rtsp.youtube.com/youtube/videos/bxabHg--WBE/video.3gp";
    		//_LIT(KUrlVideos, str);
    
    		_LIT(param,"");
    		param.Format("%s",_L("hej"));*/
    dbg("inne i event");
    		TInt event = aConnMonEvent.EventType();
    		TRequestStatus istatus;
    		dbg("Eventtype: %i",event);
    	 	if (event == EConnMonCreateConnection){
    	 		dbg("New connection");
    	 		TUint connId = aConnMonEvent.ConnectionId();
    	 		iConnMon.GetUintAttribute(connId, 0, KIAPId, iapId, istatus);
    	 		User::WaitForRequest( istatus );
    	 		iPlayer = NULL; //ANte
    	 		iPlayer = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
    	 				 		 					EMdaPriorityPreferenceNone,
    	 				 		 					iView->ClientWsSession(),
    	 				 		 					iView->ScreenDevice(),
    	 				 		 					iView->ClientWindow(),
    	 				 		 					iView->VideoRect(),
    	 				 		 					iView->VideoRect() );
    	 		//iPlayer->OpenUrlL(KUrlVideos, KUseDefaultIap, KNullDesC8, KNullUid);
    	 		//TInt leaveCode;
    	 		//TRAP(leaveCode, iPlayer->OpenUrlL(KUrlVideos));
    	 		//iPlayer->OpenUrlL(KUrlVideos);
    
    	 		//iPlayer->OpenUrlL(KUrlVideos, iapId, KNullDesC8, KNullUid);
    	 		iPlayer->OpenUrlL(url, iapId, KNullDesC8, KNullUid);
    	 		User::WaitForRequest(status);
    	 	}
    
    	}
    
    
    void CMediaEngine::ReadIPFromFile(TBuf8<200> addr)
    	{
    			
    			TBuf8<200> atext;
    			_LIT(text,"rtsp://217.174.93.71:554/");
    			atext.Copy(text);
    			atext.Append(addr);
    			atext.Append(_L(".sdp"));
    			url.Copy(atext);
    			//url.Copy(_L("rtsp://217.174.93.64:554/test1.sdp"));
    	//url.Copy(_L("rtsp/test1.sdp"));
    		}
    
    
    
    void CMediaEngine::MvpuoOpenComplete(TInt aError)
    	{
    		if(aError == KErrNone) {
    			dbg("Prepairing video");
    			iPlayer->Prepare();
    		} else {
    			dbg("Open Complete: %d", aError);
    		}
    	}
    void CMediaEngine::MvpuoPrepareComplete(TInt aError)
    	{
    		if (aError == KErrNone) {
    			dbg("Playing video");
    			iPlayer->Play();
    		} else {
    			dbg("Prepare Complete: %d", aError);
    		}
    	}
    void CMediaEngine::MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError)
    	{
    		//do nothing
    	}
    void CMediaEngine::MvpuoPlayComplete(TInt aError)
    	{
    
    		iPlayer->Stop();
    		iPlayer->Close();
    		//do nothing
    	}
    void CMediaEngine::MvpuoEvent(const TMMFEvent& aEvent)
    	{
    		//do nothing
    	}
    void CMediaEngine::PauseL()
    	{
    		iPlayer->PauseL();
    	}
    TTimeIntervalMicroSeconds CMediaEngine::PositionL()
    	{
    		return iPlayer->PositionL();
    	}
    TTimeIntervalMicroSeconds CMediaEngine::DurationL()
    	{
    		return iPlayer->DurationL();
    	}
    void CMediaEngine::Stop()
    	{
    		iPlayer->Stop();
    	}
    CMediaEngine::~CMediaEngine()
    	{
    	dbg("first in destructor");
    	if(iPlayer != NULL)
    		{
    		delete iPlayer;
    		iPlayer = NULL;
    		dbg("deleted iPLayer");
    		}
    	}
    class CMediaContainer : public CCoeControl

    Code:
    CMediaContainer* CMediaContainer::NewL(const TRect& aRect)
    	{
    	CMediaContainer* self = CMediaContainer::NewLC(aRect);
    	CleanupStack::Pop(self); // self;
    	return self;
    	}
    
    CMediaContainer* CMediaContainer::NewLC(const TRect& aRect)
    	{
    	CMediaContainer* self = new (ELeave) CMediaContainer();
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    	}
    
    void CMediaContainer::ConstructL(const TRect& aRect)
    	{
    	CreateWindowL();
    	iVideoRect = Rect();
    	iVideoRect.iTl.iX += 0; //aRect.iTl.iX; //point.iX;
    	iVideoRect.iTl.iY += 0; //aRect.iTl.iX;; //point.iY;
    	iVideoRect.iBr.iX += 240; //aRect.iTl.iX;; //point.iX;
    	iVideoRect.iBr.iY += 180; //aRect.iTl.iX;; //point.iY;
    	SetRect(iVideoRect);
    	ActivateL();
    	}
    
    void CMediaContainer::Resize()
    	{
    	iVideoRect.iTl.iX = 0; //aRect.iTl.iX; //point.iX;
    	iVideoRect.iTl.iY = 0; //aRect.iTl.iX;; //point.iY;
    	iVideoRect.iBr.iX = 240; //aRect.iTl.iX;; //point.iX;
    	iVideoRect.iBr.iY = 180; //aRect.iTl.iX;; //point.iY;
    	SetRect(iVideoRect);
    	//DrawNow();
    	}
    
    
    void CMediaContainer::Draw(const TRect&) const
    	{
    	CWindowGc& gc = SystemGc();
    	gc.SetBrushColor(KRgbGreen);
    	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    	//TRect rect = Rect();
    	//gc.Clear(rect);
    	gc.DrawRect(iVideoRect);
    	dbg("draw green screen");
    	}
    
    CMediaContainer::CMediaContainer()
    	{
    	}
    
    CMediaContainer::~CMediaContainer()
    	{
    	}

  2. #2
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,672
    a bit too much code there really. Anyway you should make sure you do cancel & close all functions that are running.

    Also you do have quite many AO's there really, and at least the GetByName is not handled correctly.. So please check your code again.

  3. #3
    Registered User Dunderante's Avatar
    Join Date
    Jul 2008
    Posts
    3
    Problem solved.

    I put
    Code:
    iResolver.Cancel();
    iResolver.Close();
    iSock.Close();
    iConnMon.CancelNotifications();
    iConnMon.Close();
    in the destructor of mediaengine. Thanks for the reply.
    What do you mean by AOs anyway?

  4. #4
    Registered User Sorcery-ltd's Avatar
    Join Date
    Dec 2006
    Posts
    2,280
    AOs = Active Objects

Similar Threads

  1. CBase inheritance & Cleanup stack
    By barrydrink in forum Symbian C++
    Replies: 4
    Last Post: 2008-11-13, 20:22
  2. CBase constructor
    By sameer.chaudhari in forum Symbian C++
    Replies: 2
    Last Post: 2008-05-19, 15:12
  3. Replies: 2
    Last Post: 2007-11-19, 15:45
  4. illegal implicit conversion from '__T?'
    By 3kstou in forum Symbian
    Replies: 5
    Last Post: 2007-06-14, 06:32
  5. Problem with inheritance (CBase)
    By julppoupou in forum Symbian C++
    Replies: 2
    Last Post: 2005-08-01, 07:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved