A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
The specific implementation form or data structure of MMS in the android MMS application is slideshowmodel, which is an arraylist with each node as slidemodel, and slidemodel is a list of models, that is, it can receive sub-classes of any model, including audio, video, image, and text, which can be placed on the slidemodel. Slidemodel is mainly used to manage the various media above it, such as their layout and Their playback control, while slideshowmodel is mainly used to manage all attachments, for example, convert all attachments to the Data Type PDU of the MMS protocol of Android, and convert from the pdu to the slideshowmodel.
PDU is the standard format of the MMS protocol. It can be directly sent to mmsc, and the data retrieved from mmsc is also in the PDU format. The Application Layer MMS does not need to care about the specific implementation method of PDU. In Android, an internal package com. Google. Android. mms. * is used to process MMS on the Android platform. It provides the ability to package data at the application layer, such as media files, into PDUS, and then decompose the PDUS into media files. The data structure of PDU includes pdubody, which is used to store multimedia files. It contains a collection of pduparts, and each pdupart represents a file. Pdupersister is used to operate on these data structures, including writing data to the database and reading data from the database.
Slideshowmodel, also known as slide, is the implementation form of MMS at the application layer, or is a data structure used by the application layer MMs to create, edit, display, and manage multimedia. When creating and sending MMS, A slideshowmodel is created, mediamodel and textmodel are constructed, and added to the slideshowmodel. When sending a message, slideshowmodel retrieves the media files and converts them to pdupart and puts them in the pdubody. After receiving the information, retrieve the pdupart from the pdubody, restore it to a media file, generate mediamodel, and add it to the slideshowmodel, that is, restore it to a slide. After the application receives the slides, it can be displayed and played.
For the attachment type, all MMS applications have a slide, which contains all the attachment files. However, MMS performs some special processing. For an MMS information, its attachment types include image, audio, video, and slideshow. These can be seen from the list in the Add attachment dialog box, the display methods are also different. But the actual implementation does not have so many types above, there is only one slideshowmodel, and all the attachments are in it. The rule is as follows. If only one media (image, audio, and video) is added, the media type is set to the corresponding media type, the attachment type is a slide only when multiple slides are explicitly selected in the attachment dialog box and added. This attachment type is only valid before adding an attachment to the MMS and before sending the mms. It is mainly used to display the media file in the message list. If it is a specific media type, it is directly displayed, otherwise, it is displayed as a slide. This attachment type is used only for displaying the media in the application and does not have any trace in the PDUS that are sent out. After receiving the MMS, the attachment type is also determined based on the content in the converted slideshowmodel, and then displayed. Therefore, for an MMS, it always has a slideshowmodel. The attachment type that the user feels is only the processing above the attachment media display.
Unlike traditional mobile phones, creating MMS does not require special methods. The difference between Mms and SMS is also very simple because the MMS application does not strictly distinguish between MMS and SMS, but is treated as a message in a unified conversation, check whether only the attachment (WorkingMessage) exists in a message. hasAttachment ()). Creating MMS is also very simple. You only need to click the Attach menu of Composer to add media. After selecting image, audio, and video in the list, there will be only one media file, and the file will be selected in other activities, and then its Uri will be returned to Composer. Composer will call WorkingMessage. setAttachment () is used for specific addition. You can use Uri to create MediaModel, add it to SlideshowModel, and set the type. In addition, if you select Attach slides, you can directly edit the slides. You can add and delete slide pages, add media files to the slides, and set the layout, after that, Composer will display the SlideshowModel, and the attachment type is also SLIDESHOW, all of which are through WorkingMessage. load.
After the workingmessage is added to the slides, an onattachmentchanged () interface is called back. composer implements this interface to notify composer that the attachment has changed, refresh the UI to correctly display attachments. Composer will create attachmenteditor to display the content of the attachment, because all the attachments are placed in slideshow. This slideshow is in workingmessage and can be obtained through workingmessage. getslideshow. Attachmenteditor creates different views based on the content in slideshow to display different attachments. If there is only one video, audio, or image in slideshow, The videoattachmentview, audioattachmentview, or imageattachmentview is directly created, slideshowattachmentview is created when the number of pages in a slide is greater than 1. You can also use the corresponding buttons to edit, replace, or delete a media set. For a single media set, you can view the source image and play the audio and video. You can re-select an attachment for replacement, deleting an attachment will remove it. If slideshow is edited or deleted, the editing will directly go to the slide editing page, where you can edit each slide in detail on one page, deleting will remove the attachment.
There are three ways to handle attachments after editing. One is to send information, the other is to save as draft, and the other is to discard information. Both sending information and saving the draft will package the slides, convert them to PDUS, and save them to the database. The subsequent slides will be loaded from the database and the PDU will be decompressed into slidehshowmodel.
Before sending information or saving the draft, you must package slideshowmodel to generate the PDU format and save it to the database. This is called packaging of MMS, which is created by slideshowmodel. the makepdubody () method is used to obtain the content in the slide one by one, convert it into a pdupart, and then put it into the pdubody to generate a pdubody. A media corresponds to a pdupart, you can also set the attributes of pdupart to describe the media file, such as contenttype, which is a string used to identify the media MIME type; the name of the filename file;
The path of the contentlocation file. This information is used to describe the metadata of the data in the pdupart, that is, what the data is, so that the data can be correctly processed during unpacking.
Then, pdupersister saves the pdubody to the database through its persist () method, and writes descriptive information in the pdupart as a database field, store the file in the telephonyprovider folder (/data/android. providers. telephony/app_parts), and write the stored path to the database as the _ data field, so that all the MMS data is written to the database. After this, the MMS data is loaded from the database, so the database in the original slideshowmodel is no longer valid, for example, the URI may point to a file or other databases in the original slideshowmodel, in pdupersister. persist () is no longer valid.
When pdupersister. after persist (), MMS attachments are loaded from the data, pdupersister. load () loads data from the database into a pdubody. The slideshowmodel method createfrompdubody () is used to convert the pdubody into a slideshowmodel, and retrieve the media information from the pdupart to obtain the correct media format, and related information. You can use URI to obtain specific files (streams ).
The received MMS process is similar. When icationicationtransaction or retrievetransaction acquires MMS data from mmsc using httputils, pduparser is used to parse the data and generate PDU, and then pdupersister is used. persist () writes it to the database and then loads it from the database.
The SMIL language is also an important piece of data for each MMs. smil is short for Synchronized Multimedia Integration Language, which is similar to HTML documents, it is a standard multimedia control language stipulated by W3C (World Wide Web Consortium. MMS also uses it to manage and play multimedia. Let's look at a specific SMIL language example:
When playing multimedia in SMIL language, a page is usually displayed, which is similar to playing in phantom, because many SMIL players make slides. Because MMS uses SMIL to transmit multimedia, the MMS terminal applications use slides to play MMs. This is why slideshowmodel is displayed in the MMS application. Slide display MMS is a common method. Even if some terminal applications do not display MMs in the form of Slide display, there is a page number for the MMS sent by the carrier or the MMS platform, in addition, some other mobile phones, such as non-smart phones, view MMS on a one-page slide.
It mainly records the layout information used for slides. This SMIL language is used for slide layout. That is to say, SMIL will describe how to layout slides like HTML document layout pages. It has these tags: Head, layout, body, par, the head is the header information. The tag layout is used to describe how this slide is laid out. Specifically, it uses sub-tags such as root-layout, region and so on. The tag body lists all the media elements and details of the slides, such as image, audio, and text. Each par is one page, its Sub-tag describes the content on this page. Of course, the SMIL language also has a lot of content to refer to the Wikipedia explanation.
When the slide is packaged and the slideshowmodel is converted to a PDU, an SMIL language is generated based on the content of the slideshowmodel. getdocument () is used to generate the SMIL document and add it to the pdubody as the first pdupart. Its contenttype (MIME) is application/SMIL, and its content is SMIL document. Note that the SMIL document will always be the first part in the pdubody, and it directly writes the document content to the pdupart, instead of the file format.
When unpacking, The SMIL document is taken out, parsed, and generated as a slide.
Because SMIL is a standard document, W3C has its own specifications and corresponding libraries for parsing and generation. In the MMS application, we can see two packages: Org. w3C. dom. * And com. android. MMS. dom. *; Org. w3C. dom is a standard library of the SMIL language, while com. android. MMS. dom. *; is for Org. w3C. the implementation of some standard DOM interfaces, or some adaptation for MMS applications. So in COM. android. MMS. model. * Some classes are also written according to the SMIL standard. For example, smilhelper is used to parse SMIL Documents and generate SMIL Documents. Of course, it will use the two packages mentioned above. For example, imagemodel, textmodel, and regionmodel are also based on the SMIL standard, such
Corresponds to labels IMG, text, and region in the SMIL document.
Of course, this is the implementation of specific terminal applications. Different applications may have different methods, but the standard PDU should be sent and received, the SMIL document is only one of the pduparts.
Start building with 50+ products and up to 12 months usage for Elastic Compute Service