/*
 * SubtitleInfo
 * Connect SDK
 *
 * Copyright (c) 2015 LG Electronics.
 * Created by Oleksii Frolov on 20 Jul 2015
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.connectsdk.core;

import android.support.annotation.NonNull;

public class SubtitleInfo {
    final String url;
    final String mimeType;
    final String label;
    final String language;

    public static class Builder {
        // required fields
        String url;

        // optional fields
        String mimeType;
        String label;
        String language;

        /**
         * Constructor with required fields.
         * Different services require a specific subtitle:
         *  - DLNAService uses SRT subtitles
         *  - CastService uses VTT subtitles and it has additional requirements
         *  @see https://developers.google.com/cast/docs/android_sender#cors-requirements
         *  - FireTVService uses VTT subtitles
         *
         * @param url subtitle URL
         */
        public Builder(@NonNull String url) {
            this.url = url;
        }

        public Builder setMimeType(@NonNull String mimeType) {
            this.mimeType = mimeType;
            return this;
        }

        public Builder setLabel(@NonNull String label) {
            this.label = label;
            return this;
        }

        public Builder setLanguage(@NonNull String language) {
            this.language = language;
            return this;
        }

        public SubtitleInfo build() {
            return new SubtitleInfo(this);
        }
    }

    private SubtitleInfo(SubtitleInfo.Builder builder) {
        url = builder.url;
        mimeType = builder.mimeType;
        label = builder.label;
        language = builder.language;
    }

    public String getUrl() {
        return url;
    }

    public String getMimeType() {
        return mimeType;
    }

    public String getLabel() {
        return label;
    }

    public String getLanguage() {
        return language;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SubtitleInfo that = (SubtitleInfo) o;

        if (getUrl() != null ? !getUrl().equals(that.getUrl()) : that.getUrl() != null) {
            return false;
        }
        return !(getMimeType() != null ? !getMimeType().equals(that.getMimeType()) : that.getMimeType() != null);

    }

    @Override
    public int hashCode() {
        int result = getUrl() != null ? getUrl().hashCode() : 0;
        result = 31 * result + (getMimeType() != null ? getMimeType().hashCode() : 0);
        return result;
    }
}

@@ -1116,16 +1116,27 @@
 fields.%0A
+         *%0A
         
@@ -1216,26 +1216,257 @@
 ice 
-uses SRT subtitles
+supports only SRT subtitles. Since there is no official specification for them,%0A         *  subtitles may not work on all DLNA-compatible devices%0A         *  - NetcastTVService supports only SRT subtitles and has the same restrictions as DLNAService
 %0A   
@@ -1480,37 +1480,49 @@
   - CastService 
-uses 
+supports only Web
 VTT subtitles an
@@ -1571,16 +1571,23 @@
 *  @see 
+%7B@link 
 https://
@@ -1642,32 +1642,33 @@
 ors-requirements
+%7D
 %0A         *  - F
@@ -1684,13 +1684,25 @@
 ice 
-uses 
+supports only Web
 VTT 

Update comment with subtitle limitations in ServiceInfo class