bluetooth/gavdp/test/tavsrcStreamer.h
branchRCL_3
changeset 24 e9b924a62a66
parent 0 29b1cd4cb562
equal deleted inserted replaced
23:5b153be919d4 24:e9b924a62a66
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef TAVSRCSTREAMER_H
       
    17 #define TAVSRCSTREAMER_H
       
    18 
       
    19 #include "tavsrc.h"
       
    20 #include "tavsrcTimer.h"
       
    21 #include "tavsrcStreamerUser.h"
       
    22 
       
    23 #include <f32file.h>
       
    24 #include <rtp.h>
       
    25 
       
    26 static const TInt KLowTidemark = 2;
       
    27 static const TInt KSendBucketSize = 2;
       
    28 	
       
    29 #ifdef __WINS__
       
    30 _LIT(KSBCFileRoot, "c:\\");
       
    31 _LIT(KSBCFiles, "c:\\*.sbc");
       
    32 #else
       
    33 //For reference boards, use the MMC drive, because C: is formatted every reboot
       
    34 _LIT(KSBCFileRoot, "e:\\");
       
    35 _LIT(KSBCFiles, "e:\\*.sbc");
       
    36 #endif
       
    37 
       
    38 class CProgressBar;
       
    39 class CStreamerUI;
       
    40 class CActiveSockWriter;
       
    41 class CActiveSockReader;
       
    42 
       
    43 class TSbcTrackFrameInfo
       
    44 	{
       
    45 public:
       
    46 	TInt iFrameSize;
       
    47 	TUint iFrameCount;
       
    48 	};
       
    49 
       
    50 // used to keep track of the sizes of the SBC frames to allow going backwards through
       
    51 // an SBC file on a frame by frame basis. This is require to support VBR where the
       
    52 // frame sizes can change for a single track.
       
    53 class CSbcTrackInfo : public CBase
       
    54 	{
       
    55 public:
       
    56 	~CSbcTrackInfo();
       
    57 	
       
    58 	TInt GetLastFrameSize();
       
    59 	TInt AddNewFrame(TInt aFrameSize);
       
    60 	TInt RemoveLastFrame();
       
    61 	void Reset();
       
    62 	
       
    63 private:
       
    64 	RArray<TSbcTrackFrameInfo> iFrameInfo;
       
    65 	};
       
    66 
       
    67 class CActiveStreamer : public CBase, private MAdaptiveHighResPeriodicClient
       
    68 	{
       
    69 public:
       
    70 	static CActiveStreamer*	NewL(RSocketArray aSockets,
       
    71 								 CConsoleBase& aConsole,
       
    72 								 MActiveStreamerUser& aUser,
       
    73 								 TUint aDisplayMode,
       
    74 								 TBool aPreloadFile);
       
    75 
       
    76 	~CActiveStreamer();
       
    77 	
       
    78 	static void RTPCallbackL(CActiveStreamer* aStreamer, const TRtpEvent& aEvent);
       
    79 	
       
    80 	// streamer operations
       
    81 	void Stream(TBool aIsSink);
       
    82 	void Suspend();
       
    83 	void ReStream();
       
    84 	void Stop();
       
    85 	void Pause();
       
    86 	void Faster();
       
    87 	void Slower();
       
    88 	void Backward();
       
    89 	void Forward();
       
    90 	void NextTrack();
       
    91 	void PrevTrack();
       
    92 
       
    93 private:
       
    94 	enum TDisplayMode
       
    95 		{
       
    96 		EStatusCommandWindows = 0x00,
       
    97 		EStreamerInfoWindow = 0x01,
       
    98 		EProgressBarWindow = 0x02,
       
    99 		EPlaylistWindow = 0x04,
       
   100 		EChunkyIconWindow = 0x08,
       
   101 		};
       
   102 	
       
   103 private:
       
   104 	CActiveStreamer(CConsoleBase& aConsole, MActiveStreamerUser& aUser, TUint aDisplayMode, TBool aPreloadFile);
       
   105 
       
   106 	void TimerEvent(CAdaptiveHighResPeriodic& aTimer);
       
   107 	void TimerError(CAdaptiveHighResPeriodic& aTimer, TInt aError);
       
   108 	void StartSinkL();
       
   109 	
       
   110 	void ConstructL(RSocketArray aSockets);
       
   111 	TInt LoadFile();
       
   112 	void DoTimerEvent();
       
   113 	void DestroyBucket();
       
   114 	void InitL();
       
   115 
       
   116 	void CreateBucketL();
       
   117 	void FillBucket();
       
   118 	void Drip();
       
   119 	void DrawBucket();
       
   120 	void CheckJammed();
       
   121 
       
   122 	void UpdateFrameInfo();
       
   123 	
       
   124 private:
       
   125 	CConsoleBase& iConsole;
       
   126 	TInt iProgressBarPos;
       
   127 	CProgressBar* iProgressBar;
       
   128 	CStreamerUI* iStreamerUI;
       
   129 	CConsoleBase* iStreamingInfoConsole;
       
   130 	CAdaptiveHighResPeriodic* iTimer;
       
   131 	
       
   132 	RFile iFile;
       
   133 	RFs iRFs;	
       
   134 	CDir* iFiles;
       
   135 	TInt iCurrentFile;
       
   136 	RSocketArray iSockets;
       
   137 	TInt iMTU;
       
   138 	TInt iFileSize;
       
   139 	TTime iStartTime;
       
   140 	
       
   141 	RRtpSession iSession;
       
   142 	RRtpSendSource iSendSource;
       
   143 	RRtpReceiveSource iReceiveSource;
       
   144 	
       
   145 	RArray<RRtpSendPacket> iSendPackets; // used like a queue sometimes
       
   146 	TRtpEventType iEventType;
       
   147 	TBool iRTPCanSend;
       
   148 
       
   149 	TInt iSBCFrameBytesPerRTP;
       
   150 	TInt iSBCFrameSize;
       
   151 	TInt iSBCFrameInterval;
       
   152 	TInt iNumSBCFramesInRTP;
       
   153 	TInt iSBCBitrate;
       
   154 	TInt iSendClockInterval;		// microsecs
       
   155 	TInt iNominalSendClockInterval;// microsecs
       
   156 	TBool iBonusDrip;
       
   157 	TTime iStartedTime;			// for "absolute" timing style
       
   158 		
       
   159 	// checking for jammed streamer, and leaky mbufs
       
   160 	TInt iBucketAppearsJammed;
       
   161 	TBool iBucketJammed;
       
   162 	TTime iLastPacketSentTime;
       
   163 	TInt iPreviousFillLevel;
       
   164 	
       
   165 	TInt iPos;
       
   166 	TInt iFailedSend;
       
   167 	TInt iSent;
       
   168 	TInt iFillLevel;
       
   169 	
       
   170 	HBufC8* iFileBuf;
       
   171 	
       
   172 	// current SEP configuration
       
   173 	TInt iNumChannels;
       
   174 	TInt iChMode;
       
   175 	TInt iNumSubbands;
       
   176 	TInt iBlkLen;
       
   177 	TInt iBitPool;
       
   178 	TInt iFreq;
       
   179 	TInt iAllocMethod;
       
   180 	
       
   181 	MActiveStreamerUser& iUser;	
       
   182 	
       
   183 	TUint iDisplayMode;
       
   184 	TBool iPreloadFile;
       
   185 	
       
   186 	CSbcTrackInfo iSbcTrackInfo;
       
   187 	
       
   188 	TInt iSbcFrameRate;
       
   189 	
       
   190 	TBool iDirectionForward;
       
   191 	};
       
   192 
       
   193 #endif // TAVSRCSTREAMER_H