diff options
| author | Lajos Molnar <lajos@google.com> | 2015-05-22 09:35:58 -0700 |
|---|---|---|
| committer | Lajos Molnar <lajos@google.com> | 2015-05-26 19:50:43 +0000 |
| commit | 466507eb1cba89fe137c825ed84cf4116cf32c02 (patch) | |
| tree | db6d6b6af943687d7ee0e2b3ee018d4032539f39 | |
| parent | c2ddb3e452d4d3a360ad697bf89a786f2af7a377 (diff) | |
| download | frameworks_base-466507eb1cba89fe137c825ed84cf4116cf32c02.zip frameworks_base-466507eb1cba89fe137c825ed84cf4116cf32c02.tar.gz frameworks_base-466507eb1cba89fe137c825ed84cf4116cf32c02.tar.bz2 | |
media: Update MediaCodec class description
Bug: 11990465
Bug: 11019199
Bug: 11990564
Bug: 10672559
Change-Id: I22533dec98fb878ca87876c9ebc0fe59f4bfe995
| -rw-r--r-- | docs/html/images/media/mediacodec_async_states.png | bin | 0 -> 46985 bytes | |||
| -rw-r--r-- | docs/html/images/media/mediacodec_async_states.svg | 151 | ||||
| -rw-r--r-- | docs/html/images/media/mediacodec_buffers.png | bin | 0 -> 21356 bytes | |||
| -rw-r--r-- | docs/html/images/media/mediacodec_buffers.svg | 102 | ||||
| -rw-r--r-- | docs/html/images/media/mediacodec_states.png | bin | 0 -> 45707 bytes | |||
| -rw-r--r-- | docs/html/images/media/mediacodec_states.svg | 150 | ||||
| -rw-r--r-- | media/java/android/media/MediaCodec.java | 1516 |
7 files changed, 1713 insertions, 206 deletions
diff --git a/docs/html/images/media/mediacodec_async_states.png b/docs/html/images/media/mediacodec_async_states.png Binary files differnew file mode 100644 index 0000000..c21f5c0 --- /dev/null +++ b/docs/html/images/media/mediacodec_async_states.png diff --git a/docs/html/images/media/mediacodec_async_states.svg b/docs/html/images/media/mediacodec_async_states.svg new file mode 100644 index 0000000..7349511 --- /dev/null +++ b/docs/html/images/media/mediacodec_async_states.svg @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" viewBox="649 397 519 356" width="519pt" height="356pt" xmlns:dc="http://purl.org/dc/elements/1.1/"> + <defs> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#ea8008"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker_2" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#274ecc"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker_3" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#d02e2a"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker_4" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#262626"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + <font-face font-family="Roboto" font-size="20" panose-1="2 0 0 0 0 0 0 0 0 0" units-per-em="1000" underline-position="-73.242188" underline-thickness="48.828125" slope="0" x-height="538.08594" cap-height="720.70312" ascent="927.7344" descent="-244.14062" font-weight="500"> + <font-face-src> + <font-face-name name="Roboto-Regular"/> + </font-face-src> + </font-face> + <font-face font-family="Roboto Condensed" font-size="16" panose-1="0 0 4 6 0 0 0 0 0 0" units-per-em="1000" underline-position="-73.242188" underline-thickness="48.828125" slope="0" x-height="538.08594" cap-height="720.70312" ascent="927.7344" descent="-244.14062" font-weight="300" font-stretch="condensed"> + <font-face-src> + <font-face-name name="RobotoCondensed-Light"/> + </font-face-src> + </font-face> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker_5" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#126f33"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + </defs> + <g stroke="none" stroke-opacity="1" stroke-dasharray="none" fill="none" fill-opacity="1"> + <title>MediaCodec state diagram for asynchronous operation</title> + <g> + <line x1="740" y1="508.5" x2="740" y2="471.4" marker-end="url(#FilledArrow_Marker)" stroke="#ea8008" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="740" y1="598.5" x2="740" y2="561.4" marker-end="url(#FilledArrow_Marker_2)" stroke="#274ecc" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="763.33333" y1="458.5" x2="763.33333" y2="495.6" marker-end="url(#FilledArrow_Marker_2)" stroke="#274ecc" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="920" y1="542" x2="822.9" y2="541.85288" marker-end="url(#FilledArrow_Marker_2)" stroke="#274ecc" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="920" y1="617.5" x2="822.89947" y2="618.38273" marker-end="url(#FilledArrow_Marker_3)" stroke="#d02e2a" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="919.5" y1="528.5" x2="822.9" y2="528.5" marker-end="url(#FilledArrow_Marker)" stroke="#ea8008" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="827.11573" y1="674.83365" x2="843.6129" y2="701.97642" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="922.88427" y1="674.83365" x2="904.22416" y2="702.32635" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 927.5 400 L 1092.5 400 C 1095.8137 400 1098.5 402.6863 1098.5 406 L 1098.5 671 C 1098.5 674.3137 1095.8137 677 1092.5 677 L 927.5 677 C 924.1863 677 921.5 674.3137 921.5 671 L 921.5 406 C 921.5 402.6863 924.1863 400 927.5 400 Z" fill="#178f46"/> + <path d="M 927.5 400 L 1092.5 400 C 1095.8137 400 1098.5 402.6863 1098.5 406 L 1098.5 671 C 1098.5 674.3137 1095.8137 677 1092.5 677 L 927.5 677 C 924.1863 677 921.5 674.3137 921.5 671 L 921.5 406 C 921.5 402.6863 924.1863 400 927.5 400 Z" stroke="#178f46" stroke-linecap="round" stroke-linejoin="round" stroke-width="3"/> + <text transform="translate(926.5 648.5)" fill="#aadbc2"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#aadbc2" x="40.091797" y="19" textLength="21.279297">Ex</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#aadbc2" x="61.17578" y="19" textLength="65.73242">ecuting</tspan> + </text> + <path d="M 657.5 400 L 822.5 400 C 825.8137 400 828.5 402.6863 828.5 406 L 828.5 671 C 828.5 674.3137 825.8137 677 822.5 677 L 657.5 677 C 654.1863 677 651.5 674.3137 651.5 671 L 651.5 406 C 651.5 402.6863 654.1863 400 657.5 400 Z" stroke="#d02e2a" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(656.5 648.5)" fill="#d02e2a"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#d02e2a" x="46.53711" y="19" textLength="18.398438">St</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#d02e2a" x="64.740234" y="19" textLength="55.722656">opped</tspan> + </text> + <text transform="translate(1130.1743 479.5)" fill="#262626"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x=".64453125" y="15" textLength="30.710938">flush</tspan> + </text> + <text transform="translate(968 467)" fill="#262626"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x="4.4101562" y="15" textLength="24.148438">star</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x="28.949219" y="15" textLength="4.640625">t</tspan> + </text> + <text transform="translate(844.054 419.2185)" fill="#136f34"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#136f34" x="14.255245" y="15" textLength="24.148438">star</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#136f34" x="38.794307" y="15" textLength="4.640625">t</tspan> + </text> + <text transform="translate(848.3963 505)" fill="#ea8008"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#ea8008" x="11.621094" y="15" textLength="11.78125">st</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#ea8008" x="23.246094" y="15" textLength="15.6328125">op</tspan> + </text> + <text transform="translate(858.68587 621.3852)" fill="#b6251f"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#b6251f" x=".21875" y="15" textLength="16.992188">err</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#b6251f" x="17.054688" y="15" textLength="12.6875">or</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#b6251f" x="28.78125" y="15" textLength="9">…</tspan> + </text> + <text transform="translate(857.8257 546.43005)" fill="#274ecc"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecc" x=".4453125" y="15" textLength="4.8359375">r</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecc" x="5.1328125" y="15" textLength="26.421875">eset</tspan> + </text> + <text transform="translate(768.33333 466.62302)" fill="#274ecc"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecc" x=".4453125" y="15" textLength="4.8359375">r</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecc" x="5.1328125" y="15" textLength="26.421875">eset</tspan> + </text> + <text transform="translate(744 571.12)" fill="#274ecc"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecc" x=".4453125" y="15" textLength="4.8359375">r</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecc" x="5.1328125" y="15" textLength="26.421875">eset</tspan> + </text> + <text transform="translate(675 479.5)" fill="#ea8008"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#ea8008" x="2.8125" y="15" textLength="30.382812">confi</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#ea8008" x="33.195312" y="15" textLength="20.320312">gur</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#ea8008" x="53.367187" y="15" textLength="7.3203125">e</tspan> + </text> + <path d="M 676 418.5 L 804 418.5 C 807.3137 418.5 810 421.1863 810 424.5 L 810 452.5 C 810 455.8137 807.3137 458.5 804 458.5 L 676 458.5 C 672.6863 458.5 670 455.8137 670 452.5 L 670 424.5 C 670 421.1863 672.6863 418.5 676 418.5 Z" fill="#f0a608"/> + <text transform="translate(675 426.5)" fill="#fbe4a3"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#fbe4a3" x="16.381836" y="19" textLength="46.533203">Confi</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#fbe4a3" x="62.91504" y="19" textLength="29.013672">gur</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#fbe4a3" x="91.743164" y="19" textLength="21.875">ed</tspan> + </text> + <path d="M 946 508.5 L 1074 508.5 C 1077.3137 508.5 1080 511.1863 1080 514.5 L 1080 542.5 C 1080 545.8137 1077.3137 548.5 1074 548.5 L 946 548.5 C 942.6863 548.5 940 545.8137 940 542.5 L 940 514.5 C 940 511.1863 942.6863 508.5 946 508.5 Z" fill="#f8f8f8"/> + <path d="M 946 508.5 L 1074 508.5 C 1077.3137 508.5 1080 511.1863 1080 514.5 L 1080 542.5 C 1080 545.8137 1077.3137 548.5 1074 548.5 L 946 548.5 C 942.6863 548.5 940 545.8137 940 542.5 L 940 514.5 C 940 511.1863 942.6863 508.5 946 508.5 Z" stroke="#49b077" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(945 516.5)" fill="#178f46"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#178f46" x="28.740234" y="19" textLength="72.51953">Running</tspan> + </text> + <path d="M 676 508.5 L 804 508.5 C 807.3137 508.5 810 511.1863 810 514.5 L 810 542.5 C 810 545.8137 807.3137 548.5 804 548.5 L 676 548.5 C 672.6863 548.5 670 545.8137 670 542.5 L 670 514.5 C 670 511.1863 672.6863 508.5 676 508.5 Z" fill="#346df1"/> + <text transform="translate(675 516.5)" fill="#bad0fb"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#bad0fb" x="10.825195" y="19" textLength="86.63086">Uninitializ</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#bad0fb" x="97.299805" y="19" textLength="21.875">ed</tspan> + </text> + <path d="M 676 598.5 L 804 598.5 C 807.3137 598.5 810 601.1863 810 604.5 L 810 632.5 C 810 635.8137 807.3137 638.5 804 638.5 L 676 638.5 C 672.6863 638.5 670 635.8137 670 632.5 L 670 604.5 C 670 601.1863 672.6863 598.5 676 598.5 Z" fill="#d02e2a"/> + <text transform="translate(675 606.5)" fill="white"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="white" x="43.55957" y="19" textLength="24.902344">Err</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="white" x="68.2666" y="19" textLength="18.173828">or</tspan> + </text> + <path d="M 946 418.5 L 1074 418.5 C 1077.3137 418.5 1080 421.1863 1080 424.5 L 1080 452.5 C 1080 455.8137 1077.3137 458.5 1074 458.5 L 946 458.5 C 942.6863 458.5 940 455.8137 940 452.5 L 940 424.5 C 940 421.1863 942.6863 418.5 946 418.5 Z" fill="#f8f8f8"/> + <path d="M 946 418.5 L 1074 418.5 C 1077.3137 418.5 1080 421.1863 1080 424.5 L 1080 452.5 C 1080 455.8137 1077.3137 458.5 1074 458.5 L 946 458.5 C 942.6863 458.5 940 455.8137 940 452.5 L 940 424.5 C 940 421.1863 942.6863 418.5 946 418.5 Z" stroke="#de6560" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(945 426.5)" fill="#178f46"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#178f46" x="29.93164" y="19" textLength="70.13672">Flushed</tspan> + </text> + <path d="M 946 598.5 L 1074 598.5 C 1077.3137 598.5 1080 601.1863 1080 604.5 L 1080 632.5 C 1080 635.8137 1077.3137 638.5 1074 638.5 L 946 638.5 C 942.6863 638.5 940 635.8137 940 632.5 L 940 604.5 C 940 601.1863 942.6863 598.5 946 598.5 Z" fill="#f8f8f8"/> + <path d="M 946 598.5 L 1074 598.5 C 1077.3137 598.5 1080 601.1863 1080 604.5 L 1080 632.5 C 1080 635.8137 1077.3137 638.5 1074 638.5 L 946 638.5 C 942.6863 638.5 940 635.8137 940 632.5 L 940 604.5 C 940 601.1863 942.6863 598.5 946 598.5 Z" stroke="#f4c23d" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(945 606.5)" fill="#178f46"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#178f46" x="2.0410156" y="19" textLength="87.09961">End of Str</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#178f46" x="88.95508" y="19" textLength="39.003906">eam</tspan> + </text> + <path d="M 810 438.5 C 810 438.5 878.0599 435.16865 921.5 455 C 947.861 467.03438 957.6335 484.16434 961.2431 495.77385" marker-end="url(#FilledArrow_Marker_5)" stroke="#126f33" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="963.33333" y1="458.5" x2="963.33333" y2="495.6" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="963.33333" y1="548.5" x2="963.33333" y2="585.6" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 1080 521.83333 C 1080 521.83333 1106 504.33135 1106 484.5 C 1106 473.46106 1097.9439 464.58984 1090.80046 458.89346" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 1056.66667 598.5 C 1056.66667 598.5 1110.38955 548.8288 1117 503.5 C 1121.4143 473.23063 1103.434 454.40253 1090.9997 445.23311" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(968.25 550.5)" fill="#262626"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x="2.171875" y="15" textLength="111.25">queueInputBuffer</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x="38.46875" y="34" textLength="35.0625">(EOS)</tspan> + </text> + <path d="M 809.6463 713 L 937.6463 713 C 940.96 713 943.6463 715.6863 943.6463 719 L 943.6463 747 C 943.6463 750.3137 940.96 753 937.6463 753 L 809.6463 753 C 806.3326 753 803.6463 750.3137 803.6463 747 L 803.6463 719 C 803.6463 715.6863 806.3326 713 809.6463 713 Z" fill="#535353"/> + <text transform="translate(808.6463 721)" fill="#d5d5d5"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#d5d5d5" x="24.28711" y="19" textLength="81.42578">Released</tspan> + </text> + <text transform="translate(852.18587 683)" fill="#262626"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x=".15625" y="15" textLength="4.8359375">r</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x="4.84375" y="15" textLength="40">elease</tspan> + </text> + </g> + </g> +</svg> diff --git a/docs/html/images/media/mediacodec_buffers.png b/docs/html/images/media/mediacodec_buffers.png Binary files differnew file mode 100644 index 0000000..f17f4ac --- /dev/null +++ b/docs/html/images/media/mediacodec_buffers.png diff --git a/docs/html/images/media/mediacodec_buffers.svg b/docs/html/images/media/mediacodec_buffers.svg new file mode 100644 index 0000000..fa121ee --- /dev/null +++ b/docs/html/images/media/mediacodec_buffers.svg @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" viewBox="20 17 540 208" width="45pc" height="208pt" xmlns:dc="http://purl.org/dc/elements/1.1/"> + <defs> + <font-face font-family="Roboto" font-size="20" panose-1="2 0 0 0 0 0 0 0 0 0" units-per-em="1000" underline-position="-73.242188" underline-thickness="48.828125" slope="0" x-height="538.08594" cap-height="720.70312" ascent="927.7344" descent="-244.14062" font-weight="500"> + <font-face-src> + <font-face-name name="Roboto-Regular"/> + </font-face-src> + </font-face> + <font-face font-family="Roboto" font-size="12" panose-1="2 0 0 0 0 0 0 0 0 0" units-per-em="1000" underline-position="-73.242188" underline-thickness="48.828125" slope="0" x-height="538.08594" cap-height="720.70312" ascent="927.7344" descent="-244.14062" font-weight="300"> + <font-face-src> + <font-face-name name="Roboto-Light"/> + </font-face-src> + </font-face> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" viewBox="-4 -2 5 4" markerWidth="5" markerHeight="4" color="#262626"> + <g> + <path d="M -2.16 0 L 0 .81 L 0 -.81 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + </defs> + <g stroke="none" stroke-opacity="1" stroke-dasharray="none" fill="none" fill-opacity="1"> + <title>MediaCodec buffer flow diagram</title> + <g> + <line x1="291" y1="20" x2="290" y2="220" stroke="#535353" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke-dasharray="4,4"/> + <path d="M 560 71 L 560 179 L 560 185 L 554 185 L 510 185 L 466 185 C 462.6863 185 460 182.31371 460 179 L 460 71 C 460 67.68629 462.6863 65 466 65 L 510 65 L 554 65 L 560 65 Z M 554 65 C 554 65 554 65 554 65 Z" fill="#178f46"/> + <text transform="translate(465 113)" fill="#aadcc2"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#aadcc2" x="19.555664" y="19" textLength="50.888672">Client</tspan> + </text> + <path d="M 246 75 L 334 75 C 337.3137 75 340 77.68629 340 81 L 340 169 C 340 172.31371 337.3137 175 334 175 L 246 175 C 242.68629 175 240 172.31371 240 169 L 240 81 C 240 77.68629 242.68629 75 246 75 Z" fill="#346df1"/> + <text transform="translate(245 113)" fill="#bad0fb"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#bad0fb" x="16.616211" y="19" textLength="56.767578">Codec</tspan> + </text> + <path d="M 132 140 L 148 140 C 149.10457 140 150 140.89543 150 142 L 150 158 C 150 159.10457 149.10457 160 148 160 L 132 160 C 130.89543 160 130 159.10457 130 158 L 130 142 C 130 140.89543 130.89543 140 132 140 Z" fill="#de6560"/> + <path d="M 132 140 L 148 140 C 149.10457 140 150 140.89543 150 142 L 150 158 C 150 159.10457 149.10457 160 148 160 L 132 160 C 130.89543 160 130 159.10457 130 158 L 130 142 C 130 140.89543 130.89543 140 132 140 Z" stroke="#b6251f" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 172 140 L 188 140 C 189.10457 140 190 140.89543 190 142 L 190 158 C 190 159.10457 189.10457 160 188 160 L 172 160 C 170.89543 160 170 159.10457 170 158 L 170 142 C 170 140.89543 170.89543 140 172 140 Z" fill="#de6560"/> + <path d="M 172 140 L 188 140 C 189.10457 140 190 140.89543 190 142 L 190 158 C 190 159.10457 189.10457 160 188 160 L 172 160 C 170.89543 160 170 159.10457 170 158 L 170 142 C 170 140.89543 170.89543 140 172 140 Z" stroke="#b6251f" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 212 140 L 228 140 C 229.10457 140 230 140.89543 230 142 L 230 158 C 230 159.10457 229.10457 160 228 160 L 212 160 C 210.89543 160 210 159.10457 210 158 L 210 142 C 210 140.89543 210.89543 140 212 140 Z" fill="#de6560"/> + <path d="M 212 140 L 228 140 C 229.10457 140 230 140.89543 230 142 L 230 158 C 230 159.10457 229.10457 160 228 160 L 212 160 C 210.89543 160 210 159.10457 210 158 L 210 142 C 210 140.89543 210.89543 140 212 140 Z" stroke="#b6251f" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 212 90 L 228 90 C 229.10457 90 230 90.89543 230 92 L 230 108 C 230 109.10457 229.10457 110 228 110 L 212 110 C 210.89543 110 210 109.10457 210 108 L 210 92 C 210 90.89543 210.89543 90 212 90 Z" stroke="#b6251f" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 172 90 L 188 90 C 189.10457 90 190 90.89543 190 92 L 190 108 C 190 109.10457 189.10457 110 188 110 L 172 110 C 170.89543 110 170 109.10457 170 108 L 170 92 C 170 90.89543 170.89543 90 172 90 Z" stroke="#b6251f" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 132 90 L 148 90 C 149.10457 90 150 90.89543 150 92 L 150 108 C 150 109.10457 149.10457 110 148 110 L 132 110 C 130.89543 110 130 109.10457 130 108 L 130 92 C 130 90.89543 130.89543 90 132 90 Z" stroke="#b6251f" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(128.5 70.5)" fill="#262626"> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x=".19238281" y="11" textLength="86.44336">empty input buff</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="86.495117" y="11" textLength="16.3125">ers</tspan> + </text> + <path d="M 20 71 L 20 179 L 20 185 L 26 185 L 70 185 L 114 185 C 117.31371 185 120 182.31371 120 179 L 120 71 C 120 67.68629 117.31371 65 114 65 L 70 65 L 26 65 L 20 65 Z M 26 65 C 26 65 26 65 26 65 Z" fill="#178f46"/> + <text transform="translate(25 113)" fill="#aadcc2"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#aadcc2" x="19.555664" y="19" textLength="50.888672">Client</tspan> + </text> + <path d="M 352 110 L 368 110 C 369.10457 110 370 109.10457 370 108 L 370 92 C 370 90.89543 369.10457 90 368 90 L 352 90 C 350.89543 90 350 90.89543 350 92 L 350 108 C 350 109.10457 350.89543 110 352 110 Z" fill="#f4c23d"/> + <path d="M 352 110 L 368 110 C 369.10457 110 370 109.10457 370 108 L 370 92 C 370 90.89543 369.10457 90 368 90 L 352 90 C 350.89543 90 350 90.89543 350 92 L 350 108 C 350 109.10457 350.89543 110 352 110 Z" stroke="#eb8007" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 392 110 L 408 110 C 409.10457 110 410 109.10457 410 108 L 410 92 C 410 90.89543 409.10457 90 408 90 L 392 90 C 390.89543 90 390 90.89543 390 92 L 390 108 C 390 109.10457 390.89543 110 392 110 Z" fill="#f4c23d"/> + <path d="M 392 110 L 408 110 C 409.10457 110 410 109.10457 410 108 L 410 92 C 410 90.89543 409.10457 90 408 90 L 392 90 C 390.89543 90 390 90.89543 390 92 L 390 108 C 390 109.10457 390.89543 110 392 110 Z" stroke="#eb8007" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 432 110 L 448 110 C 449.10457 110 450 109.10457 450 108 L 450 92 C 450 90.89543 449.10457 90 448 90 L 432 90 C 430.89543 90 430 90.89543 430 92 L 430 108 C 430 109.10457 430.89543 110 432 110 Z" fill="#f4c23d"/> + <path d="M 432 110 L 448 110 C 449.10457 110 450 109.10457 450 108 L 450 92 C 450 90.89543 449.10457 90 448 90 L 432 90 C 430.89543 90 430 90.89543 430 92 L 430 108 C 430 109.10457 430.89543 110 432 110 Z" stroke="#eb8007" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 432 160 L 448 160 C 449.10457 160 450 159.10457 450 158 L 450 142 C 450 140.89543 449.10457 140 448 140 L 432 140 C 430.89543 140 430 140.89543 430 142 L 430 158 C 430 159.10457 430.89543 160 432 160 Z" fill="#f4c23d"/> + <path d="M 432 160 L 448 160 C 449.10457 160 450 159.10457 450 158 L 450 142 C 450 140.89543 449.10457 140 448 140 L 432 140 C 430.89543 140 430 140.89543 430 142 L 430 158 C 430 159.10457 430.89543 160 432 160 Z" stroke="#eb8007" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 392 160 L 408 160 C 409.10457 160 410 159.10457 410 158 L 410 142 C 410 140.89543 409.10457 140 408 140 L 392 140 C 390.89543 140 390 140.89543 390 142 L 390 158 C 390 159.10457 390.89543 160 392 160 Z" fill="#f4c23d"/> + <path d="M 392 160 L 408 160 C 409.10457 160 410 159.10457 410 158 L 410 142 C 410 140.89543 409.10457 140 408 140 L 392 140 C 390.89543 140 390 140.89543 390 142 L 390 158 C 390 159.10457 390.89543 160 392 160 Z" stroke="#eb8007" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 352 160 L 368 160 C 369.10457 160 370 159.10457 370 158 L 370 142 C 370 140.89543 369.10457 140 368 140 L 352 140 C 350.89543 140 350 140.89543 350 142 L 350 158 C 350 159.10457 350.89543 160 352 160 Z" fill="#f4c23d"/> + <path d="M 352 160 L 368 160 C 369.10457 160 370 159.10457 370 158 L 370 142 C 370 140.89543 369.10457 140 368 140 L 352 140 C 350.89543 140 350 140.89543 350 142 L 350 158 C 350 159.10457 350.89543 160 352 160 Z" stroke="#eb8007" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="230" y1="120.03223" x2="110" y2="120" stroke="#262626" stroke-linecap="square" stroke-linejoin="round" stroke-width="2" stroke-dasharray="8,5"/> + <line x1="232.38" y1="130.03034" x2="110" y2="130" marker-start="url(#FilledArrow_Marker)" stroke="#262626" stroke-linecap="square" stroke-linejoin="round" stroke-width="2" stroke-dasharray="8,5"/> + <path d="M 110 130 C 107.238576 130 105 127.76142 105 125 C 105 122.238576 107.238576 120 110 120" stroke="#262626" stroke-linecap="square" stroke-linejoin="round" stroke-width="2" stroke-dasharray="8,5"/> + <line x1="350" y1="120.53223" x2="470" y2="120.5" stroke="#262626" stroke-linecap="square" stroke-linejoin="round" stroke-width="2" stroke-dasharray="8,5"/> + <line x1="347.62" y1="130.53034" x2="470" y2="130.5" marker-start="url(#FilledArrow_Marker)" stroke="#262626" stroke-linecap="square" stroke-linejoin="round" stroke-width="2" stroke-dasharray="8,5"/> + <path d="M 470 130.5 C 472.76142 130.5 475 128.26142 475 125.5 C 475 122.738576 472.76142 120.5 470 120.5" stroke="#262626" stroke-linecap="square" stroke-linejoin="round" stroke-width="2" stroke-dasharray="8,5"/> + <text transform="translate(132.5 166.5)" fill="#262626"> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x=".3671875" y="11" textLength="6.4453125">fi</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="6.8125" y="11" textLength="71.648438">lled input buff</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="78.320312" y="11" textLength="16.3125">ers</tspan> + </text> + <text transform="translate(348.5 70.5)" fill="#262626"> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x=".42382812" y="11" textLength="6.4453125">fi</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="6.8691406" y="11" textLength="79.535156">lled output buff</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="86.26367" y="11" textLength="16.3125">ers</tspan> + </text> + <text transform="translate(366.5 165)" fill="#262626"> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="11.748047" y="11" textLength="32.080078">discar</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="43.716797" y="11" textLength="19.535156">ded</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x=".22851562" y="25" textLength="58.371094">output buff</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="58.458984" y="25" textLength="16.3125">ers</tspan> + </text> + <text transform="translate(35.5 192)" fill="#262626"> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x=".13378906" y="11" textLength="41.8125">client pr</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="41.829102" y="11" textLength="6.720703">o</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="48.461914" y="11" textLength="27.404297">vides</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="11.6621094" y="25" textLength="52.67578">input data</tspan> + </text> + <text transform="translate(466.5 192)" fill="#262626"> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x=".40136719" y="11" textLength="86.197266">client consumes</tspan> + <tspan font-family="Roboto" font-size="12" font-weight="300" fill="#262626" x="13.21875" y="25" textLength="60.5625">output data</tspan> + </text> + <text transform="translate(157.5 30)" fill="#d02d2a"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#d02d2a" x=".166015625" y="19" textLength="44.66797">input</tspan> + </text> + <text transform="translate(371 30)" fill="#f0a608"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#f0a608" x=".12792969" y="19" textLength="57.74414">output</tspan> + </text> + </g> + </g> +</svg> diff --git a/docs/html/images/media/mediacodec_states.png b/docs/html/images/media/mediacodec_states.png Binary files differnew file mode 100644 index 0000000..a34b613 --- /dev/null +++ b/docs/html/images/media/mediacodec_states.png diff --git a/docs/html/images/media/mediacodec_states.svg b/docs/html/images/media/mediacodec_states.svg new file mode 100644 index 0000000..81646fd --- /dev/null +++ b/docs/html/images/media/mediacodec_states.svg @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" viewBox="649 8 519 357" width="519pt" height="357pt" xmlns:dc="http://purl.org/dc/elements/1.1/"> + <defs> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#ea8008"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker_2" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#274ecc"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker_3" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#d02e2a"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker_4" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#262626"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + <font-face font-family="Roboto" font-size="20" panose-1="2 0 0 0 0 0 0 0 0 0" units-per-em="1000" underline-position="-73.242188" underline-thickness="48.828125" slope="0" x-height="538.08594" cap-height="720.70312" ascent="927.7344" descent="-244.14062" font-weight="500"> + <font-face-src> + <font-face-name name="Roboto-Regular"/> + </font-face-src> + </font-face> + <font-face font-family="Roboto Condensed" font-size="16" panose-1="0 0 4 6 0 0 0 0 0 0" units-per-em="1000" underline-position="-73.242188" underline-thickness="48.828125" slope="0" x-height="538.08594" cap-height="720.70312" ascent="927.7344" descent="-244.14062" font-weight="300" font-stretch="condensed"> + <font-face-src> + <font-face-name name="RobotoCondensed-Light"/> + </font-face-src> + </font-face> + <marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker_5" viewBox="-1 -3 7 6" markerWidth="7" markerHeight="6" color="#126f33"> + <g> + <path d="M 4.8 0 L 0 -1.8 L 0 1.8 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/> + </g> + </marker> + </defs> + <g stroke="none" stroke-opacity="1" stroke-dasharray="none" fill="none" fill-opacity="1"> + <title>MediaCodec state diagram</title> + <g> + <line x1="740" y1="120" x2="740" y2="82.9" marker-end="url(#FilledArrow_Marker)" stroke="#ea8008" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="740" y1="210" x2="740" y2="172.9" marker-end="url(#FilledArrow_Marker_2)" stroke="#274ecc" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="763.33333" y1="70" x2="763.33333" y2="107.1" marker-end="url(#FilledArrow_Marker_2)" stroke="#274ecc" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="920" y1="153.5" x2="822.9" y2="153.35288" marker-end="url(#FilledArrow_Marker_2)" stroke="#274ecc" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="920" y1="229" x2="822.89947" y2="229.88273" marker-end="url(#FilledArrow_Marker_3)" stroke="#d02e2a" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="919.5" y1="140" x2="822.9" y2="140" marker-end="url(#FilledArrow_Marker)" stroke="#ea8008" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="827.11573" y1="286.33365" x2="843.6129" y2="313.47642" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="922.88427" y1="286.33365" x2="904.22416" y2="313.82635" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 927.5 11.5 L 1092.5 11.5 C 1095.8137 11.5 1098.5 14.1862915 1098.5 17.5 L 1098.5 282.5 C 1098.5 285.8137 1095.8137 288.5 1092.5 288.5 L 927.5 288.5 C 924.1863 288.5 921.5 285.8137 921.5 282.5 L 921.5 17.5 C 921.5 14.1862915 924.1863 11.5 927.5 11.5 Z" fill="#178f46"/> + <path d="M 927.5 11.5 L 1092.5 11.5 C 1095.8137 11.5 1098.5 14.1862915 1098.5 17.5 L 1098.5 282.5 C 1098.5 285.8137 1095.8137 288.5 1092.5 288.5 L 927.5 288.5 C 924.1863 288.5 921.5 285.8137 921.5 282.5 L 921.5 17.5 C 921.5 14.1862915 924.1863 11.5 927.5 11.5 Z" stroke="#178f46" stroke-linecap="round" stroke-linejoin="round" stroke-width="3"/> + <text transform="translate(926.5 260)" fill="#aadbc2"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#aadbc2" x="40.091797" y="19" textLength="21.279297">Ex</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#aadbc2" x="61.17578" y="19" textLength="65.73242">ecuting</tspan> + </text> + <path d="M 657.5 11.5 L 822.5 11.5 C 825.8137 11.5 828.5 14.1862915 828.5 17.5 L 828.5 282.5 C 828.5 285.8137 825.8137 288.5 822.5 288.5 L 657.5 288.5 C 654.1863 288.5 651.5 285.8137 651.5 282.5 L 651.5 17.5 C 651.5 14.1862915 654.1863 11.5 657.5 11.5 Z" stroke="#d02e2a" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(656.5 260)" fill="#d02e2a"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#d02e2a" x="46.53711" y="19" textLength="18.398438">St</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#d02e2a" x="64.740234" y="19" textLength="55.722656">opped</tspan> + </text> + <text transform="translate(1130.1743 91)" fill="#262626"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x=".64453125" y="15" textLength="30.710938">flush</tspan> + </text> + <text transform="translate(968 78.5)" fill="#262626"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x=".859375" y="15" textLength="122.78125">dequeueInputBuffer</tspan> + </text> + <text transform="translate(846.272 20.5)" fill="#126f33"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#126f33" x="14.255245" y="15" textLength="24.148438">star</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#126f33" x="38.794307" y="15" textLength="4.640625">t</tspan> + </text> + <text transform="translate(848.3963 116.5)" fill="#eb8007"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#eb8007" x="11.621094" y="15" textLength="11.78125">st</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#eb8007" x="23.246094" y="15" textLength="15.6328125">op</tspan> + </text> + <text transform="translate(858.68587 232.88521)" fill="#b6251f"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#b6251f" x=".21875" y="15" textLength="16.992188">err</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#b6251f" x="17.054688" y="15" textLength="12.6875">or</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#b6251f" x="28.78125" y="15" textLength="9">…</tspan> + </text> + <text transform="translate(857.8257 157.930055)" fill="#274ecd"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecd" x=".4453125" y="15" textLength="4.8359375">r</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecd" x="5.1328125" y="15" textLength="26.421875">eset</tspan> + </text> + <text transform="translate(768.33333 78.12302)" fill="#274ecd"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecd" x=".4453125" y="15" textLength="4.8359375">r</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecd" x="5.1328125" y="15" textLength="26.421875">eset</tspan> + </text> + <text transform="translate(744 182.62)" fill="#274ecd"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecd" x=".4453125" y="15" textLength="4.8359375">r</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#274ecd" x="5.1328125" y="15" textLength="26.421875">eset</tspan> + </text> + <text transform="translate(675 91)" fill="#eb8007"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#eb8007" x="2.8125" y="15" textLength="30.382812">confi</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#eb8007" x="33.195312" y="15" textLength="20.320312">gur</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#eb8007" x="53.367187" y="15" textLength="7.3203125">e</tspan> + </text> + <path d="M 676 30 L 804 30 C 807.3137 30 810 32.686292 810 36 L 810 64 C 810 67.31371 807.3137 70 804 70 L 676 70 C 672.6863 70 670 67.31371 670 64 L 670 36 C 670 32.686292 672.6863 30 676 30 Z" fill="#f0a608"/> + <text transform="translate(675 38)" fill="#fbe4a3"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#fbe4a3" x="16.381836" y="19" textLength="46.533203">Confi</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#fbe4a3" x="62.91504" y="19" textLength="29.013672">gur</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#fbe4a3" x="91.743164" y="19" textLength="21.875">ed</tspan> + </text> + <path d="M 946 120 L 1074 120 C 1077.3137 120 1080 122.68629 1080 126 L 1080 154 C 1080 157.31371 1077.3137 160 1074 160 L 946 160 C 942.6863 160 940 157.31371 940 154 L 940 126 C 940 122.68629 942.6863 120 946 120 Z" fill="#f8f8f8"/> + <path d="M 946 120 L 1074 120 C 1077.3137 120 1080 122.68629 1080 126 L 1080 154 C 1080 157.31371 1077.3137 160 1074 160 L 946 160 C 942.6863 160 940 157.31371 940 154 L 940 126 C 940 122.68629 942.6863 120 946 120 Z" stroke="#49b077" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(945 128)" fill="#178f46"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#178f46" x="28.740234" y="19" textLength="72.51953">Running</tspan> + </text> + <path d="M 676 120 L 804 120 C 807.3137 120 810 122.68629 810 126 L 810 154 C 810 157.31371 807.3137 160 804 160 L 676 160 C 672.6863 160 670 157.31371 670 154 L 670 126 C 670 122.68629 672.6863 120 676 120 Z" fill="#346df1"/> + <text transform="translate(675 128)" fill="#bad0fb"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#bad0fb" x="10.825195" y="19" textLength="86.63086">Uninitializ</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#bad0fb" x="97.299805" y="19" textLength="21.875">ed</tspan> + </text> + <path d="M 676 210 L 804 210 C 807.3137 210 810 212.68629 810 216 L 810 244 C 810 247.31371 807.3137 250 804 250 L 676 250 C 672.6863 250 670 247.31371 670 244 L 670 216 C 670 212.68629 672.6863 210 676 210 Z" fill="#d02e2a"/> + <text transform="translate(675 218)" fill="white"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="white" x="43.55957" y="19" textLength="24.902344">Err</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="white" x="68.2666" y="19" textLength="18.173828">or</tspan> + </text> + <path d="M 946 30 L 1074 30 C 1077.3137 30 1080 32.686292 1080 36 L 1080 64 C 1080 67.31371 1077.3137 70 1074 70 L 946 70 C 942.6863 70 940 67.31371 940 64 L 940 36 C 940 32.686292 942.6863 30 946 30 Z" fill="#f8f8f8"/> + <path d="M 946 30 L 1074 30 C 1077.3137 30 1080 32.686292 1080 36 L 1080 64 C 1080 67.31371 1077.3137 70 1074 70 L 946 70 C 942.6863 70 940 67.31371 940 64 L 940 36 C 940 32.686292 942.6863 30 946 30 Z" stroke="#de6560" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(945 38)" fill="#178f46"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#178f46" x="29.93164" y="19" textLength="70.13672">Flushed</tspan> + </text> + <path d="M 946 210 L 1074 210 C 1077.3137 210 1080 212.68629 1080 216 L 1080 244 C 1080 247.31371 1077.3137 250 1074 250 L 946 250 C 942.6863 250 940 247.31371 940 244 L 940 216 C 940 212.68629 942.6863 210 946 210 Z" fill="#f8f8f8"/> + <path d="M 946 210 L 1074 210 C 1077.3137 210 1080 212.68629 1080 216 L 1080 244 C 1080 247.31371 1077.3137 250 1074 250 L 946 250 C 942.6863 250 940 247.31371 940 244 L 940 216 C 940 212.68629 942.6863 210 946 210 Z" stroke="#f4c23d" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(945 218)" fill="#178f46"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#178f46" x="2.0410156" y="19" textLength="87.09961">End of Str</tspan> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#178f46" x="88.95508" y="19" textLength="39.003906">eam</tspan> + </text> + <line x1="810" y1="50" x2="927.1" y2="50" marker-end="url(#FilledArrow_Marker_5)" stroke="#126f33" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="963.33333" y1="70" x2="963.33333" y2="107.1" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <line x1="963.33333" y1="160" x2="963.33333" y2="197.1" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 1080 133.33333 C 1080 133.33333 1106 115.83135 1106 96 C 1106 84.961065 1097.9439 76.089842 1090.80046 70.39346" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <path d="M 1056.66667 210 C 1056.66667 210 1110.38955 160.3288 1117 115 C 1121.4143 84.73063 1103.434 65.902535 1090.9997 56.733113" marker-end="url(#FilledArrow_Marker_4)" stroke="#262626" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> + <text transform="translate(968.25 162)" fill="#262626"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x="2.171875" y="15" textLength="111.25">queueInputBuffer</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x="38.46875" y="34" textLength="35.0625">(EOS)</tspan> + </text> + <path d="M 809.6463 324.5 L 937.6463 324.5 C 940.96 324.5 943.6463 327.1863 943.6463 330.5 L 943.6463 358.5 C 943.6463 361.8137 940.96 364.5 937.6463 364.5 L 809.6463 364.5 C 806.3326 364.5 803.6463 361.8137 803.6463 358.5 L 803.6463 330.5 C 803.6463 327.1863 806.3326 324.5 809.6463 324.5 Z" fill="#535353"/> + <text transform="translate(808.6463 332.5)" fill="#d5d5d5"> + <tspan font-family="Roboto" font-size="20" font-weight="500" fill="#d5d5d5" x="24.28711" y="19" textLength="81.42578">Released</tspan> + </text> + <text transform="translate(852.18587 294.5)" fill="#262626"> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x=".15625" y="15" textLength="4.8359375">r</tspan> + <tspan font-family="Roboto Condensed" font-size="16" font-weight="300" font-stretch="condensed" fill="#262626" x="4.84375" y="15" textLength="40">elease</tspan> + </text> + </g> + </g> +</svg> diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 6f28bf6..eec4960 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -23,6 +23,7 @@ import android.graphics.ImageFormat; import android.graphics.Rect; import android.media.Image; import android.media.MediaCodecInfo; +import android.media.MediaCodecInfo.CodecCapabilities; import android.media.MediaCodecList; import android.media.MediaCrypto; import android.media.MediaFormat; @@ -42,204 +43,1307 @@ import java.util.HashMap; import java.util.Map; /** - * MediaCodec class can be used to access low-level media codec, i.e. - * encoder/decoder components. - * - * <p>MediaCodec is generally used like this: - * <pre> - * MediaCodec codec = MediaCodec.createDecoderByType(type); - * codec.configure(format, ...); - * codec.start(); - * - * // if API level <= 20, get input and output buffer arrays here - * ByteBuffer[] inputBuffers = codec.getInputBuffers(); - * ByteBuffer[] outputBuffers = codec.getOutputBuffers(); - * for (;;) { - * int inputBufferIndex = codec.dequeueInputBuffer(timeoutUs); - * if (inputBufferIndex >= 0) { - * // if API level >= 21, get input buffer here - * ByteBuffer inputBuffer = codec.getInputBuffer(inputBufferIndex); - * // fill inputBuffers[inputBufferIndex] with valid data - * ... - * codec.queueInputBuffer(inputBufferIndex, ...); - * } - * - * int outputBufferIndex = codec.dequeueOutputBuffer(timeoutUs); - * if (outputBufferIndex >= 0) { - * // if API level >= 21, get output buffer here - * ByteBuffer outputBuffer = codec.getOutputBuffer(outputBufferIndex); - * // outputBuffer is ready to be processed or rendered. - * ... - * codec.releaseOutputBuffer(outputBufferIndex, ...); - * } else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) { - * // no needed to handle if API level >= 21 and using getOutputBuffer(int) - * outputBuffers = codec.getOutputBuffers(); - * } else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) { - * // Subsequent data will conform to new format. - * // can ignore if API level >= 21 and using getOutputFormat(outputBufferIndex) - * MediaFormat format = codec.getOutputFormat(); - * ... - * } - * } - * codec.stop(); - * codec.release(); - * codec = null; - * </pre> - * - * Each codec maintains a number of input and output buffers that are - * referred to by index in API calls. - * <p> - * For API levels 20 and below: - * The contents of these buffers are represented by the ByteBuffer[] arrays - * accessible through {@link #getInputBuffers} and {@link #getOutputBuffers}. - * <p> - * After a successful call to {@link #start} the client "owns" neither - * input nor output buffers, subsequent calls to {@link #dequeueInputBuffer} - * and {@link #dequeueOutputBuffer} then transfer ownership from the codec - * to the client.<p> - * The client is not required to resubmit/release buffers immediately - * to the codec, the sample code above simply does this for simplicity's sake. - * Nonetheless, it is possible that a codec may hold off on generating - * output buffers until all outstanding buffers have been - * released/resubmitted. - * <p> - * Once the client has an input buffer available it can fill it with data - * and submit it it to the codec via a call to {@link #queueInputBuffer}. - * Do not submit multiple input buffers with the same timestamp (unless - * it is codec-specific data marked as such using the flag - * {@link #BUFFER_FLAG_CODEC_CONFIG}). - * <p> - * The codec in turn will return an output buffer to the client in response - * to {@link #dequeueOutputBuffer}. After the output buffer has been processed - * a call to {@link #releaseOutputBuffer} will return it to the codec. - * If a video surface has been provided in the call to {@link #configure}, - * {@link #releaseOutputBuffer} optionally allows rendering of the buffer - * to the surface.<p> - * - * Input buffers (for decoders) and Output buffers (for encoders) contain - * encoded data according to the format's type. For video types this data - * is all the encoded data representing a single moment in time, for audio - * data this is slightly relaxed in that a buffer may contain multiple - * encoded frames of audio. In either case, buffers do not start and end on - * arbitrary byte boundaries, this is not a stream of bytes, it's a stream - * of access units.<p> - * - * Most formats also require the actual data to be prefixed by a number - * of buffers containing setup data, or codec specific data, i.e. the - * first few buffers submitted to the codec object after starting it must - * be codec specific data marked as such using the flag {@link #BUFFER_FLAG_CODEC_CONFIG} - * in a call to {@link #queueInputBuffer}. - * <p> - * Codec specific data included in the format passed to {@link #configure} - * (in ByteBuffer entries with keys "csd-0", "csd-1", ...) is automatically - * submitted to the codec, this data MUST NOT be submitted explicitly by the - * client. - * <p> - * Once the client reaches the end of the input data it signals the end of - * the input stream by specifying a flag of {@link #BUFFER_FLAG_END_OF_STREAM} in the call to - * {@link #queueInputBuffer}. The codec will continue to return output buffers - * until it eventually signals the end of the output stream by specifying - * the same flag ({@link #BUFFER_FLAG_END_OF_STREAM}) on the BufferInfo returned in - * {@link #dequeueOutputBuffer}. Do not submit additional input buffers after - * signaling the end of the input stream, unless the codec has been flushed, - * or stopped and restarted. - * <p> - * <h3>Seeking & Adaptive Playback Support</h3> - * - * You can check if a decoder supports adaptive playback via {@link - * MediaCodecInfo.CodecCapabilities#isFeatureSupported}. Adaptive playback - * is only supported if you configure the codec to decode onto a {@link - * android.view.Surface}. - * - * <h4>For decoders that do not support adaptive playback (including - * when not decoding onto a Surface)</h4> - * - * In order to start decoding data that's not adjacent to previously submitted - * data (i.e. after a seek) <em>one must</em> {@link #flush} the decoder. - * Any input or output buffers the client may own at the point of the flush are - * immediately revoked, i.e. after a call to {@link #flush} the client does not - * own any buffers anymore. - * <p> - * It is important that the input data after a flush starts at a suitable - * stream boundary. The first frame must be able to be decoded completely on - * its own (for most codecs this means an I-frame), and that no frames should - * refer to frames before that first new frame. - * Note that the format of the data submitted after a flush must not change, - * flush does not support format discontinuities, - * for this a full {@link #stop}, {@link #configure configure()}, {@link #start} - * cycle is necessary. - * - * <h4>For decoders that support adaptive playback</h4> - * - * In order to start decoding data that's not adjacent to previously submitted - * data (i.e. after a seek) it is <em>not necessary</em> to {@link #flush} the - * decoder. - * <p> - * It is still important that the input data after the discontinuity starts - * at a suitable stream boundary (e.g. I-frame), and that no new frames refer - * to frames before the first frame of the new input data segment. - * <p> - * For some video formats it is also possible to change the picture size - * mid-stream. To do this for H.264, the new Sequence Parameter Set (SPS) and - * Picture Parameter Set (PPS) values must be packaged together with an - * Instantaneous Decoder Refresh (IDR) frame in a single buffer, which then - * can be enqueued as a regular input buffer. - * The client will receive an {@link #INFO_OUTPUT_FORMAT_CHANGED} return - * value from {@link #dequeueOutputBuffer dequeueOutputBuffer()} or - * {@link Callback#onOutputBufferAvailable onOutputBufferAvailable()} - * just after the picture-size change takes place and before any - * frames with the new size have been returned. - * <p> - * Be careful when calling {@link #flush} shortly after you have changed - * the picture size. If you have not received confirmation of the picture - * size change, you will need to repeat the request for the new picture size. - * E.g. for H.264 you will need to prepend the PPS/SPS to the new IDR - * frame to ensure that the codec receives the picture size change request. - * - * <h3>States and error handling</h3> - * - * <p> During its life, a codec conceptually exists in one of the following states: - * Initialized, Configured, Executing, Error, Uninitialized, (omitting transitory states - * between them). When created by one of the factory methods, - * the codec is in the Initialized state; {@link #configure} brings it to the - * Configured state; {@link #start} brings it to the Executing state. - * In the Executing state, decoding or encoding occurs through the buffer queue - * manipulation described above. The method {@link #stop} - * returns the codec to the Initialized state, whereupon it may be configured again, - * and {@link #release} brings the codec to the terminal Uninitialized state. When - * a codec error occurs, the codec moves to the Error state. Use {@link #reset} to - * bring the codec back to the Initialized state, or {@link #release} to move it - * to the Uninitialized state. - * - * <p> The factory methods - * {@link #createByCodecName}, - * {@link #createDecoderByType}, - * and {@link #createEncoderByType} - * throw {@link java.io.IOException} on failure which - * the caller must catch or declare to pass up. - * MediaCodec methods throw {@link java.lang.IllegalStateException} - * when the method is called from a codec state that does not allow it; - * this is typically due to incorrect application API usage. - * Methods involving secure buffers may throw - * {@link MediaCodec.CryptoException#MediaCodec.CryptoException}, which - * has further error information obtainable from {@link MediaCodec.CryptoException#getErrorCode}. - * - * <p> Internal codec errors result in a {@link MediaCodec.CodecException}, - * which may be due to media content corruption, hardware failure, resource exhaustion, - * and so forth, even when the application is correctly using the API. - * The recommended action when receiving a {@link MediaCodec.CodecException} can be determined by - * calling {@link MediaCodec.CodecException#isRecoverable} and - * {@link MediaCodec.CodecException#isTransient}. - * If {@link MediaCodec.CodecException#isRecoverable} returns true, - * then a {@link #stop}, {@link #configure}, and {@link #start} can be performed to recover. - * If {@link MediaCodec.CodecException#isTransient} returns true, - * then resources are temporarily unavailable and the method may be retried at a later time. - * If both {@link MediaCodec.CodecException#isRecoverable} - * and {@link MediaCodec.CodecException#isTransient} return false, - * then the {@link MediaCodec.CodecException} is fatal and the codec must be - * {@link #reset reset} or {@link #release released}. - * Both {@link MediaCodec.CodecException#isRecoverable} and - * {@link MediaCodec.CodecException#isTransient} do not return true at the same time. + MediaCodec class can be used to access low-level media codecs, i.e. encoder/decoder components. + It is part of the Android low-level multimedia support infrastructure (normally used together + with {@link MediaExtractor}, {@link MediaSync}, {@link MediaMuxer}, {@link MediaCrypto}, + {@link MediaDrm}, {@link Image}, {@link Surface}, and {@link AudioTrack}.) + <p> + <center><object style="width: 540px; height: 205px;" type="image/svg+xml" + data="../../../images/media/mediacodec_buffers.svg"><img + src="../../../images/media/mediacodec_buffers.png" style="width: 540px; height: 205px" + alt="MediaCodec buffer flow diagram"></object></center> + <p> + In broad terms, a codec processes input data to generate output data. It processes data + asynchronously and uses a set of input and output buffers. At a simplistic level, you request + (or receive) an empty input buffer, fill it up with data and send it to the codec for + processing. The codec uses up the data and transforms it into one of its empty output buffers. + Finally, you request (or receive) a filled output buffer, consume its contents and release it + back to the codec. + + <h3>Data Types</h3> + <p> + Codecs operate on three kinds of data: compressed data, raw audio data and raw video data. + All three kinds of data can be processed using {@link ByteBuffer ByteBuffers}, but you should use + a {@link Surface} for raw video data to improve codec performance. Surface uses native video + buffers without mapping or copying them to ByteBuffers; thus, it is much more efficient. + You normally cannot access the raw video data when using a Surface, but you can use the + {@link ImageReader} class to access unsecured decoded (raw) video frames. This may still be more + efficient than using ByteBuffers, as some native buffers may be mapped into {@linkplain + ByteBuffer#isDirect direct} ByteBuffers. When using ByteBuffer mode, you can access raw video + frames using the {@link Image} class and {@link #getInputImage getInput}/{@link #getOutputImage + OutputImage(int)}. + + <h4>Compressed Buffers</h4> + <p> + Input buffers (for decoders) and output buffers (for encoders) contain compressed data according + to the {@linkplain MediaFormat#KEY_MIME format's type}. For video types this is a single + compressed video frame. For audio data this is normally a single access unit (an encoded audio + segment typically containing a few milliseconds of audio as dictated by the format type), but + this requirement is slightly relaxed in that a buffer may contain multiple encoded access units + of audio. In either case, buffers do not start or end on arbitrary byte boundaries, but rather on + frame/access unit boundaries. + + <h4>Raw Audio Buffers</h4> + <p> + Raw audio buffers contain entire frames of PCM audio data, which is one sample for each channel + in channel order. Each sample is a {@linkplain AudioFormat#ENCODING_PCM_16BIT 16-bit signed + integer in native byte order}. + + <pre class=prettyprint> + short[] getSamplesForChannel(MediaCodec codec, int bufferId, int channelIx) { + ByteBuffer outputBuffer = codec.getOutputBuffer(bufferId); + MediaFormat format = codec.getOutputFormat(bufferId); + ShortBuffer samples = outputBuffer.order(ByteOrder.nativeOrder()).asShortBuffer(); + int numChannels = formet.getInteger(MediaFormat.KEY_CHANNEL_COUNT); + if (channelIx < 0 || channelIx >= numChannels) { + return null; + } + short[] res = new short[samples.remaining() / numChannels]; + for (int i = 0; i < res.length; ++i) { + res[i] = samples.get(i * numChannels + channelIx); + } + return res; + }</pre> + + <h4>Raw Video Buffers</h4> + <p> + In ByteBuffer mode video buffers are laid out according to their {@linkplain + MediaFormat#KEY_COLOR_FORMAT color format}. You can get the supported color formats as an array + from {@link #getCodecInfo}{@code .}{@link MediaCodecInfo#getCapabilitiesForType + getCapabilitiesForType(…)}{@code .}{@link CodecCapabilities#colorFormats colorFormats}. + Video codecs may support three kinds of color formats: + <ul> + <li><strong>native raw video format:</strong> This is marked by {@link + CodecCapabilities#COLOR_FormatSurface} and it can be used with an input or output Surface.</li> + <li><strong>flexible YUV buffers</strong> (such as {@link + CodecCapabilities#COLOR_FormatYUV420Flexible}): These can be used with an input/output Surface, + as well as in ByteBuffer mode, by using {@link #getInputImage getInput}/{@link #getOutputImage + OutputImage(int)}.</li> + <li><strong>other, specific formats:</strong> These are normally only supported in ByteBuffer + mode. Some color formats are vendor specific. Others are defined in {@link CodecCapabilities}. + For color formats that are equivalent to a flexible format, you can still use {@link + #getInputImage getInput}/{@link #getOutputImage OutputImage(int)}.</li> + </ul> + <p> + All video codecs support flexible YUV 4:2:0 buffers since {@link + android.os.Build.VERSION_CODES#LOLLIPOP_MR1}. + + <h3>States</h3> + <p> + During its life a codec conceptually exists in one of three states: Stopped, Executing or + Released. The Stopped collective state is actually the conglomeration of three states: + Uninitialized, Configured and Error, whereas the Executing state conceptually progresses through + three sub-states: Flushed, Running and End-of-Stream. + <p> + <center><object style="width: 516px; height: 353px;" type="image/svg+xml" + data="../../../images/media/mediacodec_states.svg"><img + src="../../../images/media/mediacodec_states.png" style="width: 519px; height: 356px" + alt="MediaCodec state diagram"></object></center> + <p> + When you create a codec using one of the factory methods, the codec is in the Uninitialized + state. First, you need to configure it via {@link #configure configure(…)}, which brings + it to the Configured state, then call {@link #start} to move it to the Executing state. In this + state you can process data through the buffer queue manipulation described above. + <p> + The Executing state has three sub-states: Flushed, Running and End-of-Stream. Immediately after + {@link #start} the codec is in the Flushed sub-state, where it holds all the buffers. As soon + as the first input buffer is dequeued, the codec moves to the Running sub-state, where it spends + most of its life. When you queue an input buffer with the {@linkplain #BUFFER_FLAG_END_OF_STREAM + end-of-stream marker}, the codec transitions to the End-of-Stream sub-state. In this state the + codec no longer accepts further input buffers, but still generates output buffers until the + end-of-stream is reached on the output. You can move back to the Flushed sub-state at any time + while in the Executing state using {@link #flush}. + <p> + Call {@link #stop} to return the codec to the Uninitialized state, whereupon it may be configured + again. When you are done using a codec, you must release it by calling {@link #release}. + <p> + On rare occasions the codec may encounter an error and move to the Error state. This is + communicated using an invalid return value from a queuing operation, or sometimes via an + exception. Call {@link #reset} to make the codec usable again. You can call it from any state to + move the codec back to the Uninitialized state. Otherwise, call {@link #release} to move to the + terminal Released state. + + <h3>Creation</h3> + <p> + Use {@link MediaCodecList} to create a MediaCodec for a specific {@link MediaFormat}. When + decoding a file or a stream, you can get the desired format from {@link + MediaExtractor#getTrackFormat MediaExtractor.getTrackFormat}. Inject any specific features that + you want to add using {@link MediaFormat#setFeatureEnabled MediaFormat.setFeatureEnabled}, then + call {@link MediaCodecList#findDecoderForFormat MediaCodecList.findDecoderForFormat} to get the + name of a codec that can handle that specific media format. Finally, create the codec using + {@link #createByCodecName}. + <p class=note> + <strong>Note:</strong> On {@link android.os.Build.VERSION_CODES#LOLLIPOP}, the format to + {@code MediaCodecList.findDecoder}/{@code EncoderForFormat} must not contain a {@linkplain + MediaFormat#KEY_FRAME_RATE frame rate}. Use + <code class=prettyprint>format.setString(MediaFormat.KEY_FRAME_RATE, null)</code> + to clear any existing frame rate setting in the format. + <p> + You can also create the preferred codec for a specific MIME type using {@link + #createDecoderByType createDecoder}/{@link #createEncoderByType EncoderByType(String)}. + This, however, cannot be used to inject features, and may create a codec that cannot handle the + specific desired media format. + + <h4>Creating secure decoders</h4> + <p> + On versions {@link android.os.Build.VERSION_CODES#KITKAT_WATCH} and earlier, secure codecs might + not be listed in {@link MediaCodecList}, but may still be available on the system. Secure codecs + that exist can be instantiated by name only, by appending {@code ".secure"} to the name of a + regular codec (the name of all secure codecs must end in {@code ".secure"}.) {@link + #createByCodecName} will throw an {@code IOException} if the codec is not present on the system. + <p> + From {@link android.os.Build.VERSION_CODES#LOLLIPOP} onwards, you should use the {@link + CodecCapabilities#FEATURE_SecurePlayback} feature in the media format to create a secure decoder. + + <h3>Initialization</h3> + <p> + After creating the codec, you can set a callback using {@link #setCallback setCallback} if you + want to process data asynchronously. Then, {@linkplain #configure configure} the codec using the + specific media format. This is when you can specify the output {@link Surface} for video + producers – codecs that generate raw video data (e.g. video decoders). This is also when + you can set the decryption parameters for secure codecs (see {@link MediaCrypto}). Finally, since + some codecs can operate in multiple modes, you must specify whether you want it to work as a + decoder or an encoder. + <p> + Since {@link android.os.Build.VERSION_CODES#LOLLIPOP}, you can query the resulting input and + output format in the Configured state. You can use this to verify the resulting configuration, + e.g. color formats, before starting the codec. + <p> + If you want to process raw input video buffers natively with a video consumer – a codec + that processes raw video input, such as a video encoder – create a destination Surface for + your input data using {@link #createInputSurface} after configuration. Alternately, set up the + codec to use a previously created {@linkplain #createPersistentInputSurface persistent input + surface} by calling {@link #setInputSurface}. + + <h4 id=CSD><a name="CSD"></a>Codec-specific Data</h4> + <p> + Some formats, notably AAC audio and MPEG4, H.264 and H.265 video formats require the actual data + to be prefixed by a number of buffers containing setup data, or codec specific data. When + processing such compressed formats, this data must be submitted to the codec after {@link + #start} and before any frame data. Such data must be marked using the flag {@link + #BUFFER_FLAG_CODEC_CONFIG} in a call to {@link #queueInputBuffer queueInputBuffer}. + <p> + Codec-specific data can also be included in the format passed to {@link #configure configure} in + ByteBuffer entries with keys "csd-0", "csd-1", etc. These keys are always included in the track + {@link MediaFormat} obtained from the {@link MediaExtractor#getTrackFormat MediaExtractor}. + Codec-specific data in the format is automatically submitted to the codec upon {@link #start}; + you <strong>MUST NOT</strong> submit this data explicitly. If the format did not contain codec + specific data, you can choose to submit it using the specified number of buffers in the correct + order, according to the format requirements. Alternately, you can concatenate all codec-specific + data and submit it as a single codec-config buffer. + <p> + Android uses the following codec-specific data buffers. These are also required to be set in + the track format for proper {@link MediaMuxer} track configuration. Each parameter set and + codec-specific-data must start with a start code of {@code "\x00\x00\x00\x01"}. + <p> + <style>td.NA { background: #ccc; } .mid > tr > td { vertical-align: middle; }</style> + <table> + <thead> + <th>Format</th> + <th>CSD buffer #0</th> + <th>CSD buffer #1</th> + </thead> + <tbody class=mid> + <tr> + <td>AAC</td> + <td>Decoder-specific information from ESDS</td> + <td class=NA>Not Used</td> + </tr> + <tr> + <td>MPEG-4</td> + <td>Decoder-specific information from ESDS</td> + <td class=NA>Not Used</td> + </tr> + <tr> + <td>H.264 AVC</td> + <td>SPS (Sequence Parameter Sets)</td> + <td>PPS (Picture Parameter Sets)</td> + </tr> + <tr> + <td>H.265 HEVC</td> + <td>VPS (Video Parameter Sets) +<br> + SPS (Sequence Parameter Sets) +<br> + PPS (Picture Parameter Sets)</td> + <td class=NA>Not Used</td> + </tr> + </tbody> + </table> + + <p class=note> + <strong>Note:</strong> care must be taken if the codec is flushed immediately or shortly + after start, before any output buffer or output format change has been returned, as the codec + specific data may be lost during the flush. You must resubmit the data using buffers marked with + {@link #BUFFER_FLAG_CODEC_CONFIG} after such flush to ensure proper codec operation. + <p> + Encoders (or codecs that generate compressed data) will create and return the codec specific data + before any valid output buffer in output buffers marked with the {@linkplain + #BUFFER_FLAG_CODEC_CONFIG codec-config flag}. Buffers containing codec-specific-data have no + meaningful timestamps. + + <h3>Data Processing</h3> + <p> + Each codec maintains a set of input and output buffers that are referred to by a buffer-ID in + API calls. After a successful call to {@link #start} the client "owns" neither input nor output + buffers. In synchronous mode, call {@link #dequeueInputBuffer dequeueInput}/{@link + #dequeueOutputBuffer OutputBuffer(…)} to obtain (get ownership of) an input or output + buffer from the codec. In asynchronous mode, you will automatically receive available buffers via + the {@link Callback#onInputBufferAvailable MediaCodec.Callback.onInput}/{@link + Callback#onOutputBufferAvailable OutputBufferAvailable(…)} callbacks. + <p> + Upon obtaining an input buffer, fill it with data and submit it to the codec using {@link + #queueInputBuffer queueInputBuffer} – or {@link #queueSecureInputBuffer + queueSecureInputBuffer} if using decryption. Do not submit multiple input buffers with the same + timestamp (unless it is <a href="#CSD">codec-specific data</a> marked as such). + <p> + The codec in turn will return a read-only output buffer via the {@link + Callback#onOutputBufferAvailable onOutputBufferAvailable} callback in asynchronous mode, or in + response to a {@link #dequeueOutputBuffer dequeuOutputBuffer} call in synchronous mode. After the + output buffer has been processed, call one of the {@link #releaseOutputBuffer + releaseOutputBuffer} methods to return the buffer to the codec. + <p> + While you are not required to resubmit/release buffers immediately to the codec, holding onto + input and/or output buffers may stall the codec, and this behavior is device dependent. E.g. it + is possible that a codec may hold off on generating output buffers until all outstanding buffers + have been released/resubmitted. Therefore, try to hold onto to available buffers as little as + possible. + <p> + Depending on the API version, you can process data in three ways: + <table> + <thead> + <tr> + <th>Processing Mode</th> + <th>API version <= 20<br>Jelly Bean/KitKat</th> + <th>API version >= 21<br>Lollipop and later</th> + </tr> + </thead> + <tbody> + <tr> + <td>Synchronous API using buffer arrays</td> + <td>Supported</td> + <td>Deprecated</td> + </tr> + <tr> + <td>Synchronous API using buffers</td> + <td class=NA>Not Available</td> + <td>Supported</td> + </tr> + <tr> + <td>Asynchronous API using buffers</td> + <td class=NA>Not Available</td> + <td>Supported</td> + </tr> + </tbody> + </table> + + <h4>Asynchronous Processing using Buffers</h4> + <p> + Since {@link android.os.Build.VERSION_CODES#LOLLIPOP}, the preferred method is to process data + asynchronously by setting a callback before calling {@link #configure configure}. Asynchronous + mode changes the state transitions slightly, because you must call {@link #start} after {@link + #flush} to transition the codec to the Running sub-state and start receiving input buffers. + Similarly, upon an initial call to {@code start} the codec will move directly to the Running + sub-state and start passing available input buffers via the callback. + <p> + <center><object style="width: 516px; height: 353px;" type="image/svg+xml" + data="../../../images/media/mediacodec_async_states.svg"><img + src="../../../images/media/mediacodec_async_states.png" style="width: 516px; height: 353px" + alt="MediaCodec state diagram for asynchronous operation"></object></center> + <p> + MediaCodec is typically used like this in asynchronous mode: + <pre class=prettyprint> + MediaCodec codec = MediaCodec.createCodecByName(name); + MediaFormat mOutputFormat; // member variable + codec.setCallback(new MediaCodec.Callback() { + {@literal @Override} + void onInputBufferAvailable(MediaCodec mc, int inputBufferId) { + ByteBuffer inputBuffer = codec.getInputBuffer(inputBufferId); + // fill inputBuffer with valid data + … + codec.queueInputBuffer(inputBufferId, …); + } + + {@literal @Override} + void onOutputBufferAvailable(MediaCodec mc, int outputBufferId, …) { + ByteBuffer outputBuffer = codec.getOutputBuffer(outputBufferId); + MediaFormat bufferFormat = codec.getOutputFormat(outputBufferId); // option A + // bufferFormat is equivalent to mOutputFormat + // outputBuffer is ready to be processed or rendered. + … + codec.releaseOutputBuffer(outputBufferId, …); + } + + {@literal @Override} + void onOutputFormatChanged(MediaCodec mc, MediaFormat format) { + // Subsequent data will conform to new format. + // Can ignore if using getOutputFormat(outputBufferId) + mOutputFormat = format; // option B + } + + {@literal @Override} + void onError(…) { + … + } + }); + codec.configure(format, …); + mOutputFormat = codec.getOutputFormat(); // option B + codec.start(); + // wait for processing to complete + codec.stop(); + codec.release();</pre> + + <h4>Synchronous Processing using Buffers</h4> + <p> + Since {@link android.os.Build.VERSION_CODES#LOLLIPOP}, you should retrieve input and output + buffers using {@link #getInputBuffer getInput}/{@link #getOutputBuffer OutputBuffer(int)} and/or + {@link #getInputImage getInput}/{@link #getOutputImage OutputImage(int)} even when using the + codec in synchronous mode. This allows certain optimizations by the framework, e.g. when + processing dynamic content. This optimization is disabled if you call {@link #getInputBuffers + getInput}/{@link #getOutputBuffers OutputBuffers()}. + + <p class=note> + <strong>Note:</strong> do not mix the methods of using buffers and buffer arrays at the same + time. Specifically, only call {@code getInput}/{@code OutputBuffers} directly after {@link + #start} or after having dequeued an output buffer ID with the value of {@link + #INFO_OUTPUT_FORMAT_CHANGED}. + <p> + MediaCodec is typically used like this in synchronous mode: + <pre> + MediaCodec codec = MediaCodec.createCodecByName(name); + codec.configure(format, …); + MediaFormat outputFormat = codec.getOutputFormat(); // option B + codec.start(); + for (;;) { + int inputBufferId = codec.dequeueInputBuffer(timeoutUs); + if (inputBufferId >= 0) { + ByteBuffer inputBuffer = codec.getInputBuffer(…); + // fill inputBuffer with valid data + … + codec.queueInputBuffer(inputBufferId, …); + } + int outputBufferId = codec.dequeueOutputBuffer(…); + if (outputBufferId >= 0) { + ByteBuffer outputBuffer = codec.getOutputBuffer(outputBufferId); + MediaFormat bufferFormat = codec.getOutputFormat(outputBufferId); // option A + // bufferFormat is identical to outputFormat + // outputBuffer is ready to be processed or rendered. + … + codec.releaseOutputBuffer(outputBufferId, …); + } else if (outputBufferId == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) { + // Subsequent data will conform to new format. + // Can ignore if using getOutputFormat(outputBufferId) + outputFormat = codec.getOutputFormat(); // option B + } + } + codec.stop(); + codec.release();</pre> + + <h4>Synchronous Processing using Buffer Arrays (deprecated)</h4> + <p> + In versions {@link android.os.Build.VERSION_CODES#KITKAT_WATCH} and before, the set of input and + output buffers are represented by the {@code ByteBuffer[]} arrays. After a successful call to + {@link #start}, retrieve the buffer arrays using {@link #getInputBuffers getInput}/{@link + #getOutputBuffers OutputBuffers()}. Use the buffer ID-s as indices into these arrays (when + non-negative), as demonstrated in the sample below. Note that there is no inherent correlation + between the size of the arrays and the number of input and output buffers used by the system, + although the array size provides an upper bound. + <pre> + MediaCodec codec = MediaCodec.createCodecByName(name); + codec.configure(format, …); + codec.start(); + ByteBuffer[] inputBuffers = codec.getInputBuffers(); + ByteBuffer[] outputBuffers = codec.getOutputBuffers(); + for (;;) { + int inputBufferId = codec.dequeueInputBuffer(…); + if (inputBufferId >= 0) { + // fill inputBuffers[inputBufferId] with valid data + … + codec.queueInputBuffer(inputBufferId, …); + } + int outputBufferId = codec.dequeueOutputBuffer(…); + if (outputBufferId >= 0) { + // outputBuffers[outputBufferId] is ready to be processed or rendered. + … + codec.releaseOutputBuffer(outputBufferId, …); + } else if (outputBufferId == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) { + outputBuffers = codec.getOutputBuffers(); + } else if (outputBufferId == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) { + // Subsequent data will conform to new format. + MediaFormat format = codec.getOutputFormat(); + } + } + codec.stop(); + codec.release();</pre> + + <h4>End-of-stream Handling</h4> + <p> + When you reach the end of the input data, you must signal it to the codec by specifying the + {@link #BUFFER_FLAG_END_OF_STREAM} flag in the call to {@link #queueInputBuffer + queueInputBuffer}. You can do this on the last valid input buffer, or by submitting an additional + empty input buffer with the end-of-stream flag set. If using an empty buffer, the timestamp will + be ignored. + <p> + The codec will continue to return output buffers until it eventually signals the end of the + output stream by specifying the same end-of-stream flag in the {@link BufferInfo} set in {@link + #dequeueOutputBuffer dequeueOutputBuffer} or returned via {@link Callback#onOutputBufferAvailable + onOutputBufferAvailable}. This can be set on the last valid output buffer, or on an empty buffer + after the last valid output buffer. The timestamp of such empty buffer should be ignored. + <p> + Do not submit additional input buffers after signaling the end of the input stream, unless the + codec has been flushed, or stopped and restarted. + + <h4>Using an Output Surface</h4> + <p> + The data processing is nearly identical to the ByteBuffer mode when using an output {@link + Surface}; however, the output buffers will not be accessible, and are represented as {@code null} + values. E.g. {@link #getOutputBuffer getOutputBuffer}/{@link #getOutputImage Image(int)} will + return {@code null} and {@link #getOutputBuffers} will return an array containing only {@code + null}-s. + <p> + When using an output Surface, you can select whether or not to render each output buffer on the + surface. You have three choices: + <ul> + <li><strong>Do not render the buffer:</strong> Call {@link #releaseOutputBuffer(int, boolean) + releaseOutputBuffer(bufferId, false)}.</li> + <li><strong>Render the buffer with the default timestamp:</strong> Call {@link + #releaseOutputBuffer(int, boolean) releaseOutputBuffer(bufferId, true)}.</li> + <li><strong>Render the buffer with a specific timestamp:</strong> Call {@link + #releaseOutputBuffer(int, long) releaseOutputBuffer(bufferId, timestamp)}.</li> + </ul> + <p> + Since {@link android.os.Build.VERSION_CODES#MNC}, the default timestamp is the {@linkplain + BufferInfo#presentationTimeUs presentation timestamp} of the buffer (converted to nanoseconds). + It was not defined prior to that. + <p> + Also since {@link android.os.Build.VERSION_CODES#MNC}, you can change the output Surface + dynamically using {@link #setOutputSurface setOutputSurface}. + + <h4>Using an Input Surface</h4> + <p> + When using an input Surface, there are no accessible input buffers, as buffers are automatically + passed from the input surface to the codec. Calling {@link #dequeueInputBuffer + dequeueInputBuffer} will throw an {@code IllegalStateException}, and {@link #getInputBuffers} + returns a bogus {@code ByteBuffer[]} array that <strong>MUST NOT</strong> be written into. + <p> + Call {@link #signalEndOfInputStream} to signal end-of-stream. The input surface will stop + submitting data to the codec immediately after this call. + <p> + + <h3>Seeking & Adaptive Playback Support</h3> + <p> + Video decoders (and in general codecs that consume compressed video data) behave differently + regarding seek and format change whether or not they support and are configured for adaptive + playback. You can check if a decoder supports {@linkplain + CodecCapabilities#FEATURE_AdaptivePlayback adaptive playback} via {@link + CodecCapabilities#isFeatureSupported CodecCapabilities.isFeatureSupported(String)}. Adaptive + playback support for video decoders is only activated if you configure the codec to decode onto a + {@link Surface}. + + <h4 id=KeyFrames><a name="KeyFrames"></a>Stream Boundary and Key Frames</h4> + <p> + It is important that the input data after {@link #start} or {@link #flush} starts at a suitable + stream boundary: the first frame must a key frame. A <em>key frame</em> can be decoded + completely on its own (for most codecs this means an I-frame), and no frames that are to be + displayed after a key frame refer to frames before the key frame. + <p> + The following table summarizes suitable key frames for various video formats. + <table> + <thead> + <tr> + <th>Format</th> + <th>Suitable key frame</th> + </tr> + </thead> + <tbody class=mid> + <tr> + <td>VP9/VP8</td> + <td>a suitable intraframe where no subsequent frames refer to frames prior to this frame.<br> + <i>(There is no specific name for such key frame.)</i></td> + </tr> + <tr> + <td>H.265 HEVC</td> + <td>IDR or CRA</td> + </tr> + <tr> + <td>H.264 AVC</td> + <td>IDR</td> + </tr> + <tr> + <td>MPEG-4<br>H.263<br>MPEG-2</td> + <td>a suitable I-frame where no subsequent frames refer to frames prior to this frame.<br> + <i>(There is no specific name for such key frame.)</td> + </tr> + </tbody> + </table> + + <h4>For decoders that do not support adaptive playback (including when not decoding onto a + Surface)</h4> + <p> + In order to start decoding data that is not adjacent to previously submitted data (i.e. after a + seek) you <strong>MUST</strong> flush the decoder. Since all output buffers are immediately + revoked at the point of the flush, you may want to first signal then wait for the end-of-stream + before you call {@code flush}. It is important that the input data after a flush starts at a + suitable stream boundary/key frame. + <p class=note> + <strong>Note:</strong> the format of the data submitted after a flush must not change; {@link + #flush} does not support format discontinuities; for that, a full {@link #stop} - {@link + #configure configure(…)} - {@link #start} cycle is necessary. + + <p class=note> + <strong>Also note:</strong> if you flush the codec too soon after {@link #start} – + generally, before the first output buffer or output format change is received – you + will need to resubmit the codec-specific-data to the codec. See the <a + href="#CSD">codec-specific-data section</a> for more info. + + <h4>For decoders that support and are configured for adaptive playback</h4> + <p> + In order to start decoding data that is not adjacent to previously submitted data (i.e. after a + seek) it is <em>not necessary</em> to flush the decoder; however, input data after the + discontinuity must start at a suitable stream boundary/key frame. + <p> + For some video formats - namely H.264, H.265, VP8 and VP9 - it is also possible to change the + picture size or configuration mid-stream. To do this you must package the entire new + codec-specific configuration data together with the key frame into a single buffer (including + any start codes), and submit it as a <strong>regular</strong> input buffer. + <p> + You will receive an {@link #INFO_OUTPUT_FORMAT_CHANGED} return value from {@link + #dequeueOutputBuffer dequeueOutputBuffer} or a {@link Callback#onOutputBufferAvailable + onOutputFormatChanged} callback just after the picture-size change takes place and before any + frames with the new size have been returned. + <p class=note> + <strong>Note:</strong> just as the case for codec-specific data, be careful when calling + {@link #flush} shortly after you have changed the picture size. If you have not received + confirmation of the picture size change, you will need to repeat the request for the new picture + size. + + <h3>Error handling</h3> + <p> + The factory methods {@link #createByCodecName createByCodecName} and {@link #createDecoderByType + createDecoder}/{@link #createEncoderByType EncoderByType} throw {@code IOException} on failure + which you must catch or declare to pass up. MediaCodec methods throw {@code + IllegalStateException} when the method is called from a codec state that does not allow it; this + is typically due to incorrect application API usage. Methods involving secure buffers may throw + {@link CryptoException}, which has further error information obtainable from {@link + CryptoException#getErrorCode}. + <p> + Internal codec errors result in a {@link CodecException}, which may be due to media content + corruption, hardware failure, resource exhaustion, and so forth, even when the application is + correctly using the API. The recommended action when receiving a {@code CodecException} + can be determined by calling {@link CodecException#isRecoverable} and {@link + CodecException#isTransient}: + <ul> + <li><strong>recoverable errors:</strong> If {@code isRecoverable()} returns true, then call + {@link #stop}, {@link #configure configure(…)}, and {@link #start} to recover.</li> + <li><strong>transient errors:</strong> If {@code isTransient()} returns true, then resources are + temporarily unavailable and the method may be retried at a later time.</li> + <li><strong>fatal errors:</strong> If both {@code isRecoverable()} and {@code isTransient()} + return false, then the {@code CodecException} is fatal and the codec must be {@linkplain #reset + reset} or {@linkplain #release released}.</li> + </ul> + <p> + Both {@code isRecoverable()} and {@code isTransient()} do not return true at the same time. + + <h2 id=History><a name="History"></a>Valid API Calls and API History</h2> + <p> + This sections summarizes the valid API calls in each state and the API history of the MediaCodec + class. For API version numbers, see {@link android.os.Build.VERSION_CODES}. + + <style> + .api > tr > th, td { text-align: center; padding: 4px 4px; } + .api > tr > th { vertical-align: bottom; } + .api > tr > td { vertical-align: middle; } + .sml > tr > th, td { text-align: center; padding: 2px 4px; } + .fn { text-align: left; } + .fn > code > a { font: 14px/19px Roboto Condensed, sans-serif; } + .deg45 { + white-space: nowrap; background: none; border: none; vertical-align: bottom; + width: 30px; height: 83px; + } + .deg45 > div { + transform: skew(-45deg, 0deg) translate(1px, -67px); + transform-origin: bottom left 0; + width: 30px; height: 20px; + } + .deg45 > div > div { border: 1px solid #ddd; background: #999; height: 90px; width: 42px; } + .deg45 > div > div > div { transform: skew(45deg, 0deg) translate(-55px, 55px) rotate(-45deg); } + </style> + + <table align="right" style="width: 0%"> + <thead> + <tr><th>Symbol</th><th>Meaning</th></tr> + </thead> + <tbody class=sml> + <tr><td>●</td><td>Supported</td></tr> + <tr><td>⁕</td><td>Semantics changed</td></tr> + <tr><td>○</td><td>Experimental support</td></tr> + <tr><td>[ ]</td><td>Deprecated</td></tr> + <tr><td>⎋</td><td>Restricted to surface input mode</td></tr> + <tr><td>⎆</td><td>Restricted to surface output mode</td></tr> + <tr><td>▧</td><td>Restricted to ByteBuffer input mode</td></tr> + <tr><td>↩</td><td>Restricted to synchronous mode</td></tr> + <tr><td>⇄</td><td>Restricted to asynchronous mode</td></tr> + <tr><td>( )</td><td>Can be called, but shouldn't</td></tr> + </tbody> + </table> + + <table style="width: 100%;"> + <thead class=api> + <tr> + <th class=deg45><div><div style="background:#4285f4"><div>Uninitialized</div></div></div></th> + <th class=deg45><div><div style="background:#f4b400"><div>Configured</div></div></div></th> + <th class=deg45><div><div style="background:#e67c73"><div>Flushed</div></div></div></th> + <th class=deg45><div><div style="background:#0f9d58"><div>Running</div></div></div></th> + <th class=deg45><div><div style="background:#f7cb4d"><div>End of Stream</div></div></div></th> + <th class=deg45><div><div style="background:#db4437"><div>Error</div></div></div></th> + <th class=deg45><div><div style="background:#666"><div>Released</div></div></div></th> + <th></th> + <th colspan="8">SDK Version</th> + </tr> + <tr> + <th colspan="7">State</th> + <th>Method</th> + <th>16</th> + <th>17</th> + <th>18</th> + <th>19</th> + <th>20</th> + <th>21</th> + <th>22</th> + <th>23</th> + </tr> + </thead> + <tbody class=api> + <tr> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td class=fn>{@link #createByCodecName createByCodecName}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td class=fn>{@link #createDecoderByType createDecoderByType}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td class=fn>{@link #createEncoderByType createEncoderByType}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td class=fn>{@link #createPersistentInputSurface createPersistentInputSurface}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>●</td> + </tr> + <tr> + <td>16+</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #configure configure}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>⁕</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>18+</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #createInputSurface createInputSurface}</td> + <td></td> + <td></td> + <td>⎋</td> + <td>⎋</td> + <td>⎋</td> + <td>⎋</td> + <td>⎋</td> + <td>⎋</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>16+</td> + <td>(16+)</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #dequeueInputBuffer dequeueInputBuffer}</td> + <td>●</td> + <td>●</td> + <td>▧</td> + <td>▧</td> + <td>▧</td> + <td>⁕▧↩</td> + <td>▧↩</td> + <td>▧↩</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #dequeueOutputBuffer dequeueOutputBuffer}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>⁕↩</td> + <td>↩</td> + <td>↩</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #flush flush}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>18+</td> + <td>18+</td> + <td>18+</td> + <td>18+</td> + <td>18+</td> + <td>18+</td> + <td>-</td> + <td class=fn>{@link #getCodecInfo getCodecInfo}</td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>(21+)</td> + <td>21+</td> + <td>(21+)</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getInputBuffer getInputBuffer}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>(16+)</td> + <td>(16+)</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getInputBuffers getInputBuffers}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>[⁕↩]</td> + <td>[↩]</td> + <td>[↩]</td> + </tr> + <tr> + <td>-</td> + <td>21+</td> + <td>(21+)</td> + <td>(21+)</td> + <td>(21+)</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getInputFormat getInputFormat}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>(21+)</td> + <td>21+</td> + <td>(21+)</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getInputImage getInputImage}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>○</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>18+</td> + <td>18+</td> + <td>18+</td> + <td>18+</td> + <td>18+</td> + <td>18+</td> + <td>-</td> + <td class=fn>{@link #getName getName}</td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>(21+)</td> + <td>21+</td> + <td>21+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getOutputBuffer getOutputBuffer}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getOutputBuffers getOutputBuffers}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>[⁕↩]</td> + <td>[↩]</td> + <td>[↩]</td> + </tr> + <tr> + <td>-</td> + <td>21+</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getOutputFormat()}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>(21+)</td> + <td>21+</td> + <td>21+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getOutputFormat(int)}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>(21+)</td> + <td>21+</td> + <td>21+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #getOutputImage getOutputImage}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>○</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>(16+)</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #queueInputBuffer queueInputBuffer}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>⁕</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>(16+)</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #queueSecureInputBuffer queueSecureInputBuffer}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>⁕</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td class=fn>{@link #release release}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>16+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #releaseOutputBuffer(int, boolean)}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>⁕</td> + <td>●</td> + <td>⁕</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>-</td> + <td>21+</td> + <td>21+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #releaseOutputBuffer(int, long)}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>⎆</td> + <td>⎆</td> + <td>⎆</td> + </tr> + <tr> + <td>21+</td> + <td>21+</td> + <td>21+</td> + <td>21+</td> + <td>21+</td> + <td>21+</td> + <td>-</td> + <td class=fn>{@link #reset reset}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>21+</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #setCallback(Callback) setCallback}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>{@link #setCallback(Callback, Handler) ⁕}</td> + </tr> + <tr> + <td>-</td> + <td>23+</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #setInputSurface setInputSurface}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>⎋</td> + </tr> + <tr> + <td>23+</td> + <td>23+</td> + <td>23+</td> + <td>23+</td> + <td>23+</td> + <td>(23+)</td> + <td>(23+)</td> + <td class=fn>{@link #setOnFrameRenderedListener setOnFrameRenderedListener}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>○ ⎆</td> + </tr> + <tr> + <td>-</td> + <td>23+</td> + <td>23+</td> + <td>23+</td> + <td>23+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #setOutputSurface setOutputSurface}</td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td></td> + <td>⎆</td> + </tr> + <tr> + <td>19+</td> + <td>19+</td> + <td>19+</td> + <td>19+</td> + <td>19+</td> + <td>(19+)</td> + <td>-</td> + <td class=fn>{@link #setParameters setParameters}</td> + <td></td> + <td></td> + <td></td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>(16+)</td> + <td>-</td> + <td class=fn>{@link #setVideoScalingMode setVideoScalingMode}</td> + <td>⎆</td> + <td>⎆</td> + <td>⎆</td> + <td>⎆</td> + <td>⎆</td> + <td>⎆</td> + <td>⎆</td> + <td>⎆</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>18+</td> + <td>18+</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #signalEndOfInputStream signalEndOfInputStream}</td> + <td></td> + <td></td> + <td>⎋</td> + <td>⎋</td> + <td>⎋</td> + <td>⎋</td> + <td>⎋</td> + <td>⎋</td> + </tr> + <tr> + <td>-</td> + <td>16+</td> + <td>21+(⇄)</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #start start}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>⁕</td> + <td>●</td> + <td>●</td> + </tr> + <tr> + <td>-</td> + <td>-</td> + <td>16+</td> + <td>16+</td> + <td>16+</td> + <td>-</td> + <td>-</td> + <td class=fn>{@link #stop stop}</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + <td>●</td> + </tr> + </tbody> + </table> */ final public class MediaCodec { /** @@ -548,14 +1652,14 @@ final public class MediaCodec { } /** - * Returns the codec to its initial (Initialized) state. + * Returns the codec to its initial (Uninitialized) state. * * Call this if an {@link MediaCodec.CodecException#isRecoverable unrecoverable} * error has occured to reset the codec to its initial state after creation. * * @throws CodecException if an unrecoverable error has occured and the codec * could not be reset. - * @throws IllegalStateException if in the Uninitialized state. + * @throws IllegalStateException if in the Released state. */ public final void reset() { freeAllTrackedBuffers(); // free buffers first @@ -607,7 +1711,7 @@ final public class MediaCodec { * or the format is unacceptable (e.g. missing a mandatory key), * or the flags are not set properly * (e.g. missing {@link #CONFIGURE_FLAG_ENCODE} for an encoder). - * @throws IllegalStateException if not in the Initialized state. + * @throws IllegalStateException if not in the Uninitialized state. * @throws CryptoException upon DRM error. * @throws CodecException upon codec error. */ @@ -765,7 +1869,7 @@ final public class MediaCodec { * remains active and ready to be {@link #start}ed again. * To ensure that it is available to other client call {@link #release} * and don't just rely on garbage collection to eventually do this for you. - * @throws IllegalStateException if in the Uninitialized state. + * @throws IllegalStateException if in the Released state. */ public final void stop() { native_stop(); @@ -1771,14 +2875,14 @@ final public class MediaCodec { * If a surface has been specified in a previous call to {@link #configure} * specifies the scaling mode to use. The default is "scale to fit". * @throws IllegalArgumentException if mode is not recognized. - * @throws IllegalStateException if in the Uninitialized state. + * @throws IllegalStateException if in the Released state. */ public native final void setVideoScalingMode(@VideoScalingMode int mode); /** * Get the component name. If the codec was created by createDecoderByType * or createEncoderByType, what component is chosen is not known beforehand. - * @throws IllegalStateException if in the Uninitialized state. + * @throws IllegalStateException if in the Released state. */ @NonNull public native final String getName(); @@ -1811,7 +2915,7 @@ final public class MediaCodec { * <b>Note:</b> Some of these parameter changes may silently fail to apply. * * @param params The bundle of parameters to set. - * @throws IllegalStateException if in the Uninitialized state. + * @throws IllegalStateException if in the Released state. */ public final void setParameters(@Nullable Bundle params) { if (params == null) { @@ -2025,7 +3129,7 @@ final public class MediaCodec { * Get the codec info. If the codec was created by createDecoderByType * or createEncoderByType, what component is chosen is not known beforehand, * and thus the caller does not have the MediaCodecInfo. - * @throws IllegalStateException if in the Uninitialized state. + * @throws IllegalStateException if in the Released state. */ @NonNull public MediaCodecInfo getCodecInfo() { |
