1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.accessorydisplay.common;
18
19/**
20 * Defines message types.
21 */
22public class Protocol {
23    // Message header.
24    //   0: service id (16 bits)
25    //   2: what (16 bits)
26    //   4: content size (32 bits)
27    //   8: ... content follows ...
28    static final int HEADER_SIZE = 8;
29
30    // Maximum size of a message envelope including the header and contents.
31    static final int MAX_ENVELOPE_SIZE = 64 * 1024;
32
33    /**
34     * Maximum message content size.
35     */
36    public static final int MAX_CONTENT_SIZE = MAX_ENVELOPE_SIZE - HEADER_SIZE;
37
38    public static final class DisplaySinkService {
39        private DisplaySinkService() { }
40
41        public static final int ID = 1;
42
43        // Query sink capabilities.
44        // Replies with sink available or not available.
45        public static final int MSG_QUERY = 1;
46
47        // Send MPEG2-TS H.264 encoded content.
48        public static final int MSG_CONTENT = 2;
49    }
50
51    public static final class DisplaySourceService {
52        private DisplaySourceService() { }
53
54        public static final int ID = 2;
55
56        // Sink is now available for use.
57        //   0: width (32 bits)
58        //   4: height (32 bits)
59        //   8: density dpi (32 bits)
60        public static final int MSG_SINK_AVAILABLE = 1;
61
62        // Sink is no longer available for use.
63        public static final int MSG_SINK_NOT_AVAILABLE = 2;
64    }
65}
66