public void sync(PduBody pb) {
   for (SlideModel slide : mSlides) {
     for (MediaModel media : slide) {
       PduPart part = pb.getPartByContentLocation(media.getSrc());
       if (part != null) {
         media.setUri(part.getDataUri());
       }
     }
   }
 }
  private PduBody makePduBody(Context context, SMILDocument document, boolean isMakingCopy) {
    PduBody pb = new PduBody();

    boolean hasForwardLock = false;
    for (SlideModel slide : mSlides) {
      for (MediaModel media : slide) {
        if (isMakingCopy) {
          if (media.isDrmProtected() && !media.isAllowedToForward()) {
            hasForwardLock = true;
            continue;
          }
        }

        PduPart part = new PduPart();

        if (media.isText()) {
          TextModel text = (TextModel) media;
          // Don't create empty text part.
          if (TextUtils.isEmpty(text.getText())) {
            continue;
          }
          // Set Charset if it's a text media.
          part.setCharset(text.getCharset());
        }

        // Set Content-Type.
        part.setContentType(media.getContentType().getBytes());

        String src = media.getSrc();
        String location;
        boolean startWithContentId = src.startsWith("cid:");
        if (startWithContentId) {
          location = src.substring("cid:".length());
        } else {
          location = src;
        }

        // Set Content-Location.
        part.setContentLocation(location.getBytes());

        // Set Content-Id.
        if (startWithContentId) {
          // Keep the original Content-Id.
          part.setContentId(location.getBytes());
        } else {
          int index = location.lastIndexOf(".");
          String contentId = (index == -1) ? location : location.substring(0, index);
          part.setContentId(contentId.getBytes());
        }

        if (media.isDrmProtected()) {
          DrmWrapper wrapper = media.getDrmObject();
          part.setDataUri(wrapper.getOriginalUri());
          part.setData(wrapper.getOriginalData());
        } else if (media.isText()) {
          part.setData(((TextModel) media).getText().getBytes());
        } else if (media.isImage() || media.isVideo() || media.isAudio()) {
          part.setDataUri(media.getUri());
        } else {
          Log.w(TAG, "Unsupport media: " + media);
        }

        pb.addPart(part);
      }
    }

    if (hasForwardLock && isMakingCopy && context != null) {
      Toast.makeText(context, context.getString(R.string.cannot_forward_drm_obj), Toast.LENGTH_LONG)
          .show();
      document = SmilHelper.getDocument(pb);
    }

    // Create and insert SMIL part(as the first part) into the PduBody.
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    SmilXmlSerializer.serialize(document, out);
    PduPart smilPart = new PduPart();
    smilPart.setContentId("smil".getBytes());
    smilPart.setContentLocation("smil.xml".getBytes());
    smilPart.setContentType(ContentType.APP_SMIL.getBytes());
    smilPart.setData(out.toByteArray());
    pb.addPart(0, smilPart);

    return pb;
  }