// WARNING: Please don't edit this file. It was generated by Python/WinRT v3.2.1

#include "py.Windows.Media.Casting.h"

namespace py::cpp::Windows::Media::Casting
{
    // ----- CastingConnection class --------------------

    static PyObject* _new_CastingConnection(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Casting::CastingConnection>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Casting::CastingConnection>::type_name);
        return nullptr;
    }

    static void _dealloc_CastingConnection(py::wrapper::Windows::Media::Casting::CastingConnection* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CastingConnection_Close(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingConnection", L"Close", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Close();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingConnection_DisconnectAsync(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingConnection", L"DisconnectAsync", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.DisconnectAsync();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingConnection_RequestStartCastingAsync(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingConnection", L"RequestStartCastingAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Media::Casting::CastingSource>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.RequestStartCastingAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingConnection_get_Source(py::wrapper::Windows::Media::Casting::CastingConnection* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingConnection", L"Source");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Source();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int CastingConnection_put_Source(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingConnection", L"Source");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Media::Casting::CastingSource>(arg);

            {
                auto _gil = release_gil();
                self->obj.Source(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* CastingConnection_get_Device(py::wrapper::Windows::Media::Casting::CastingConnection* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingConnection", L"Device");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Device();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingConnection_get_State(py::wrapper::Windows::Media::Casting::CastingConnection* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingConnection", L"State");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.State();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingConnection_add_ErrorOccurred(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Casting.CastingConnection", L"ErrorOccurred");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Media::Casting::CastingConnection, winrt::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ErrorOccurred(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingConnection_remove_ErrorOccurred(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Casting.CastingConnection", L"ErrorOccurred");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            {
                auto _gil = release_gil();
                self->obj.ErrorOccurred(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingConnection_add_StateChanged(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Casting.CastingConnection", L"StateChanged");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Media::Casting::CastingConnection, winrt::Windows::Foundation::IInspectable>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.StateChanged(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingConnection_remove_StateChanged(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Casting.CastingConnection", L"StateChanged");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            {
                auto _gil = release_gil();
                self->obj.StateChanged(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_CastingConnection(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Media::Casting::CastingConnection>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CastingConnection(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Media::Casting::CastingConnection>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _enter_CastingConnection(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* /*unused*/) noexcept
    {
        return Py_NewRef(self);
    }

    static PyObject* _exit_CastingConnection(py::wrapper::Windows::Media::Casting::CastingConnection* self, PyObject* /*unused*/) noexcept
    {
        try
        {
            {
                auto _gil = py::release_gil();
                self->obj.Close();
            }

            Py_RETURN_FALSE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CastingConnection[] = {
        { "close", reinterpret_cast<PyCFunction>(CastingConnection_Close), METH_VARARGS, nullptr },
        { "disconnect_async", reinterpret_cast<PyCFunction>(CastingConnection_DisconnectAsync), METH_VARARGS, nullptr },
        { "request_start_casting_async", reinterpret_cast<PyCFunction>(CastingConnection_RequestStartCastingAsync), METH_VARARGS, nullptr },
        { "add_error_occurred", reinterpret_cast<PyCFunction>(CastingConnection_add_ErrorOccurred), METH_O, nullptr },
        { "remove_error_occurred", reinterpret_cast<PyCFunction>(CastingConnection_remove_ErrorOccurred), METH_O, nullptr },
        { "add_state_changed", reinterpret_cast<PyCFunction>(CastingConnection_add_StateChanged), METH_O, nullptr },
        { "remove_state_changed", reinterpret_cast<PyCFunction>(CastingConnection_remove_StateChanged), METH_O, nullptr },
        { "_assign_array_", _assign_array_CastingConnection, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CastingConnection), METH_O | METH_STATIC, nullptr },
        { "__enter__", reinterpret_cast<PyCFunction>(_enter_CastingConnection), METH_NOARGS, nullptr },
        { "__exit__", reinterpret_cast<PyCFunction>(_exit_CastingConnection), METH_VARARGS, nullptr },
        { }};

    static PyGetSetDef _getset_CastingConnection[] = {
        { "source", reinterpret_cast<getter>(CastingConnection_get_Source), reinterpret_cast<setter>(CastingConnection_put_Source), nullptr, nullptr },
        { "device", reinterpret_cast<getter>(CastingConnection_get_Device), nullptr, nullptr, nullptr },
        { "state", reinterpret_cast<getter>(CastingConnection_get_State), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_CastingConnection[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CastingConnection) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CastingConnection) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CastingConnection) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CastingConnection) },
        { }};

    static PyType_Spec type_spec_CastingConnection = {
        "winrt._winrt_windows_media_casting.CastingConnection",
        sizeof(py::wrapper::Windows::Media::Casting::CastingConnection),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CastingConnection};

    // ----- CastingConnectionErrorOccurredEventArgs class --------------------

    static PyObject* _new_CastingConnectionErrorOccurredEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_CastingConnectionErrorOccurredEventArgs(py::wrapper::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CastingConnectionErrorOccurredEventArgs_get_ErrorStatus(py::wrapper::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingConnectionErrorOccurredEventArgs", L"ErrorStatus");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ErrorStatus();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingConnectionErrorOccurredEventArgs_get_Message(py::wrapper::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingConnectionErrorOccurredEventArgs", L"Message");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Message();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_CastingConnectionErrorOccurredEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CastingConnectionErrorOccurredEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CastingConnectionErrorOccurredEventArgs[] = {
        { "_assign_array_", _assign_array_CastingConnectionErrorOccurredEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CastingConnectionErrorOccurredEventArgs), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_CastingConnectionErrorOccurredEventArgs[] = {
        { "error_status", reinterpret_cast<getter>(CastingConnectionErrorOccurredEventArgs_get_ErrorStatus), nullptr, nullptr, nullptr },
        { "message", reinterpret_cast<getter>(CastingConnectionErrorOccurredEventArgs_get_Message), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_CastingConnectionErrorOccurredEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CastingConnectionErrorOccurredEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CastingConnectionErrorOccurredEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CastingConnectionErrorOccurredEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CastingConnectionErrorOccurredEventArgs) },
        { }};

    static PyType_Spec type_spec_CastingConnectionErrorOccurredEventArgs = {
        "winrt._winrt_windows_media_casting.CastingConnectionErrorOccurredEventArgs",
        sizeof(py::wrapper::Windows::Media::Casting::CastingConnectionErrorOccurredEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CastingConnectionErrorOccurredEventArgs};

    // ----- CastingDevice class --------------------

    static PyObject* _new_CastingDevice(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Casting::CastingDevice>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Casting::CastingDevice>::type_name);
        return nullptr;
    }

    static void _dealloc_CastingDevice(py::wrapper::Windows::Media::Casting::CastingDevice* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CastingDevice_CreateCastingConnection(py::wrapper::Windows::Media::Casting::CastingDevice* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevice", L"CreateCastingConnection", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.CreateCastingConnection();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevice_DeviceInfoSupportsCastingAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevice", L"DeviceInfoSupportsCastingAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Enumeration::DeviceInformation>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Media::Casting::CastingDevice::DeviceInfoSupportsCastingAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevice_FromIdAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevice", L"FromIdAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Media::Casting::CastingDevice::FromIdAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevice_GetDeviceSelector(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevice", L"GetDeviceSelector", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Media::Casting::CastingPlaybackTypes>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Media::Casting::CastingDevice::GetDeviceSelector(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevice_GetDeviceSelectorFromCastingSourceAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevice", L"GetDeviceSelectorFromCastingSourceAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Media::Casting::CastingSource>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Media::Casting::CastingDevice::GetDeviceSelectorFromCastingSourceAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevice_GetSupportedCastingPlaybackTypesAsync(py::wrapper::Windows::Media::Casting::CastingDevice* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevice", L"GetSupportedCastingPlaybackTypesAsync", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.GetSupportedCastingPlaybackTypesAsync();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevice_get_FriendlyName(py::wrapper::Windows::Media::Casting::CastingDevice* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevice", L"FriendlyName");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.FriendlyName();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingDevice_get_Icon(py::wrapper::Windows::Media::Casting::CastingDevice* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevice", L"Icon");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Icon();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingDevice_get_Id(py::wrapper::Windows::Media::Casting::CastingDevice* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevice", L"Id");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Id();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_CastingDevice(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Media::Casting::CastingDevice>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CastingDevice(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Media::Casting::CastingDevice>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CastingDevice[] = {
        { "create_casting_connection", reinterpret_cast<PyCFunction>(CastingDevice_CreateCastingConnection), METH_VARARGS, nullptr },
        { "get_supported_casting_playback_types_async", reinterpret_cast<PyCFunction>(CastingDevice_GetSupportedCastingPlaybackTypesAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_CastingDevice, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CastingDevice), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_CastingDevice[] = {
        { "friendly_name", reinterpret_cast<getter>(CastingDevice_get_FriendlyName), nullptr, nullptr, nullptr },
        { "icon", reinterpret_cast<getter>(CastingDevice_get_Icon), nullptr, nullptr, nullptr },
        { "id", reinterpret_cast<getter>(CastingDevice_get_Id), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_CastingDevice[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CastingDevice) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CastingDevice) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CastingDevice) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CastingDevice) },
        { }};

    static PyType_Spec type_spec_CastingDevice = {
        "winrt._winrt_windows_media_casting.CastingDevice",
        sizeof(py::wrapper::Windows::Media::Casting::CastingDevice),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CastingDevice};

    static PyGetSetDef getset_CastingDevice_Static[] = {
        { }};

    static PyMethodDef methods_CastingDevice_Static[] = {
        { "device_info_supports_casting_async", reinterpret_cast<PyCFunction>(CastingDevice_DeviceInfoSupportsCastingAsync), METH_VARARGS, nullptr },
        { "from_id_async", reinterpret_cast<PyCFunction>(CastingDevice_FromIdAsync), METH_VARARGS, nullptr },
        { "get_device_selector", reinterpret_cast<PyCFunction>(CastingDevice_GetDeviceSelector), METH_VARARGS, nullptr },
        { "get_device_selector_from_casting_source_async", reinterpret_cast<PyCFunction>(CastingDevice_GetDeviceSelectorFromCastingSourceAsync), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_CastingDevice_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_CastingDevice_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_CastingDevice_Static) },
        { }
    };

    static PyType_Spec type_spec_CastingDevice_Static = {
        "winrt._winrt_windows_media_casting.CastingDevice_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_CastingDevice_Static};

    // ----- CastingDevicePicker class --------------------

    static PyObject* _new_CastingDevicePicker(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_GET_SIZE(args);
        if (arg_count == 0)
        {
            try
            {
                winrt::Windows::Media::Casting::CastingDevicePicker instance{};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_CastingDevicePicker(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CastingDevicePicker_Hide(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevicePicker", L"Hide", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Hide();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevicePicker_Show(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevicePicker", L"Show", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Foundation::Rect>(args, 0);

                {
                    auto _gil = release_gil();
                    self->obj.Show(param0);
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevicePicker_ShowWithPlacement(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 2)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Casting.CastingDevicePicker", L"Show", 2);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(2);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Foundation::Rect>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::UI::Popups::Placement>(args, 1);

                {
                    auto _gil = release_gil();
                    self->obj.Show(param0, param1);
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* CastingDevicePicker_get_Appearance(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePicker", L"Appearance");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Appearance();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingDevicePicker_get_Filter(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePicker", L"Filter");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Filter();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingDevicePicker_add_CastingDevicePickerDismissed(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Casting.CastingDevicePicker", L"CastingDevicePickerDismissed");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Media::Casting::CastingDevicePicker, winrt::Windows::Foundation::IInspectable>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.CastingDevicePickerDismissed(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingDevicePicker_remove_CastingDevicePickerDismissed(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Casting.CastingDevicePicker", L"CastingDevicePickerDismissed");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            {
                auto _gil = release_gil();
                self->obj.CastingDevicePickerDismissed(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingDevicePicker_add_CastingDeviceSelected(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Casting.CastingDevicePicker", L"CastingDeviceSelected");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Media::Casting::CastingDevicePicker, winrt::Windows::Media::Casting::CastingDeviceSelectedEventArgs>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.CastingDeviceSelected(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* CastingDevicePicker_remove_CastingDeviceSelected(py::wrapper::Windows::Media::Casting::CastingDevicePicker* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Casting.CastingDevicePicker", L"CastingDeviceSelected");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            {
                auto _gil = release_gil();
                self->obj.CastingDeviceSelected(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_CastingDevicePicker(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Media::Casting::CastingDevicePicker>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CastingDevicePicker(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Media::Casting::CastingDevicePicker>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CastingDevicePicker[] = {
        { "hide", reinterpret_cast<PyCFunction>(CastingDevicePicker_Hide), METH_VARARGS, nullptr },
        { "show", reinterpret_cast<PyCFunction>(CastingDevicePicker_Show), METH_VARARGS, nullptr },
        { "show_with_placement", reinterpret_cast<PyCFunction>(CastingDevicePicker_ShowWithPlacement), METH_VARARGS, nullptr },
        { "add_casting_device_picker_dismissed", reinterpret_cast<PyCFunction>(CastingDevicePicker_add_CastingDevicePickerDismissed), METH_O, nullptr },
        { "remove_casting_device_picker_dismissed", reinterpret_cast<PyCFunction>(CastingDevicePicker_remove_CastingDevicePickerDismissed), METH_O, nullptr },
        { "add_casting_device_selected", reinterpret_cast<PyCFunction>(CastingDevicePicker_add_CastingDeviceSelected), METH_O, nullptr },
        { "remove_casting_device_selected", reinterpret_cast<PyCFunction>(CastingDevicePicker_remove_CastingDeviceSelected), METH_O, nullptr },
        { "_assign_array_", _assign_array_CastingDevicePicker, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CastingDevicePicker), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_CastingDevicePicker[] = {
        { "appearance", reinterpret_cast<getter>(CastingDevicePicker_get_Appearance), nullptr, nullptr, nullptr },
        { "filter", reinterpret_cast<getter>(CastingDevicePicker_get_Filter), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_CastingDevicePicker[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CastingDevicePicker) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CastingDevicePicker) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CastingDevicePicker) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CastingDevicePicker) },
        { }};

    static PyType_Spec type_spec_CastingDevicePicker = {
        "winrt._winrt_windows_media_casting.CastingDevicePicker",
        sizeof(py::wrapper::Windows::Media::Casting::CastingDevicePicker),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CastingDevicePicker};

    // ----- CastingDevicePickerFilter class --------------------

    static PyObject* _new_CastingDevicePickerFilter(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Casting::CastingDevicePickerFilter>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Casting::CastingDevicePickerFilter>::type_name);
        return nullptr;
    }

    static void _dealloc_CastingDevicePickerFilter(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CastingDevicePickerFilter_get_SupportsVideo(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePickerFilter", L"SupportsVideo");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.SupportsVideo();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int CastingDevicePickerFilter_put_SupportsVideo(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePickerFilter", L"SupportsVideo");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<bool>(arg);

            {
                auto _gil = release_gil();
                self->obj.SupportsVideo(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* CastingDevicePickerFilter_get_SupportsPictures(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePickerFilter", L"SupportsPictures");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.SupportsPictures();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int CastingDevicePickerFilter_put_SupportsPictures(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePickerFilter", L"SupportsPictures");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<bool>(arg);

            {
                auto _gil = release_gil();
                self->obj.SupportsPictures(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* CastingDevicePickerFilter_get_SupportsAudio(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePickerFilter", L"SupportsAudio");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.SupportsAudio();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int CastingDevicePickerFilter_put_SupportsAudio(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePickerFilter", L"SupportsAudio");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<bool>(arg);

            {
                auto _gil = release_gil();
                self->obj.SupportsAudio(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* CastingDevicePickerFilter_get_SupportedCastingSources(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDevicePickerFilter", L"SupportedCastingSources");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.SupportedCastingSources();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_CastingDevicePickerFilter(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Media::Casting::CastingDevicePickerFilter>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CastingDevicePickerFilter(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Media::Casting::CastingDevicePickerFilter>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CastingDevicePickerFilter[] = {
        { "_assign_array_", _assign_array_CastingDevicePickerFilter, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CastingDevicePickerFilter), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_CastingDevicePickerFilter[] = {
        { "supports_video", reinterpret_cast<getter>(CastingDevicePickerFilter_get_SupportsVideo), reinterpret_cast<setter>(CastingDevicePickerFilter_put_SupportsVideo), nullptr, nullptr },
        { "supports_pictures", reinterpret_cast<getter>(CastingDevicePickerFilter_get_SupportsPictures), reinterpret_cast<setter>(CastingDevicePickerFilter_put_SupportsPictures), nullptr, nullptr },
        { "supports_audio", reinterpret_cast<getter>(CastingDevicePickerFilter_get_SupportsAudio), reinterpret_cast<setter>(CastingDevicePickerFilter_put_SupportsAudio), nullptr, nullptr },
        { "supported_casting_sources", reinterpret_cast<getter>(CastingDevicePickerFilter_get_SupportedCastingSources), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_CastingDevicePickerFilter[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CastingDevicePickerFilter) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CastingDevicePickerFilter) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CastingDevicePickerFilter) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CastingDevicePickerFilter) },
        { }};

    static PyType_Spec type_spec_CastingDevicePickerFilter = {
        "winrt._winrt_windows_media_casting.CastingDevicePickerFilter",
        sizeof(py::wrapper::Windows::Media::Casting::CastingDevicePickerFilter),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CastingDevicePickerFilter};

    // ----- CastingDeviceSelectedEventArgs class --------------------

    static PyObject* _new_CastingDeviceSelectedEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Casting::CastingDeviceSelectedEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Casting::CastingDeviceSelectedEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_CastingDeviceSelectedEventArgs(py::wrapper::Windows::Media::Casting::CastingDeviceSelectedEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CastingDeviceSelectedEventArgs_get_SelectedCastingDevice(py::wrapper::Windows::Media::Casting::CastingDeviceSelectedEventArgs* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingDeviceSelectedEventArgs", L"SelectedCastingDevice");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.SelectedCastingDevice();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_CastingDeviceSelectedEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Media::Casting::CastingDeviceSelectedEventArgs>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CastingDeviceSelectedEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Media::Casting::CastingDeviceSelectedEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CastingDeviceSelectedEventArgs[] = {
        { "_assign_array_", _assign_array_CastingDeviceSelectedEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CastingDeviceSelectedEventArgs), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_CastingDeviceSelectedEventArgs[] = {
        { "selected_casting_device", reinterpret_cast<getter>(CastingDeviceSelectedEventArgs_get_SelectedCastingDevice), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_CastingDeviceSelectedEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CastingDeviceSelectedEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CastingDeviceSelectedEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CastingDeviceSelectedEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CastingDeviceSelectedEventArgs) },
        { }};

    static PyType_Spec type_spec_CastingDeviceSelectedEventArgs = {
        "winrt._winrt_windows_media_casting.CastingDeviceSelectedEventArgs",
        sizeof(py::wrapper::Windows::Media::Casting::CastingDeviceSelectedEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CastingDeviceSelectedEventArgs};

    // ----- CastingSource class --------------------

    static PyObject* _new_CastingSource(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Casting::CastingSource>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Casting::CastingSource>::type_name);
        return nullptr;
    }

    static void _dealloc_CastingSource(py::wrapper::Windows::Media::Casting::CastingSource* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CastingSource_get_PreferredSourceUri(py::wrapper::Windows::Media::Casting::CastingSource* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingSource", L"PreferredSourceUri");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.PreferredSourceUri();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int CastingSource_put_PreferredSourceUri(py::wrapper::Windows::Media::Casting::CastingSource* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Casting.CastingSource", L"PreferredSourceUri");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::Uri>(arg);

            {
                auto _gil = release_gil();
                self->obj.PreferredSourceUri(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* _assign_array_CastingSource(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Media::Casting::CastingSource>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CastingSource(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Media::Casting::CastingSource>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CastingSource[] = {
        { "_assign_array_", _assign_array_CastingSource, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CastingSource), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_CastingSource[] = {
        { "preferred_source_uri", reinterpret_cast<getter>(CastingSource_get_PreferredSourceUri), reinterpret_cast<setter>(CastingSource_put_PreferredSourceUri), nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_CastingSource[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CastingSource) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CastingSource) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CastingSource) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CastingSource) },
        { }};

    static PyType_Spec type_spec_CastingSource = {
        "winrt._winrt_windows_media_casting.CastingSource",
        sizeof(py::wrapper::Windows::Media::Casting::CastingSource),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CastingSource};

    // ----- Windows.Media.Casting Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Media.Casting");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_media_casting",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Media::Casting

PyMODINIT_FUNC PyInit__winrt_windows_media_casting(void) noexcept
{
    using namespace py::cpp::Windows::Media::Casting;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto inspectable_meta_type = py::get_inspectable_meta_type();
    if (!inspectable_meta_type)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pytype_handle CastingConnection_type{py::register_python_type(module.get(), &type_spec_CastingConnection, object_bases.get(), inspectable_meta_type)};
    if (!CastingConnection_type)
    {
        return nullptr;
    }

    py::pytype_handle CastingConnectionErrorOccurredEventArgs_type{py::register_python_type(module.get(), &type_spec_CastingConnectionErrorOccurredEventArgs, object_bases.get(), inspectable_meta_type)};
    if (!CastingConnectionErrorOccurredEventArgs_type)
    {
        return nullptr;
    }

    py::pyobj_handle CastingDevice_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!CastingDevice_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_CastingDevice_Static{PyType_FromSpecWithBases(&type_spec_CastingDevice_Static, CastingDevice_Static_bases.get())};
    if (!type_CastingDevice_Static)
    {
        return nullptr;
    }

    py::pytype_handle CastingDevice_type{py::register_python_type(module.get(), &type_spec_CastingDevice, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_CastingDevice_Static.get()))};
    if (!CastingDevice_type)
    {
        return nullptr;
    }

    py::pytype_handle CastingDevicePicker_type{py::register_python_type(module.get(), &type_spec_CastingDevicePicker, object_bases.get(), inspectable_meta_type)};
    if (!CastingDevicePicker_type)
    {
        return nullptr;
    }

    py::pytype_handle CastingDevicePickerFilter_type{py::register_python_type(module.get(), &type_spec_CastingDevicePickerFilter, object_bases.get(), inspectable_meta_type)};
    if (!CastingDevicePickerFilter_type)
    {
        return nullptr;
    }

    py::pytype_handle CastingDeviceSelectedEventArgs_type{py::register_python_type(module.get(), &type_spec_CastingDeviceSelectedEventArgs, object_bases.get(), inspectable_meta_type)};
    if (!CastingDeviceSelectedEventArgs_type)
    {
        return nullptr;
    }

    py::pytype_handle CastingSource_type{py::register_python_type(module.get(), &type_spec_CastingSource, object_bases.get(), inspectable_meta_type)};
    if (!CastingSource_type)
    {
        return nullptr;
    }


    return module.detach();
}
