1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977
|
Source API Reference (obs_source_t)
===================================
Sources are used to render video and/or audio on stream. Things such as
capturing displays/games/audio, playing a video, showing an image, or
playing audio. Sources can also be used to implement audio and video
filters as well as transitions. The `libobs/obs-source.h`_ file is the
dedicated header for implementing sources.
.. type:: obs_source_t
A reference-counted video/audio input source.
.. type:: obs_weak_source_t
A weak reference to an video/audio input source.
.. code:: cpp
#include <obs.h>
Source Definition Structure (obs_source_info)
---------------------------------------------
.. struct:: obs_source_info
Source definition structure.
.. member:: const char *obs_source_info.id
Unique string identifier for the source (required).
.. member:: uint32_t version
Source version (optional).
This is used when a source's implementation is significantly
modified and the previous version is deprecated, but is kept to
prevent old sources from breaking.
.. member:: enum obs_source_type obs_source_info.type
Type of source.
- **OBS_SOURCE_TYPE_INPUT** - Video/Audio Input
- **OBS_SOURCE_TYPE_FILTER** - Filter
- **OBS_SOURCE_TYPE_TRANSITION** - Transition
.. member:: uint32_t obs_source_info.output_flags
Source output capability flags (required).
(Author's note: This should be renamed to "capability_flags")
A bitwise OR combination of one or more of the following values:
- **OBS_SOURCE_VIDEO** - Source has video
Unless SOURCE_ASYNC_VIDEO is specified, the source must include the
:c:member:`obs_source_info.video_render` callback in the source
definition structure.
- **OBS_SOURCE_AUDIO** - Source has audio
Use the :c:func:`obs_source_output_audio()` function to pass raw
audio data, which will be automatically converted and uploaded. If
used with OBS_SOURCE_ASYNC_VIDEO, audio will automatically be
synced up to the video output based upon their mutual timestamps.
- **OBS_SOURCE_ASYNC** - Video is asynchronous (use
OBS_SOURCE_ASYNC_VIDEO instead to automatically combine this flag
with the OBS_SOURCE_VIDEO flag).
- **OBS_SOURCE_ASYNC_VIDEO** - Source passes raw video data via RAM
Use the :c:func:`obs_source_output_video()` function to pass raw
video data, which will be automatically drawn at a timing relative
to the provided timestamp.
If audio is also present on the source, the audio will
automatically be synced to the video based upon their mutual
timestamps.
- **OBS_SOURCE_CUSTOM_DRAW** - Source uses custom graphics calls,
rather than just rendering a single texture.
This capability flag must be used if the source does not use
:c:func:`obs_source_draw()` to render a single texture.
This capability flag is an important hint to turn off a specific
optimization that allows the first effect filter in the filter
chain to render the source directly with that effect filter. The
optimization does not work if there are custom graphics calls, and
the source must be rendered to a texture first before being sent to
the first filter in the filter chain.
(Author's note: Ironically, not many sources render with that
optimization. I should have made it so that the optimization isn't
used by default, and a flag should have been used to turn on the
optimization -- not turn it off).
- **OBS_SOURCE_INTERACTION** - Source can be interacted with by the
user.
When this is used, the source will receive interaction events if
these callbacks are provided:
:c:member:`obs_source_info.mouse_click`,
:c:member:`obs_source_info.mouse_move`,
:c:member:`obs_source_info.mouse_wheel`,
:c:member:`obs_source_info.focus`, and
:c:member:`obs_source_info.key_click`.
- **OBS_SOURCE_COMPOSITE** - Source composites child sources
When used, specifies that the source composites one or more child
sources. Scenes and transitions are examples of sources that
contain and render child sources.
Sources that render sub-sources must implement the audio_render
callback in order to perform custom audio mixing of child sources.
This capability flag is always set for transitions.
- **OBS_SOURCE_DO_NOT_DUPLICATE** - Source should not be fully
duplicated.
When this is used, specifies that the source should not be fully
duplicated, and should prefer to duplicate via holding references
rather than full duplication.
When functions such as :c:func:`obs_source_duplicate()` or
:c:func:`obs_scene_duplicate()` are called, sources or child
sources with this flag will never be fully duplicated, and will
instead only be referenced.
An example of the type of sources that should not be fully
duplicated are video devices, browsers, and video/audio captures,
as they will either not function correctly or will cause
performance or resource issues when duplicated.
- **OBS_SOURCE_DEPRECATED** - Source is deprecated and should not be
used.
- **OBS_SOURCE_DO_NOT_SELF_MONITOR** - Audio of this source should
not allow monitoring if the current monitoring device is the same
device being captured by the source.
This flag is used as a hint to the back-end to prevent the source
from creating an audio feedback loop. This is primarily only used
with desktop audio capture sources.
- **OBS_SOURCE_CAP_DISABLED** - This source type has been disabled
and should not be shown as a type of source the user can add.
- **OBS_SOURCE_CAP_OBSOLETE** - This source type is obsolete and
should not be shown as a type of source the user can add.
Identical to *OBS_SOURCE_CAP_DISABLED*. Meant to be used when a
source has changed in some way (mostly defaults/properties), but
you want to avoid breaking older configurations. Basically solves
the problem of "I want to change the defaults of a source but I
don't want to break people's configurations"
- **OBS_SOURCE_CONTROLLABLE_MEDIA** - This source has media that can
be controlled
- **OBS_SOURCE_MONITOR_BY_DEFAULT** - Source should enable
monitoring by default. Monitoring should be set by the
frontend if this flag is set.
- **OBS_SOURCE_CEA_708** - Source type provides cea708 data
- **OBS_SOURCE_SRGB** - Source understands SRGB rendering
- **OBS_SOURCE_CAP_DONT_SHOW_PROPERTIES** - Source type prefers not
to have its properties shown on creation (prefers to rely on
defaults first)
.. member:: const char *(*obs_source_info.get_name)(void *type_data)
Get the translated name of the source type.
:param type_data: The type_data variable of this structure
:return: The translated name of the source type
.. member:: void *(*obs_source_info.create)(obs_data_t *settings, obs_source_t *source)
Creates the implementation data for the source.
:param settings: Settings to initialize the source with
:param source: Source that this data is associated with
:return: The implementation data associated with this source
.. member:: void (*obs_source_info.destroy)(void *data)
Destroys the implementation data for the source.
Async sources must not call obs_source_output_video after returning
from destroy.
.. member:: uint32_t (*obs_source_info.get_width)(void *data)
uint32_t (*obs_source_info.get_height)(void *data)
Returns the width/height of the source. These callbacks are required
if this is a video source and is synchronous.
(Author's note: These should really be consolidated in to one
function, not two)
:return: The width/height of the video
.. member:: void (*obs_source_info.get_defaults)(obs_data_t *settings)
void (*obs_source_info.get_defaults2)(void *type_data, obs_data_t *settings)
Sets the default settings for this source.
:param settings: Default settings. Call obs_data_set_default*
functions on this object to set default setting
values
.. member:: obs_properties_t *(*obs_source_info.get_properties)(void *data)
obs_properties_t *(*obs_source_info.get_properties2)(void *data, void *type_data)
Gets the property information of this source.
:param data: The implementation data associated with this source.
This value can be null (e.g., when
:c:func:`obs_get_source_properties()` is called on the
source type), make sure to handle this gracefully.
(Optional)
:return: The properties of the source
.. member:: void (*obs_source_info.update)(void *data, obs_data_t *settings)
Updates the settings for this source.
(Optional)
:param settings: New settings for this source
.. member:: void (*obs_source_info.activate)(void *data)
Called when the source has been activated in the main view (visible
on stream/recording).
(Optional)
.. member:: void (*obs_source_info.deactivate)(void *data)
Called when the source has been deactivated from the main view (no
longer visible on stream/recording).
(Optional)
.. member:: void (*obs_source_info.show)(void *data)
Called when the source is visible on any display and/or on the main
view.
(Optional)
.. member:: void (*obs_source_info.hide)(void *data)
Called when the source is no longer visible on any display and/or on
the main view.
(Optional)
.. member:: void (*obs_source_info.video_tick)(void *data, float seconds)
Called each video frame with the time elapsed.
(Optional)
:param seconds: Seconds elapsed since the last frame
.. member:: void (*obs_source_info.video_render)(void *data, gs_effect_t *effect)
Called when rendering the source with the graphics subsystem.
If this is an input/transition source, this is called to draw the
source texture with the graphics subsystem.
If this is a filter source, it wraps source draw calls (for example
applying a custom effect with custom parameters to a source). In
this case, it's highly recommended to use the
:c:func:`obs_source_process_filter_begin()` and
:c:func:`obs_source_process_filter_end()` functions to automatically
handle effect-based filter processing. However, you can implement
custom draw handling as desired as well.
If the source output capability flags do not include
OBS_SOURCE_CUSTOM_DRAW, the source must use
:c:func:`obs_source_draw()` to render the source's texture.
:param effect: This parameter is no longer used. Instead, call
:c:func:`obs_source_draw()`
.. member:: struct obs_source_frame *(*obs_source_info.filter_video)(void *data, struct obs_source_frame *frame)
Called to filter raw async video data. This function is only used
with asynchronous video filters.
:param frame: Video frame to filter
:return: New video frame data. This can defer video data to
be drawn later if time is needed for processing
.. member:: struct obs_audio_data *(*obs_source_info.filter_audio)(void *data, struct obs_audio_data *audio)
Called to filter raw audio data. This function is only used with
audio filters.
:param audio: Audio data to filter
:return: Modified or new audio data. You can directly modify
the data passed and return it, or you can defer audio
data for later if time is needed for processing. If
you are returning new data, that data must exist until
the next call to the
:c:member:`obs_source_info.filter_audio` callback or
until the filter is removed/destroyed
.. member:: void (*obs_source_info.enum_active_sources)(void *data, obs_source_enum_proc_t enum_callback, void *param)
Called to enumerate all active sources being used within this
source. If the source has children that render audio/video it must
implement this callback. Only used with sources that have the
OBS_SOURCE_COMPOSITE output capability flag.
:param enum_callback: Enumeration callback
:param param: User data to pass to callback
.. member:: void (*obs_source_info.save)(void *data, obs_data_t *settings)
Called when saving custom data for a source. This is a separate
function because sometimes a source needs to know when it is being
saved so it doesn't always have to update the current settings until
a certain point.
(Optional)
:param settings: Settings object to save data to
.. member:: void (*obs_source_info.load)(void *data, obs_data_t *settings)
Called when loading custom data from saved source data. This is
called after all the loading sources have actually been created,
allowing the ability to reference other sources if desired.
(Optional)
:param settings: Settings object to load data from
.. member:: void (*obs_source_info.mouse_click)(void *data, const struct obs_mouse_event *event, int32_t type, bool mouse_up, uint32_t click_count)
Called when interacting with a source and a mouse-down or mouse-up
occurs. Only used with sources that have the OBS_SOURCE_INTERACTION
output capability flag.
(Optional)
:param event: Mouse event properties
:param type: Mouse button pushed
:param mouse_up: Mouse event type (true if mouse-up)
:param click_count: Mouse click count (1 for single click, etc.)
.. member:: void (*obs_source_info.mouse_move)(void *data, const struct obs_mouse_event *event, bool mouse_leave)
Called when interacting with a source and a mouse-move occurs. Only
used with sources that have the OBS_SOURCE_INTERACTION output
capability flag.
(Optional)
:param event: Mouse event properties
:param mouse_leave: Mouse leave state (true if mouse left source)
.. member:: void (*obs_source_info.mouse_wheel)(void *data, const struct obs_mouse_event *event, int x_delta, int y_delta)
Called when interacting with a source and a mouse-wheel occurs. Only
used with sources that have the OBS_SOURCE_INTERACTION output
capability flag.
(Optional)
:param event: Mouse event properties
:param x_delta: Movement delta in the horizontal direction
:param y_delta: Movement delta in the vertical direction
.. member:: void (*obs_source_info.focus)(void *data, bool focus)
Called when interacting with a source and gain focus/lost focus event
occurs. Only used with sources that have the OBS_SOURCE_INTERACTION
output capability flag.
(Optional)
:param focus: Focus state (true if focus gained)
.. member:: void (*obs_source_info.key_click)(void *data, const struct obs_key_event *event, bool key_up)
Called when interacting with a source and a key-up or key-down
occurs. Only used with sources that have the OBS_SOURCE_INTERACTION
output capability flag.
(Optional)
:param event: Key event properties
:param focus: Key event type (true if mouse-up)
.. member:: void (*obs_source_info.filter_add)(void *data, obs_source_t *source)
Called when the filter is added to a source.
(Optional)
:param data: Filter data
:param source: Source that the filter is being added to
.. member:: void (*obs_source_info.filter_remove)(void *data, obs_source_t *source)
Called when the filter is removed from a source.
(Optional)
:param data: Filter data
:param source: Source that the filter being removed from
.. member:: void *obs_source_info.type_data
void (*obs_source_info.free_type_data)(void *type_data)
Private data associated with this entry. Note that this is not the
same as the implementation data; this is used to differentiate
between two different types if the same callbacks are used for more
than one different type.
.. member:: bool (*obs_source_info.audio_render)(void *data, uint64_t *ts_out, struct obs_source_audio_mix *audio_output, uint32_t mixers, size_t channels, size_t sample_rate)
Called to render audio of composite sources. Only used with sources
that have the OBS_SOURCE_COMPOSITE output capability flag.
.. member:: void (*obs_source_info.enum_all_sources)(void *data, obs_source_enum_proc_t enum_callback, void *param)
Called to enumerate all active and inactive sources being used
within this source. If this callback isn't implemented,
enum_active_sources will be called instead. Only used with sources
that have the OBS_SOURCE_COMPOSITE output capability flag.
This is typically used if a source can have inactive child sources.
:param enum_callback: Enumeration callback
:param param: User data to pass to callback
.. member:: void (*obs_source_info.transition_start)(void *data)
void (*obs_source_info.transition_stop)(void *data)
Called on transition sources when the transition starts/stops.
(Optional)
.. member:: enum obs_icon_type obs_source_info.icon_type
Icon used for the source.
- **OBS_ICON_TYPE_UNKNOWN** - Unknown
- **OBS_ICON_TYPE_IMAGE** - Image
- **OBS_ICON_TYPE_COLOR** - Color
- **OBS_ICON_TYPE_SLIDESHOW** - Slideshow
- **OBS_ICON_TYPE_AUDIO_INPUT** - Audio Input
- **OBS_ICON_TYPE_AUDIO_OUTPUT** - Audio Output
- **OBS_ICON_TYPE_DESKTOP_CAPTURE** - Desktop Capture
- **OBS_ICON_TYPE_WINDOW_CAPTURE** - Window Capture
- **OBS_ICON_TYPE_GAME_CAPTURE** - Game Capture
- **OBS_ICON_TYPE_CAMERA** - Camera
- **OBS_ICON_TYPE_TEXT** - Text
- **OBS_ICON_TYPE_MEDIA** - Media
- **OBS_ICON_TYPE_BROWSER** - Browser
- **OBS_ICON_TYPE_CUSTOM** - Custom (not implemented yet)
.. member:: void (*obs_source_info.media_play_pause)(void *data, bool pause)
Called to pause or play media.
.. member:: void (*obs_source_info.media_restart)(void *data)
Called to restart the media.
.. member:: void (*obs_source_info.media_stop)(void *data)
Called to stop the media.
.. member:: void (*obs_source_info.media_next)(void *data)
Called to go to the next media.
.. member:: void (*obs_source_info.media_previous)(void *data)
Called to go to the previous media.
.. member:: int64_t (*obs_source_info.media_get_duration)(void *data)
Called to get the media duration.
.. member:: int64_t (*obs_source_info.media_get_time)(void *data)
Called to get the current time of the media.
.. member:: void (*obs_source_info.media_set_time)(void *data, int64_t milliseconds)
Called to set the media time.
.. member:: enum obs_media_state (*obs_source_info.media_get_state)(void *data)
Called to get the state of the media.
- **OBS_MEDIA_STATE_NONE** - None
- **OBS_MEDIA_STATE_PLAYING** - Playing
- **OBS_MEDIA_STATE_OPENING** - Opening
- **OBS_MEDIA_STATE_BUFFERING** - Buffering
- **OBS_MEDIA_STATE_PAUSED** - Paused
- **OBS_MEDIA_STATE_STOPPED** - Stopped
- **OBS_MEDIA_STATE_ENDED** - Ended
- **OBS_MEDIA_STATE_ERROR** - Error
.. member:: obs_missing_files_t *(*missing_files)(void *data)
Called to get the missing files of the source.
.. member:: enum gs_color_space (*obs_source_info.video_get_color_space)(void *data, size_t count, const enum gs_color_space *preferred_spaces)
Returns the color space of the source. Assume GS_CS_SRGB if not
implemented.
There's an optimization an SDR source can do when rendering to HDR.
Check if the active space is GS_CS_709_EXTENDED, and return
GS_CS_709_EXTENDED instead of GS_CS_SRGB to avoid an redundant
conversion. This optimization can only be done if the pixel shader
outputs linear 709, which is why it's not performed by default.
:return: The color space of the video
.. _source_signal_handler_reference:
Common Source Signals
---------------------
The following signals are defined for every source type:
**destroy** (ptr *source*)
This signal is called when the source is about to be destroyed. Do
not increment any references when using this signal.
**remove** (ptr source)
Called when the :c:func:`obs_source_remove()` function is called on
the source.
**update** (ptr source)
Called when the source's settings have been updated.
.. versionadded:: 29.0.0
**save** (ptr source)
Called when the source is being saved.
**load** (ptr source)
Called when the source is being loaded.
**activate** (ptr source)
Called when the source has been activated in the main view (visible
on stream/recording).
**deactivate** (ptr source)
Called when the source has been deactivated from the main view (no
longer visible on stream/recording).
**show** (ptr source)
Called when the source is visible on any display and/or on the main
view.
**hide** (ptr source)
Called when the source is no longer visible on any display and/or on
the main view.
**mute** (ptr source, bool muted)
Called when the source is muted/unmuted.
**push_to_mute_changed** (ptr source, bool enabled)
Called when push-to-mute has been enabled/disabled.
**push_to_mute_delay** (ptr source, int delay)
Called when the push-to-mute delay value has changed.
**push_to_talk_changed** (ptr source, bool enabled)
Called when push-to-talk has been enabled/disabled.
**push_to_talk_delay** (ptr source, int delay)
Called when the push-to-talk delay value has changed.
**enable** (ptr source, bool enabled)
Called when the source has been disabled/enabled.
**rename** (ptr source, string new_name, string prev_name)
Called when the source has been renamed.
**volume** (ptr source, in out float volume)
Called when the volume of the source has changed.
**update_properties** (ptr source)
Called to signal to any properties view (or other users of the source's
obs_properties_t) that the presentable properties of the source have changed
and should be re-queried via obs_source_properties.
Does not mean that the source's *settings* (as configured by the user) have
changed. For that, use the `update` signal instead.
**update_flags** (ptr source, int flags)
Called when the flags of the source have been changed.
**audio_sync** (ptr source, int out int offset)
Called when the audio sync offset has changed.
**audio_balance** (ptr source, in out float balance)
Called when the audio balance has changed.
**audio_mixers** (ptr source, in out int mixers)
Called when the audio mixers have changed.
**audio_activate** (ptr source)
Called when the source's audio becomes active.
**audio_deactivate** (ptr source)
Called when the source's audio becomes inactive.
**filter_add** (ptr source, ptr filter)
Called when a filter has been added to the source.
.. versionadded:: 30.0
**filter_remove** (ptr source, ptr filter)
Called when a filter has been removed from the source.
**reorder_filters** (ptr source)
Called when filters have been reordered.
**transition_start** (ptr source)
Called when a transition is starting.
**transition_video_stop** (ptr source)
Called when a transition's video transitioning has stopped.
**transition_stop** (ptr source)
Called when a transition has stopped.
**media_started** (ptr source)
Called when media has started.
**media_ended** (ptr source)
Called when media has ended.
**media_pause** (ptr source)
Called when media has been paused.
**media_play** (ptr source)
Called when media starts playing.
**media_restart** (ptr source)
Called when the playing of media has been restarted.
**media_stopped** (ptr source)
Called when the playing of media has been stopped.
**media_next** (ptr source)
Called when the media source switches to the next media.
**media_previous** (ptr source)
Called when the media source switches to the previous media.
Source-specific Signals
-----------------------
**slide_changed** (int index, string path)
Called when the source's currently displayed image changes.
:Defined by: - Image Slide Show
-----------------------
**hooked** (ptr source, string title, string class, string executable)
Called when the source successfully captures an existing window.
:Defined by: - Window Capture (Windows)
- Game Capture (Windows)
- Application Audio Output Capture (Windows)
-----------------------
**hooked** (ptr source, string name, string class)
Called when the source successfully captures an existing window.
:Defined by: - Window Capture (Xcomposite)
-----------------------
**unhooked** (ptr source)
Called when the source stops capturing.
:Defined by: - Window Capture (Windows)
- Game Capture (Windows)
- Application Audio Output Capture (Windows)
- Window Capture (Xcomposite)
-----------------------
Source-specific Procedures
--------------------------
The following procedures are defined for specific sources only:
**current_index** (out int current_index)
Returns the index of the currently displayed image in the slideshow.
:Defined by: - Image Slide Show
-----------------------
**total_files** (out int total_files)
Returns the total number of image files in the slideshow.
:Defined by: - Image Slide Show
-----------------------
**get_hooked** (out bool hooked, out string title, out string class, out string executable)
Returns whether the source is currently capturing a window and if yes, which.
:Defined by: - Window Capture (Windows)
- Game Capture (Windows)
- Application audio output capture (Windows)
-----------------------
**get_hooked** (out bool hooked, out string name, out string class)
Returns whether the source is currently capturing a window and if yes, which.
:Defined by: - Window Capture (Xcomposite)
-----------------------
**get_metadata** (in string tag_id, out string tag_data)
For a given metadata tag, returns the data associated with it.
:Defined by: - VLC Video Source
-----------------------
**restart** ()
Restarts the media.
:Defined by: - Media Source
-----------------------
**get_duration** (out int duration)
Returns the total duration of the media file, in nanoseconds.
:Defined by: - Media Source
-----------------------
**get_nb_frames** (out int num_frames)
Returns the total number of frames in the media file.
:Defined by: - Media Source
-----------------------
**activate** (in bool active)
Activates or deactivates the device.
:Defined by: - Video Capture Device Source (Windows)
-----------------------
General Source Functions
------------------------
.. function:: void obs_register_source(struct obs_source_info *info)
Registers a source type. Typically used in
:c:func:`obs_module_load()` or in the program's initialization phase.
---------------------
.. function:: const char *obs_source_get_display_name(const char *id)
Calls the :c:member:`obs_source_info.get_name` callback to get the
translated display name of a source type.
:param id: The source type string identifier
:return: The translated display name of a source type
---------------------
.. function:: obs_source_t *obs_source_create(const char *id, const char *name, obs_data_t *settings, obs_data_t *hotkey_data)
Creates a source of the specified type with the specified settings.
The "source" context is used for anything related to presenting
or modifying video/audio. Use :c:func:`obs_source_release` to release it.
:param id: The source type string identifier
:param name: The desired name of the source. If this is
not unique, it will be made to be unique
:param settings: The settings for the source, or *NULL* if
none
:param hotkey_data: Saved hotkey data for the source, or *NULL*
if none
:return: A reference to the newly created source, or
*NULL* if failed
---------------------
.. function:: obs_source_t *obs_source_create_private(const char *id, const char *name, obs_data_t *settings)
Creates a 'private' source which is not enumerated by
:c:func:`obs_enum_sources()`, and is not saved by
:c:func:`obs_save_sources()`.
Author's Note: The existence of this function is a result of design
flaw: the front-end should control saving/loading of sources, and
functions like :c:func:`obs_enum_sources()` and
:c:func:`obs_save_sources()` should not exist in the back-end.
:param id: The source type string identifier
:param name: The desired name of the source. For private
sources, this does not have to be unique,
and can additionally be *NULL* if desired
:param settings: The settings for the source, or *NULL* if
none
:return: A reference to the newly created source, or
*NULL* if failed
---------------------
.. function:: obs_source_t *obs_source_duplicate(obs_source_t *source, const char *desired_name, bool create_private)
Duplicates a source. If the source has the
OBS_SOURCE_DO_NOT_DUPLICATE output flag set, this only returns a
new reference to the same source. Either way,
release with :c:func:`obs_source_release`.
:param source: The source to duplicate
:param desired_name: The desired name of the new source. If this is
not a private source and the name is not unique,
it will be made to be unique
:param create_private: If *true*, the new source will be a private
source if fully duplicated
:return: A new source reference
---------------------
.. function:: void obs_source_addref(obs_source_t *source)
Adds a reference to a source.
.. deprecated:: 27.2.0
Use :c:func:`obs_source_get_ref()` instead.
---------------------
.. function:: obs_source_t *obs_source_get_ref(obs_source_t *source)
Returns an incremented reference if still valid, otherwise returns
*NULL*. Use :c:func:`obs_source_release` to release it.
---------------------
.. function:: void obs_source_release(obs_source_t *source)
Releases a reference to a source. When the last reference is
released, the source is destroyed.
---------------------
.. function:: obs_weak_source_t *obs_source_get_weak_source(obs_source_t *source)
obs_source_t *obs_weak_source_get_source(obs_weak_source_t *weak)
These functions are used to get an incremented weak reference from a strong source
reference, or an incremented strong source reference from a weak reference. If
the source is destroyed, *obs_weak_source_get_source* will return
*NULL*. Release with :c:func:`obs_weak_source_release()` or
:c:func:`obs_source_release()`, respectively.
---------------------
.. function:: void obs_weak_source_addref(obs_weak_source_t *weak)
void obs_weak_source_release(obs_weak_source_t *weak)
Adds/releases a weak reference to a source.
---------------------
.. function:: void obs_source_remove(obs_source_t *source)
Notifies all reference holders of the source (via
:c:func:`obs_source_removed()`) that the source should be released.
---------------------
.. function:: bool obs_source_removed(const obs_source_t *source)
:return: *true* if the source should be released
---------------------
.. function:: bool obs_source_is_hidden(obs_source_t *source)
void obs_source_set_hidden(obs_source_t *source, bool hidden)
Gets/sets the hidden property that determines whether it should be hidden from the user.
Used when the source is still alive but should not be referenced.
---------------------
.. function:: uint32_t obs_source_get_output_flags(const obs_source_t *source)
uint32_t obs_get_source_output_flags(const char *id)
:return: Capability flags of a source
Author's Note: "Output flags" is poor wording in retrospect; this
should have been named "Capability flags", and the OBS_SOURCE_*
macros should really be OBS_SOURCE_CAP_* macros instead.
See :c:member:`obs_source_info.output_flags` for more information.
---------------------
.. function:: obs_data_t *obs_get_source_defaults(const char *id)
Calls :c:member:`obs_source_info.get_defaults` to get the defaults
settings of the source type.
:return: The default settings for a source type
---------------------
.. function:: obs_properties_t *obs_source_properties(const obs_source_t *source)
obs_properties_t *obs_get_source_properties(const char *id)
Use these functions to get the properties of a source or source type.
Properties are optionally used (if desired) to automatically generate
user interface widgets to allow users to update settings.
:return: The properties list for a specific existing source. Free with
:c:func:`obs_properties_destroy()`
---------------------
.. function:: bool obs_source_configurable(const obs_source_t *source)
bool obs_is_source_configurable(const char *id)
:return: *true* if the the source has custom properties, *false*
otherwise
---------------------
.. function:: void obs_source_update(obs_source_t *source, obs_data_t *settings)
Updates the settings for a source and calls the
:c:member:`obs_source_info.update` callback of the source. If the
source is a video source, the :c:member:`obs_source_info.update` will
be not be called immediately; instead, it will be deferred to the
video thread to prevent threading issues.
---------------------
.. function:: void obs_source_reset_settings(obs_source_t *source, obs_data_t *settings)
Same as :c:func:`obs_source_update`, but clears existing settings
first.
---------------------
.. function:: void obs_source_video_render(obs_source_t *source)
Renders a video source. This will call the
:c:member:`obs_source_info.video_render` callback of the source.
---------------------
.. function:: uint32_t obs_source_get_width(obs_source_t *source)
uint32_t obs_source_get_height(obs_source_t *source)
Calls the :c:member:`obs_source_info.get_width` or
:c:member:`obs_source_info.get_height` of the source to get its width
and/or height.
Author's Note: These functions should be consolidated in to a single
function/callback rather than having a function for both width and
height.
:return: The width or height of the source
---------------------
.. function:: enum gs_color_space obs_source_get_color_space(obs_source_t *source, size_t count, const enum gs_color_space *preferred_spaces)
Calls the :c:member:`obs_source_info.video_get_color_space` of the
source to get its color space. Assumes GS_CS_SRGB if not implemented.
Disabled filters are skipped, and async video sources can figure out
the color space for themselves.
:return: The color space of the source
---------------------
.. function:: bool obs_source_get_texcoords_centered(obs_source_t *source)
Hints whether or not the source will blend texels.
:return: Whether or not the source will blend texels
---------------------
.. function:: obs_data_t *obs_source_get_settings(const obs_source_t *source)
:return: The settings string for a source. The reference counter of the
returned settings data is incremented, so
:c:func:`obs_data_release()` must be called when the
settings are no longer used
---------------------
.. function:: const char *obs_source_get_name(const obs_source_t *source)
:return: The name of the source
---------------------
.. function:: const char *obs_source_get_uuid(const obs_source_t *source)
:return: The UUID of the source
.. versionadded:: 29.1
---------------------
.. function:: void obs_source_set_name(obs_source_t *source, const char *name)
Sets the name of a source. If the source is not private and the name
is not unique, it will automatically be given a unique name.
---------------------
.. function:: enum obs_source_type obs_source_get_type(const obs_source_t *source)
:return: | OBS_SOURCE_TYPE_INPUT for inputs
| OBS_SOURCE_TYPE_FILTER for filters
| OBS_SOURCE_TYPE_TRANSITION for transitions
| OBS_SOURCE_TYPE_SCENE for scenes
---------------------
.. function:: bool obs_source_is_scene(const obs_source_t *source)
:return: *true* if the source is a scene
---------------------
.. function:: bool obs_source_is_group(const obs_source_t *source)
:return: *true* if the source is a group
---------------------
.. function:: const char *obs_source_get_id(const obs_source_t *source)
:return: The source's type identifier string. If the source is versioned,
"_vN" is appended at the end, where "N" is the source's version.
---------------------
.. function:: const char *obs_source_get_unversioned_id(const obs_source_t *source)
:return: The source's unversioned type identifier string.
---------------------
.. function:: signal_handler_t *obs_source_get_signal_handler(const obs_source_t *source)
:return: The source's signal handler. Should not be manually freed,
as its lifecycle is managed by libobs.
See the :ref:`source_signal_handler_reference` for more information
on signals that are available for sources.
---------------------
.. function:: proc_handler_t *obs_source_get_proc_handler(const obs_source_t *source)
:return: The procedure handler for a source. Should not be manually freed,
as its lifecycle is managed by libobs.
---------------------
.. function:: void obs_source_set_volume(obs_source_t *source, float volume)
float obs_source_get_volume(const obs_source_t *source)
Sets/gets the user volume for a source that has audio output.
---------------------
.. function:: bool obs_source_muted(const obs_source_t *source)
void obs_source_set_muted(obs_source_t *source, bool muted)
Sets/gets whether the source's audio is muted.
---------------------
.. function:: enum speaker_layout obs_source_get_speaker_layout(obs_source_t *source)
Gets the current speaker layout.
---------------------
.. function:: void obs_source_set_balance_value(obs_source_t *source, float balance)
float obs_source_get_balance_value(const obs_source_t *source)
Sets/gets the audio balance value.
---------------------
.. function:: void obs_source_set_sync_offset(obs_source_t *source, int64_t offset)
int64_t obs_source_get_sync_offset(const obs_source_t *source)
Sets/gets the audio sync offset (in nanoseconds) for a source.
---------------------
.. function:: void obs_source_set_audio_mixers(obs_source_t *source, uint32_t mixers)
uint32_t obs_source_get_audio_mixers(const obs_source_t *source)
Sets/gets the audio mixer channels (i.e. audio tracks) that a source outputs to,
depending on what bits are set. Audio mixers allow filtering
specific using multiple audio encoders to mix different sources
together depending on what mixer channel they're set to.
For example, to output to mixer 1 and 3, you would perform a bitwise
OR on bits 0 and 2: (1<<0) | (1<<2), or 0x5.
---------------------
.. function:: void obs_source_set_monitoring_type(obs_source_t *source, enum obs_monitoring_type type)
enum obs_monitoring_type obs_source_get_monitoring_type(obs_source_t *source)
Sets/gets the desktop audio monitoring type.
:param order: | OBS_MONITORING_TYPE_NONE - Do not monitor
| OBS_MONITORING_TYPE_MONITOR_ONLY - Send to monitor device, no outputs
| OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT - Send to monitor device and outputs
---------------------
.. function:: void obs_source_set_audio_active(obs_source_t *source, bool active)
bool obs_source_audio_active(const obs_source_t *source)
Sets/gets the audio active status (controls whether the source is shown in the mixer).
---------------------
.. function:: void obs_source_enum_active_sources(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
void obs_source_enum_active_tree(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
Enumerates active child sources or source tree used by this source.
Relevant data types used with this function:
.. code:: cpp
typedef void (*obs_source_enum_proc_t)(obs_source_t *parent,
obs_source_t *child, void *param);
---------------------
.. function:: bool obs_source_push_to_mute_enabled(const obs_source_t *source)
void obs_source_enable_push_to_mute(obs_source_t *source, bool enabled)
Sets/gets whether push-to-mute is enabled.
---------------------
.. function:: uint64_t obs_source_get_push_to_mute_delay(const obs_source_t *source)
void obs_source_set_push_to_mute_delay(obs_source_t *source, uint64_t delay)
Sets/gets the push-to-mute delay.
---------------------
.. function:: bool obs_source_push_to_talk_enabled(const obs_source_t *source)
void obs_source_enable_push_to_talk(obs_source_t *source, bool enabled)
Sets/gets whether push-to-talk is enabled.
---------------------
.. function:: uint64_t obs_source_get_push_to_talk_delay(const obs_source_t *source)
void obs_source_set_push_to_talk_delay(obs_source_t *source, uint64_t delay)
Sets/gets the push-to-talk delay.
---------------------
.. function:: bool obs_source_active(const obs_source_t *source)
:return: *true* if active, *false* if not. A source is only
considered active if it's being shown on the final mix
---------------------
.. function:: bool obs_source_showing(const obs_source_t *source)
:return: *true* if showing, *false* if not. A source is considered
showing if it's being displayed anywhere at all, whether on
a display context or on the final output
---------------------
.. function:: void obs_source_inc_showing(obs_source_t *source)
void obs_source_dec_showing(obs_source_t *source)
Increments/decrements a source's "showing" state. Typically used
when drawing a source on a display manually.
---------------------
.. function:: void obs_source_set_flags(obs_source_t *source, uint32_t flags)
uint32_t obs_source_get_flags(const obs_source_t *source)
:param flags: OBS_SOURCE_FLAG_FORCE_MONO Forces audio to mono
---------------------
.. function:: void obs_source_enum_filters(obs_source_t *source, obs_source_enum_proc_t callback, void *param)
Enumerates active filters on a source.
Relevant data types used with this function:
.. code:: cpp
typedef void (*obs_source_enum_proc_t)(obs_source_t *parent,
obs_source_t *child, void *param);
---------------------
.. function:: obs_source_t *obs_source_get_filter_by_name(obs_source_t *source, const char *name)
:return: The desired filter, or *NULL* if not found. The reference
of the filter is incremented
---------------------
.. function:: void obs_source_copy_filters(obs_source_t *dst, obs_source_t *src)
Copies filters from the source to the destination. If filters by the
same name already exist in the destination source, the newer filters
will be given unique names.
---------------------
.. function:: void obs_source_copy_single_filter(obs_source_t *dst, obs_source_t *filter)
Copies the filter from the source to the destination. If a filter by the
same name already exists in the destination source, the newer filter
will be given a unique name.
---------------------
.. function:: size_t obs_source_filter_count(const obs_source_t *source)
Returns the number of filters the source has.
---------------------
.. function:: obs_data_array_t *obs_source_backup_filters(obs_source_t *source)
void obs_source_restore_filters(obs_source_t *source, obs_data_array_t *array)
Backs up and restores the current filter list and order.
---------------------
.. function:: bool obs_source_enabled(const obs_source_t *source)
void obs_source_set_enabled(obs_source_t *source, bool enabled)
Enables/disables a source, or returns the enabled state.
---------------------
.. function:: void obs_source_add_audio_capture_callback(obs_source_t *source, obs_source_audio_capture_t callback, void *param)
void obs_source_remove_audio_capture_callback(obs_source_t *source, obs_source_audio_capture_t callback, void *param)
Adds/removes an audio capture callback for a source. This allows the
ability to get the raw audio data of a source as it comes in.
Relevant data types used with this function:
.. code:: cpp
typedef void (*obs_source_audio_capture_t)(void *param, obs_source_t *source,
const struct audio_data *audio_data, bool muted);
---------------------
.. function:: void obs_source_set_deinterlace_mode(obs_source_t *source, enum obs_deinterlace_mode mode)
enum obs_deinterlace_mode obs_source_get_deinterlace_mode(const obs_source_t *source)
Sets/gets the deinterlace mode.
:param mode: | OBS_DEINTERLACE_MODE_DISABLE - Disables deinterlacing
| OBS_DEINTERLACE_MODE_DISCARD - Discard
| OBS_DEINTERLACE_MODE_RETRO - Retro
| OBS_DEINTERLACE_MODE_BLEND - Blend
| OBS_DEINTERLACE_MODE_BLEND_2X - Blend 2x
| OBS_DEINTERLACE_MODE_LINEAR - Linear
| OBS_DEINTERLACE_MODE_LINEAR_2X - Linear 2x
| OBS_DEINTERLACE_MODE_YADIF - Yadif
| OBS_DEINTERLACE_MODE_YADIF_2X - Yadif 2x
---------------------
.. function:: void obs_source_set_deinterlace_field_order(obs_source_t *source, enum obs_deinterlace_field_order order)
enum obs_deinterlace_field_order obs_source_get_deinterlace_field_order(const obs_source_t *source)
Sets/gets the deinterlace field order.
:param order: | OBS_DEINTERLACE_FIELD_ORDER_TOP - Start from top
| OBS_DEINTERLACE_FIELD_ORDER_BOTTOM - Start from bottom
---------------------
.. function:: obs_data_t *obs_source_get_private_settings(obs_source_t *item)
Gets private front-end settings data. This data is saved/loaded
automatically. Returns an incremented reference. Use :c:func:`obs_data_release()`
to release it.
---------------------
.. function:: void obs_source_send_mouse_click(obs_source_t *source, const struct obs_mouse_event *event, int32_t type, bool mouse_up, uint32_t click_count)
Used for interacting with sources: sends a mouse down/up event to a
source.
---------------------
.. function:: void obs_source_send_mouse_move(obs_source_t *source, const struct obs_mouse_event *event, bool mouse_leave)
Used for interacting with sources: sends a mouse move event to a
source.
---------------------
.. function:: void obs_source_send_mouse_wheel(obs_source_t *source, const struct obs_mouse_event *event, int x_delta, int y_delta)
Used for interacting with sources: sends a mouse wheel event to a
source.
---------------------
.. function:: void obs_source_send_focus(obs_source_t *source, bool focus)
Used for interacting with sources: sends a got-focus or lost-focus
event to a source.
---------------------
.. function:: void obs_source_send_key_click(obs_source_t *source, const struct obs_key_event *event, bool key_up)
Used for interacting with sources: sends a key up/down event to a
source.
---------------------
.. function:: enum obs_icon_type obs_source_get_icon_type(const char *id)
Calls the :c:member:`obs_source_info.icon_type` to get the icon type.
---------------------
.. function:: void obs_source_media_play_pause(obs_source_t *source, bool pause)
Calls the :c:member:`obs_source_info.media_play_pause` to pause or play media.
---------------------
.. function:: void obs_source_media_restart(obs_source_t *source)
Calls the :c:member:`obs_source_info.media_restart` to restart the media.
---------------------
.. function:: void obs_source_media_stop(obs_source_t *source)
Calls the :c:member:`obs_source_info.media_stop` to stop the media.
---------------------
.. function:: void obs_source_media_next(obs_source_t *source)
Calls the :c:member:`obs_source_info.media_next` to go to the next media.
---------------------
.. function:: void obs_source_media_previous(obs_source_t *source)
Calls the :c:member:`obs_source_info.media_previous` to go to the previous media.
---------------------
.. function:: int64_t obs_source_media_get_duration(obs_source_t *source)
Calls the :c:member:`obs_source_info.media_get_duration` to
get the media duration in milliseconds.
---------------------
.. function:: int64_t obs_source_media_get_time(obs_source_t *source)
void obs_source_media_set_time(obs_source_t *source, int64_t ms)
Calls the :c:member:`obs_source_info.media_get_time` or
:c:member:`obs_source_info.media_set_time` to get/set the
current time (in milliseconds) of the media. Will return 0
for non-media sources.
---------------------
.. function:: enum obs_media_state obs_source_media_get_state(obs_source_t *source)
Calls the :c:member:`obs_source_info.media_get_state` to get the state of the media.
---------------------
.. function:: void obs_source_media_started(obs_source_t *source)
Emits a **media_started** signal.
---------------------
.. function:: void obs_source_media_ended(obs_source_t *source)
Emits a **media_ended** signal.
---------------------
Functions used by sources
-------------------------
.. function:: void obs_source_draw_set_color_matrix(const struct matrix4 *color_matrix, const struct vec3 *color_range_min, const struct vec3 *color_range_max)
Helper function to set the color matrix information when drawing the
source.
:param color_matrix: The color matrix. Assigns to the 'color_matrix'
effect variable.
:param color_range_min: The minimum color range. Assigns to the
'color_range_min' effect variable. If NULL,
{0.0f, 0.0f, 0.0f} is used.
:param color_range_max: The maximum color range. Assigns to the
'color_range_max' effect variable. If NULL,
{1.0f, 1.0f, 1.0f} is used.
---------------------
.. function:: void obs_source_draw(gs_texture_t *image, int x, int y, uint32_t cx, uint32_t cy, bool flip)
Helper function to draw sprites for a source (synchronous video).
:param image: The sprite texture to draw. Assigns to the 'image' variable
of the current effect.
:param x: X position of the sprite.
:param y: Y position of the sprite.
:param cx: Width of the sprite. If 0, uses the texture width.
:param cy: Height of the sprite. If 0, uses the texture height.
:param flip: Specifies whether to flip the image vertically.
---------------------
.. function:: void obs_source_output_video(obs_source_t *source, const struct obs_source_frame *frame)
Outputs asynchronous video data. Set to NULL to deactivate the texture.
Relevant data types used with this function:
.. code:: cpp
enum video_format {
VIDEO_FORMAT_NONE,
/* planar 4:2:0 formats */
VIDEO_FORMAT_I420, /* three-plane */
VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */
/* packed 4:2:2 formats */
VIDEO_FORMAT_YVYU,
VIDEO_FORMAT_YUY2, /* YUYV */
VIDEO_FORMAT_UYVY,
/* packed uncompressed formats */
VIDEO_FORMAT_RGBA,
VIDEO_FORMAT_BGRA,
VIDEO_FORMAT_BGRX,
VIDEO_FORMAT_Y800, /* grayscale */
/* planar 4:4:4 */
VIDEO_FORMAT_I444,
/* more packed uncompressed formats */
VIDEO_FORMAT_BGR3,
/* planar 4:2:2 */
VIDEO_FORMAT_I422,
/* planar 4:2:0 with alpha */
VIDEO_FORMAT_I40A,
/* planar 4:2:2 with alpha */
VIDEO_FORMAT_I42A,
/* planar 4:4:4 with alpha */
VIDEO_FORMAT_YUVA,
/* packed 4:4:4 with alpha */
VIDEO_FORMAT_AYUV,
/* planar 4:2:0 format, 10 bpp */
VIDEO_FORMAT_I010, /* three-plane */
VIDEO_FORMAT_P010, /* two-plane, luma and packed chroma */
/* planar 4:2:2 format, 10 bpp */
VIDEO_FORMAT_I210,
/* planar 4:4:4 format, 12 bpp */
VIDEO_FORMAT_I412,
/* planar 4:4:4:4 format, 12 bpp */
VIDEO_FORMAT_YA2L,
/* planar 4:2:2 format, 16 bpp */
VIDEO_FORMAT_P216, /* two-plane, luma and packed chroma */
/* planar 4:4:4 format, 16 bpp */
VIDEO_FORMAT_P416, /* two-plane, luma and packed chroma */
/* packed 4:2:2 format, 10 bpp */
VIDEO_FORMAT_V210,
/* packed uncompressed 10-bit format */
VIDEO_FORMAT_R10L,
};
struct obs_source_frame {
uint8_t *data[MAX_AV_PLANES];
uint32_t linesize[MAX_AV_PLANES];
uint32_t width;
uint32_t height;
uint64_t timestamp;
enum video_format format;
float color_matrix[16];
bool full_range;
uint16_t max_luminance;
float color_range_min[3];
float color_range_max[3];
bool flip;
uint8_t flags;
uint8_t trc; /* enum video_trc */
};
---------------------
.. function:: void obs_source_set_async_rotation(obs_source_t *source, long rotation)
Allows the ability to set rotation (0, 90, 180, -90, 270) for an
async video source. The rotation will be automatically applied to
the source.
---------------------
.. function:: void obs_source_preload_video(obs_source_t *source, const struct obs_source_frame *frame)
Preloads a video frame to ensure a frame is ready for playback as
soon as video playback starts.
---------------------
.. function:: void obs_source_show_preloaded_video(obs_source_t *source)
Shows any preloaded video frame.
---------------------
.. function:: void obs_source_output_audio(obs_source_t *source, const struct obs_source_audio *audio)
Outputs audio data.
---------------------
.. function:: void obs_source_update_properties(obs_source_t *source)
Signals to any currently opened properties views (or other users of the
source's obs_properties_t) that the source's presentable properties have
changed and that the view should be updated.
---------------------
.. function:: bool obs_source_add_active_child(obs_source_t *parent, obs_source_t *child)
Adds an active child source. Must be called by parent sources on child
sources when the child is added and active. This ensures that the source is
properly activated if the parent is active.
:return: *true* if source can be added, *false* if it causes recursion
---------------------
.. function:: void obs_source_remove_active_child(obs_source_t *parent, obs_source_t *child)
Removes an active child source. Must be called by parent sources on child
sources when the child is removed or inactive. This ensures that the source
is properly deactivated if the parent is no longer active.
---------------------
Filters
-------
.. function:: obs_source_t *obs_filter_get_parent(const obs_source_t *filter)
If the source is a filter, returns the parent source of the filter.
The parent source is the source being filtered. Does not increment the
reference.
Only guaranteed to be valid inside of the video_render, filter_audio,
filter_video, filter_add, and filter_remove callbacks.
---------------------
.. function:: obs_source_t *obs_filter_get_target(const obs_source_t *filter)
If the source is a filter, returns the target source of the filter.
The target source is the next source in the filter chain. Does not increment
the reference.
Only guaranteed to be valid inside of the video_render, filter_audio,
filter_video, and filter_remove callbacks.
---------------------
.. function:: void obs_source_default_render(obs_source_t *source)
Can be used by filters to directly render a non-async parent source
without any filter processing.
---------------------
.. function:: void obs_source_filter_add(obs_source_t *source, obs_source_t *filter)
void obs_source_filter_remove(obs_source_t *source, obs_source_t *filter)
Adds/removes a filter to/from a source.
---------------------
.. function:: void obs_source_filter_set_order(obs_source_t *source, obs_source_t *filter, enum obs_order_movement movement)
Modifies the order of a specific filter.
:param movement: | Can be one of the following:
| OBS_ORDER_MOVE_UP
| OBS_ORDER_MOVE_DOWN
| OBS_ORDER_MOVE_TOP
| OBS_ORDER_MOVE_BOTTOM
---------------------
.. function:: void obs_source_filter_set_index(obs_source_t *source, obs_source_t *filter, size_t index)
Moves a filter to the specified index in the filters array.
:param index: | The index to move the filter to.
.. versionadded:: 30.0
---------------------
.. function:: int obs_source_filter_get_index(obs_source_t *source, obs_source_t *filter)
Gets the index of the specified filter.
:return: Index of the filter or -1 if it is invalid/not found.
.. versionadded:: 30.0
Functions used by filters
-------------------------
.. function:: bool obs_source_process_filter_begin(obs_source_t *filter, enum gs_color_format format, enum obs_allow_direct_render allow_direct)
Default RGB filter handler for generic effect filters. Processes the
filter chain and renders them to texture if needed, then the filter is
drawn with.
After calling this, set your parameters for the effect, then call
obs_source_process_filter_end to draw the filter.
:return: *true* if filtering should continue, *false* if the filter
is bypassed for whatever reason
---------------------
.. function:: bool obs_source_process_filter_begin_with_color_space(obs_source_t *filter, enum gs_color_format format, enum gs_color_space space, enum obs_allow_direct_render allow_direct)
Similar to obs_source_process_filter_begin, but also set the active
color space.
:return: *true* if filtering should continue, *false* if the filter
is bypassed for whatever reason
---------------------
.. function:: void obs_source_process_filter_end(obs_source_t *filter, gs_effect_t *effect, uint32_t width, uint32_t height)
Draws the filter using the effect's "Draw" technique.
Before calling this function, first call obs_source_process_filter_begin and
then set the effect parameters, and then call this function to finalize the
filter.
---------------------
.. function:: void obs_source_process_filter_tech_end(obs_source_t *filter, gs_effect_t *effect, uint32_t width, uint32_t height, const char *tech_name)
Draws the filter with a specific technique in the effect.
Before calling this function, first call obs_source_process_filter_begin and
then set the effect parameters, and then call this function to finalize the
filter.
---------------------
.. function:: void obs_source_skip_video_filter(obs_source_t *filter)
Skips the filter if the filter is invalid and cannot be rendered.
---------------------
.. _transitions:
Transitions
-----------
.. function:: obs_source_t *obs_transition_get_source(obs_source_t *transition, enum obs_transition_target target)
:param target: | OBS_TRANSITION_SOURCE_A - Source being transitioned from, or the current source if not transitioning
| OBS_TRANSITION_SOURCE_B - Source being transitioned to
:return: An incremented reference to the source or destination
sources of the transition. Use :c:func:`obs_source_release`
to release it.
---------------------
.. function:: void obs_transition_clear(obs_source_t *transition)
Clears the transition.
---------------------
.. function:: obs_source_t *obs_transition_get_active_source(obs_source_t *transition)
:return: An incremented reference to the currently active source of
the transition. Use :c:func:`obs_source_release` to release it.
---------------------
.. function:: bool obs_transition_start(obs_source_t *transition, enum obs_transition_mode mode, uint32_t duration_ms, obs_source_t *dest)
Starts the transition with the desired destination source.
:param mode: Currently only OBS_TRANSITION_MODE_AUTO
:param duration_ms: Duration in milliseconds. If the transition has
a fixed duration set by
:c:func:`obs_transition_enable_fixed`, this
parameter will have no effect
:param dest: The destination source to transition to
---------------------
.. function:: void obs_transition_set_size(obs_source_t *transition, uint32_t cx, uint32_t cy)
void obs_transition_get_size(const obs_source_t *transition, uint32_t *cx, uint32_t *cy)
Sets/gets the dimensions of the transition.
---------------------
.. function:: void obs_transition_set_scale_type(obs_source_t *transition, enum obs_transition_scale_type type)
enum obs_transition_scale_type obs_transition_get_scale_type( const obs_source_t *transition)
Sets/gets the scale type for sources within the transition.
:param type: | OBS_TRANSITION_SCALE_MAX_ONLY - Scale to aspect ratio, but only to the maximum size of each source
| OBS_TRANSITION_SCALE_ASPECT - Always scale the sources, but keep aspect ratio
| OBS_TRANSITION_SCALE_STRETCH - Scale and stretch the sources to the size of the transition
---------------------
.. function:: void obs_transition_set_alignment(obs_source_t *transition, uint32_t alignment)
uint32_t obs_transition_get_alignment(const obs_source_t *transition)
Sets/gets the alignment used to draw the two sources within
transition the transition.
:param alignment: | Can be any bitwise OR combination of:
| OBS_ALIGN_CENTER
| OBS_ALIGN_LEFT
| OBS_ALIGN_RIGHT
| OBS_ALIGN_TOP
| OBS_ALIGN_BOTTOM
---------------------
Functions used by transitions
-----------------------------
.. function:: void obs_transition_enable_fixed(obs_source_t *transition, bool enable, uint32_t duration_ms)
bool obs_transition_fixed(obs_source_t *transition)
Sets/gets whether the transition uses a fixed duration. Useful for
certain types of transitions such as stingers. If this is set, the
*duration_ms* parameter of :c:func:`obs_transition_start()` has no
effect.
---------------------
.. function:: float obs_transition_get_time(obs_source_t *transition)
:return: The current transition time value (0.0f..1.0f)
---------------------
.. function:: void obs_transition_video_render(obs_source_t *transition, obs_transition_video_render_callback_t callback)
void obs_transition_video_render2(obs_source_t *transition, obs_transition_video_render_callback_t callback, gs_texture_t *placeholder_texture)
Helper function used for rendering transitions. This function will
render two distinct textures for source A and source B of the
transition, allowing the ability to blend them together with a pixel
shader in a desired manner.
The *a* and *b* parameters of *callback* are automatically rendered
textures of source A and source B, *t* is the time value
(0.0f..1.0f), *cx* and *cy* are the current dimensions of the
transition, and *data* is the implementation's private data.
The *placeholder_texture* parameter allows a callback to receive
a replacement that isn't the default transparent texture, including
NULL if the caller desires.
Relevant data types used with this function:
.. code:: cpp
typedef void (*obs_transition_video_render_callback_t)(void *data,
gs_texture_t *a, gs_texture_t *b, float t,
uint32_t cx, uint32_t cy);
---------------------
.. function:: enum gs_color_space obs_transition_video_get_color_space(obs_source_t *transition)
Figure out the color space that encompasses both child sources.
The wider space wins.
:return: The color space of the transition
---------------------
.. function:: bool obs_transition_audio_render(obs_source_t *transition, uint64_t *ts_out, struct obs_source_audio_mix *audio, uint32_t mixers, size_t channels, size_t sample_rate, obs_transition_audio_mix_callback_t mix_a_callback, obs_transition_audio_mix_callback_t mix_b_callback)
Helper function used for transitioning audio. Typically you'd call
this in the obs_source_info.audio_render callback with its
parameters, and use the mix_a_callback and mix_b_callback to
determine the the audio fading of source A and source B.
Relevant data types used with this function:
.. code:: cpp
typedef float (*obs_transition_audio_mix_callback_t)(void *data, float t);
---------------------
.. function:: void obs_transition_swap_begin(obs_source_t *tr_dest, obs_source_t *tr_source)
void obs_transition_swap_end(obs_source_t *tr_dest, obs_source_t *tr_source)
Swaps two transitions. Call obs_transition_swap_begin, swap the
source, then call obs_transition_swap_end when complete. This allows
the ability to seamlessly swap two different transitions without it
affecting the output.
For example, if a transition is assigned to output channel 0, you'd
call obs_transition_swap_begin, then you'd call obs_set_output_source
with the new transition, then call
:c:func:`obs_transition_swap_begin()`.
.. ---------------------------------------------------------------------------
.. _libobs/obs-source.h: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-source.h
|