'Gets the the changes that have happened since the last sync.
Args:
sync_result_builder(SyncResultBuilder)
ignored_users(set(str)): Set of users ignored by user.
Returns:
Deferred(tuple): Returns a tuple of the form:
`([RoomSyncResultBuilder], [InvitedSyncResult], newly_joined_rooms)`'

@defer.inlineCallbacks
def _get_rooms_changed(self, sync_result_builder, ignored_users):

    user_id = sync_result_builder.sync_config.user.to_string()
    since_token = sync_result_builder.since_token
    now_token = sync_result_builder.now_token
    sync_config = sync_result_builder.sync_config
    assert since_token
    app_service = self.store.get_app_service_by_user_id(user_id)
    if app_service:
        rooms = (yield self.store.get_app_service_rooms(app_service))
        joined_room_ids = set((r.room_id for r in rooms))
    else:
        joined_room_ids = (yield self.store.get_rooms_for_user(user_id))
    rooms_changed = (yield self.store.get_membership_changes_for_user(user_id, since_token.room_key, now_token.room_key))
    mem_change_events_by_room_id = {}
    for event in rooms_changed:
        mem_change_events_by_room_id.setdefault(event.room_id, []).append(event)
    newly_joined_rooms = []
    room_entries = []
    invited = []
    for (room_id, events) in mem_change_events_by_room_id.items():
        non_joins = [e for e in events if (e.membership != Membership.JOIN)]
        has_join = (len(non_joins) != len(events))
        if ((room_id in joined_room_ids) or has_join):
            old_state_ids = (yield self.get_state_at(room_id, since_token))
            old_mem_ev_id = old_state_ids.get((EventTypes.Member, user_id), None)
            old_mem_ev = None
            if old_mem_ev_id:
                old_mem_ev = (yield self.store.get_event(old_mem_ev_id, allow_none=True))
            if ((not old_mem_ev) or (old_mem_ev.membership != Membership.JOIN)):
                newly_joined_rooms.append(room_id)
            if (room_id in joined_room_ids):
                continue
        if (not non_joins):
            continue
        should_invite = (non_joins[(-1)].membership == Membership.INVITE)
        if should_invite:
            if (event.sender not in ignored_users):
                room_sync = InvitedSyncResult(room_id, invite=non_joins[(-1)])
                if room_sync:
                    invited.append(room_sync)
        leave_events = [e for e in non_joins if (e.membership in (Membership.LEAVE, Membership.BAN))]
        if leave_events:
            leave_event = leave_events[(-1)]
            leave_stream_token = (yield self.store.get_stream_token_for_event(leave_event.event_id))
            leave_token = since_token.copy_and_replace('room_key', leave_stream_token)
            if (since_token and since_token.is_after(leave_token)):
                continue
            room_entries.append(RoomSyncResultBuilder(room_id=room_id, rtype='archived', events=None, newly_joined=(room_id in newly_joined_rooms), full_state=False, since_token=since_token, upto_token=leave_token))
    timeline_limit = sync_config.filter_collection.timeline_limit()
    room_to_events = (yield self.store.get_room_events_stream_for_rooms(room_ids=joined_room_ids, from_key=since_token.room_key, to_key=now_token.room_key, limit=(timeline_limit + 1)))
    for room_id in joined_room_ids:
        room_entry = room_to_events.get(room_id, None)
        if room_entry:
            (events, start_key) = room_entry
            prev_batch_token = now_token.copy_and_replace('room_key', start_key)
            room_entries.append(RoomSyncResultBuilder(room_id=room_id, rtype='joined', events=events, newly_joined=(room_id in newly_joined_rooms), full_state=False, since_token=(None if (room_id in newly_joined_rooms) else since_token), upto_token=prev_batch_token))
        else:
            room_entries.append(RoomSyncResultBuilder(room_id=room_id, rtype='joined', events=[], newly_joined=(room_id in newly_joined_rooms), full_state=False, since_token=since_token, upto_token=since_token))
    defer.returnValue((room_entries, invited, newly_joined_rooms))
