symba (779893), страница 43
Текст из файла (страница 43)
It requires an observer instance thatimplements the MMMTunerObserver interface. You can re-use the sameinstance that you have for the main CMMTunerUtility class or you cancreate a separate one. The scanner utility is then controlled via two mainmethods: StationScan() starts the station scan and StopScan()stops scanning and uses the currently tuned station.7.3.6 Radio Data SystemRadio Data System (RDS) allows broadcasters to embed some metadataand text information into FM radio stations. This allows radios to displaythe station name, music genre and other useful information. Where thehardware supports RDS (which can be queried when you probe a tuner’scapabilities, see Section 7.2.1), the Tuner API lets you access the RDSdata via the CMMRdsTunerUtility class.204THE TUNER APIFetching into TRdsDataAs with the other utilities, there is a method in the main tuner utilityclass, GetRdsTunerUtilityL(), that creates an instance of CMMRdsTunerUtility for you.
Similarly to the scanner utility, it expectsa tuner observer as one of its parameters. You can re-use your existingobserver if you wish.Not every radio station broadcasts RDS data, so before attemptingto use any RDS features it is recommended that you call the IsRdsSignal() method to query whether RDS data is present. If it is, youcan retrieve information about the currently tuned station by using theGetRdsData() method, which reads the station’s data into a TRdsDataobject. By default, all available data is fetched but you can limit it to a specific subset by using bitwise OR with values from TRdsData::TFieldthat represent the information you need and passing this into GetRdsData() as the aWhichData parameter.
Alternatively, you can requestall of the data and extract the items you want separately afterwards. Forinstance, to retrieve the name of the currently tuned station, you coulddo the following:// get the RDS utilityiMyRdsUtil = iMyTunerUtility->GetRdsTunerUtilityL( *iMyTunerObserver );// make sure current station is broadcasting RDS dataif (iMyRdsUtil->IsRdsSignal() ){// create RDS data object to hold infoTRdsData stationData();// fetch station dataTUint32 whatInfoIsValid = 0;iMyRdsUtil->GetRdsData( stationData, whatInfoIsValid );// check station name is presentif (whatInfoIsValid & TRdsData::EStationName ){// extract station nameTRdsStationName stationName = stationData.iPs;// ...
do something with the name}}Other RDS DataThere are a number of additional RDS features besides what is coveredin TRdsData. The RDS utility provides a number of Get() methodsto access this information. Since the data may change throughout thebroadcast there are also a number of Notify() methods that enableyou to register for notifications when the data changes. Notifications canbe canceled using the corresponding Cancel() methods in the RDSutility.
Although all of these follow the same general pattern each has aBASIC USE CASES205specialized observer interface to handle its notifications. Please refer tothe developer library’s API documentation on CMMRdsTunerUtilityfor the details.Different phones may or may not support all of these advanced RDSfeatures so it makes sense to check which are available on your deviceusing the RDS utility’s GetRdsCapabilities() method. For example,to see if the RadioText feature is supported and register for notifications,you could do something like the following:// get the RDS utilityiMyRdsUtil =iMyTunerUtility->GetRdsTunerUtility( *iMyTunerObserver );// this will contain the capabilitiesTRdsCapabilities rdsCaps;iMyTunerUtility->GetRdsCapabilities( rdsCaps );if ( rdsCaps.iRdsFunctions & ERdsFunctionRt ){// Radio Text is supported!// register for notifications ...iMyTunerUtility->NotifyRadioText( *iRdsDataObserver );}Advanced FeaturesBeyond fetching information on the currently tuned radio station thereare a few extra features in the RDS utility.
They are explained in the APIdocumentation, so we just outline them here:• Searching for stations: You can scan for the next station which has aspecific RDS property (such as program type). This behaves similarlyto StationSeek(), discussed in Section 7.3.4. Look up the RDSutility’s StationSearchByXxx() methods for more information.• Traffic and news announcements: If supported by the broadcaster,the RDS utility can automatically re-tune to another station that hastraffic or news announcements when they come in and then tuneback once the announcement has ended.
Look up the RDS utility’sSetNewsAnnouncement() and SetTrafficAnnouncement()methods for more information.• Regional link: Some national radio stations broadcast on differentfrequencies in different regions. If they support the regional linkfeature, the RDS utility can automatically switch to the station’salternative frequency if the signal on the currently tuned one is gettingweak. This allows the end user to continue listening to the samestation with no interruption when traveling between regions.
Look upthe RDS utility’s SetRegionalLink() method for more informationon this.206THE TUNER API7.4 Future Technologies7.4.1 Digital Audio BroadcastingDigital Audio Broadcasting (DAB) is a standard for broadcasting digitalradio. It is currently in use in a number of countries.
Looking at the APIdocumentation for the tuner utility, you may notice a few references toDAB; for example, the tuning functions have variants that take channelnumbers instead of frequencies. However, there is no support in thecurrent API for DAB’s more advanced features, such as DLS radio text, soextensions would be necessary if full support were required.So far there have been no Symbian smartphones with DAB support.However, other technologies such as streaming Internet radio and mobileTV can offer a similar experience to DAB and are more fully supported inSymbian OS. Mobile TV is briefly covered in Section 7.4.2 and Internetstreaming is handled by the MMF APIs.7.4.2 Mobile TVThere are now a number of standards for broadcasting digital televisionservices to mobile devices, such as DVB-H, DMB and ISDB-T 1seg.
Notethat these are completely separate from streaming audio or video overan Internet connection. Streaming is usually a one-to-one connectionbetween a server and a client application,5 so each new connection takesup a piece of the available bandwidth. Therefore there is a finite limitto how many streaming users there can be in a cellular network at anygiven time. Broadcasting, on the other hand, is a one-to-many connectionwhere a tower broadcasts a signal that can be picked up by any numberof receivers.Although the various mobile TV standards are technically quite different from one another, they generally deliver the same kind of services tothe user: a number of digital TV and audio channels, an electronic serviceguide (ESG) that lists channel and program details, support for subscription and pay-per-view channels and data services (teletext, filecasting,etc.).
Since the functionality they offer is much richer and more complexthan analog radio, the tuner API is not suitable for controlling them.There is some support for mobile TV in Symbian OS, but it is in theform of a low-level hardware abstraction layer (HAL) that standardizes theinterface between drivers for DVB-H receiver hardware and middlewareproducts that take care of processing the received data in order to extractESG data and TV services. The user-facing applications that allow youto watch TV are generally developed by the licensees and their partners5Strictly speaking this is unicast streaming.
Multicast streaming allows a single stream ofdata to go to any number of recipients on the network. Some mobile TV standards, such asMBMS, use multicasting over cellular networks to deliver TV services.SAMPLE CODE207and talk directly to whatever middleware is present in the device. Thereis no standard Symbian API at this level for third-party applicationdevelopers.7.5 Sample CodeSymbian OS C++ for Mobile Phones, Volume 3 by Richard Harrison andMark Shackman (2007) provides sample code for the tuner API. The codeis available from developer.symbian.com/main/documentation/books/books files/scmp v3/index.jsp (use the source code link near the bottomright corner of the page). The example is in the \multimedia\tunerdirectory after you have installed the code package.