Android MMS: Deep MMS Support _android

Source: Internet
Author: User
Tags data structures unpack

Composing and editing
MMS in the Android MMS application of the specific implementation of the form, or data structure is slideshowmodel, it is a node for each Slidemodel Arraylist,slidemodel is a model list, That is, it can receive any model of the subclass, Audio,video,image and text can be placed on the slidemodel above. Slidemodel is mainly used to manage the various media on top of it, such as their layout, their playback control, and Slideshowmodel is mainly used to manage all the attachments, such as converting all the attachments into the data type PDU of the Android MMS protocol, and transform from PDU to Slideshowmodel.
PDU is the implementation of the MMS protocol standard format, it can be directly sent to MMSc, from the mmsc back to the data is a PDU format. Application layer MMS does not need to care about the specific implementation of the PDU, there is an internal package in Android com.google.android.mms.* the following classes are specifically designed to handle MMS on the Android platform. It provides the work can put the application layer of data, such as media files, packaging into a PDU, and then decompose the PDU into a media file. The PDU's data structure includes Pdubody, which is where the multimedia files are stored, which is a collection of Pdupart, each pdupart represents a file. Pdupersister is used to manipulate these data structures, including writing to the database, reading from the database, and so on.

Slideshowmodel or commonly known as slides is the implementation of MMS in the application layer, or it is a data structure used by the application layer MMS to create, edit, display, and manage multimedia. When you create and send MMS, you create a slideshowmodel, build a Mediamodel,textmodel, and join the Slideshowmodel. At the time of sending, the Slideshowmodel will take out the media files inside and convert them into Pdupart into pdubody. After receiving the information, remove the Pdupart from the Pdubody, restore to the media file, generate Mediamodel, add to Slideshowmodel, that is, revert to the slide. The application can be displayed and played after the slide.

Attachment Type
With regard to attachment types, all MMS in MMS applications has a slide that contains all the attachment files. But MMS does some special processing, for an MMS information, its attachment types are divided into image, AUDIO, video, and slideshow, which can be seen from the list of Add Attachments dialog box, and the presentation is different. But the actual implementation is not so many types, only a slideshowmodel, all the accessories are inside. The rule that it handles is that if only one media (image, audio, and video) is added, the type is set to the appropriate media type, and the attachment type will be a slide only if you explicitly choose to add the slide in the Attachment dialog box and add more slides. This attachment type is valid only when adding attachments to MMS and before sending MMS. Mainly used in the message list how to display media files, if the specific media type, directly displayed, otherwise displayed as a slide, this attachment type only exists in the application display media use, and will not be sent out in the PDU traces. When the MMS is received, it is also based on the contents of the transformed Slideshowmodel to infer the attachment type, and then do the display. So, for a MMS, it always has a slideshowmodel, the user's feeling of attachment type is only the attachment of the media to show the above one processing.

Creating and editing MMS
Unlike traditional handsets, creating MMS does not require a special approach. Because MMS applications are not strictly differentiated between MMS and SMS, but are treated as a single message in a unified conversation, the difference between MMS and SMS is simple, and there is only one message that has an attachment (Workingmessage.hasattachment ()). Creating MMS is also very simple, just click on the composer and the Attach menu to add media. Select image in the list, audio and video after only one media file, will run to other activity to select the file, and then return its URI to composer, Composer calls Workingmessage.setattachment () to do the concrete additions, creates the Mediamodel with the URI, then joins Slideshowmodel, and sets the type. In addition, if you select the Attach slide, you will go directly to the editing slides, you can add the Delete slide page, the slide page with the media file, set the layout, and so on, and then composer will slideshowmodel display, the attachment type is also slideshow , these are done through Workingmessage.load ().
Workingmessage after adding the media to the slide, it recalls an interface onattachmentchanged (), composer implements this interface, which is used primarily to notify composer that the attachment has changed and refresh the UI to properly display the attachment. Composer creates attachmenteditor to display the contents of the attachment, because all of the attachments are placed inside the slideshow slideshow in Workingmessage, can be obtained by workingmessage.getslideshow (). Attachmenteditor will create different view to show different attachments according to the contents of slideshow, if only one video,audio or image in slideshow, create Videoattachmentview directly , Audioattachmentview or Imageattachmentview, and Slideshowattachmentview is created for the number of pages in the slide greater than 1 o'clock. and the corresponding buttons can be used to edit, replace or delete, for a single media has to view/play, select can view the original image and play audio video, replacement can be reset to select an attachment, delete will remove the attachment; for slideshow, edit and delete, edit will go directly to the slide edit page, There can be a page on each page of the slide detailed edit, delete will remove the attachment.

After editing the attachment there are three ways of handling, one is to send information, one is saved as a draft and the other is to give up information. Sending information and saving drafts will package the slides, turn them into PDUs, and save them to the database, after which the slides need to be loaded from the database and the PDU unpacked into Slidehshowmodel.

Packaging and unpackaging MMS
To send a message, or to save a draft, you need to package the Slideshowmodel to generate the PDU format and save it to the database. This package called MMS (packaging) is done by the Slideshowmodel.makepdubody () method, which takes the contents of a slide out one by one, turns it into a pdupart, and puts it into the pdubody. To generate Pdubody, a medium corresponds to a pdupart, and you can also set pdupart properties to describe the media file, such as ContentType, a string that identifies the type of media mime, the name of the filename file; The path to the Contentlocation file. This information is used to describe the meta information (MetaData) of the data in the Pdupart, which is what the data is, so that the data is handled correctly when the packet is unpack.
Later, Pdupersister will deposit pdubody into the database through its persist () method, which writes descriptive information from Pdupart to the database field and stores the file under the Telephonyprovider folder(/data/data/android.providers.telephony/app_parts), and writes the stored path as the _data field to the database, so that an MMS data is written to the database. After this, MMS data is loaded from the database, so the database in the original Slideshowmodel is no longer valid, such as the URI in the original Slideshowmodel may point to a file, or other databases, in thepdupersister.persist ()And then it doesn't work anymore.
After Pdupersister.persist (), the MMS's attachments are loaded from the data, and pdupersister.load () loads the data from the database into a pdubody, The Slideshowmodel Method Createfrompdubody () is used to convert pdubody into a slideshowmodel, remove media information from Pdupart to get the correct media format, and related information, You can obtain a specific file (stream) through a URI.
The process of receiving MMS is almost the same when notificationtransaction or retrievetransaction uses httputils to obtain MMS data from MMSC, it uses Pduparser to parse data generation PDU. It is then written to the database using Pdupersister.persist (), which is then loaded from the database.

Smil Language Support
One important piece of data for each MMS is the SMIL language, which is the abbreviation for the Synchronized Multimedia Integration language (Synchronized Multimedia integration Language), which is similar to the HTML document and is the world Wide Web Consortium) organizes the standard language of multimedia manipulation. MMS also uses it to manage and play multimedia. Take a look at a specific Smil language example:

Copy Code code as follows:

<smil xmlns= "Http://www.w3.org/2000/SMIL20/CR/Language" >
<layout>
<root-layout width= "360" height= "615"/>
<region id= "Image" width= "347" height= "the" top= "7" left= "fit=" Meet
<region id= "Text" width= "326" height= "7" top= "281" "left=" fit= "scroll"
</layout>
<body>
<par dur= "60s" >

<text src = "0.txt" region= "text"/>
</par>
<par dur= "60s" >
<text src = "1.txt" region= "text"/>
</par>
<par dur= "60s" >
<text src = "2.txt" region= "text"/>
</par>
<par dur= "60s" >
<text src = "3.txt" region= "text"/>
</par>
<par dur= "60s" >
<text src = "4.txt" region= "text"/>
</par>
</body>
</smil>

The Smil language is usually a page when playing multimedia, and is very similar to a phantom playback, as many smil players are made into slide forms. Because MMS uses SMIL to transfer multimedia, MMS terminal applications play MMS in the form of slides. This is why MMS applications will come out Slideshowmodel. Slideshow is a common way to display MMS. Even though some terminal applications do not display MMS in the form of a slide show, the MMS has a page number for the carrier or MMS platform, and other mobile phones, such as non-smartphones, view the MMS as a slide-page show.

It mainly records the layout information used for slides. This smil language is for slide layouts, which means that SMIL will be like HTML document Layout page to explain how to layout slides, it has these tag:head, layout, body, Par,head is header information, there are tag Layout is used to illustrate how this slide is laid out, and it uses some sub tags such as root-layout, region, and so on to explain how each element of the slide, such as image or text, is laid out. Tag body lists all the media Elements and details of the slide, such as image, audio, text, and so on, each par is a page, and its son tag explains what the page has, of course, there are a lot of smil language content can refer to Wikipedia on the explanation.

When the slide is packaged, that is, converting the slideshowmodel into a PDU, a Smil language is generated based on the content of Slideshowmodel, and a SMIL document is generated by Smilhelper.getdocument (). Add it to the Pdubody and as the first Pdupart, its contenttype (MIME) is Application/smil, and its content is the SMIL document. It is important to note that the SMIL document is always in the first part of the Pdubody, and that it directly writes the contents of the document into the Pdupart, rather than in the form of a file.
When the packet is unpack, the SMIL document is first removed, parsed, and the slides are generated.

Because SMIL is a standard document, the consortium has its own specifications, as well as a corresponding library to parse and generate. Two package:org.w3c.dom.* and com.android.mms.dom.* can be seen in MMS application, among which Org.w3c.dom is a standard library of smil language and com.android.mms.dom.*; is the implementation of some standard interfaces for Org.w3c.dom, or some adaptations for MMS applications. Some of the classes in com.android.mms.model.* are also written according to the SMIL standard, such as Smilhelper, which is designed to parse SMIL documents and generate SMIL documents, and of course it uses the two package that are mentioned above. Also like Imagemodel,textmodel and Regionmodel are also based on SMIL standards, such as they correspond to the tags in the SMIL document IMG, text and region.
Of course, this is the implementation of specific terminal applications, may be different applications will have different ways, but sent and received should be standard PDU, and the SMIL document is only one of the Pdupart.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.